From 89d9cac0aae327630607687eded08c3b992b572e Mon Sep 17 00:00:00 2001 From: Justin Lebar Date: Sat, 6 Feb 2016 19:32:44 +0000 Subject: [PATCH] [NVPTX] Mark nvvm synchronizing intrinsics as convergent. Summary: This is the attribute purpose-made for e.g. __syncthreads. It appears that NoDuplicate may not be sufficient to prevent Sink from touching a call to __syncthreads. Reviewers: jingyue, hfinkel Subscribers: llvm-commits, jholewinski, jhen, rnk, tra, majnemer Differential Revision: http://reviews.llvm.org/D16941 llvm-svn: 260005 --- include/llvm/IR/IntrinsicsNVVM.td | 14 +++++++++----- test/Feature/intrinsic-noduplicate.ll | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/llvm/IR/IntrinsicsNVVM.td b/include/llvm/IR/IntrinsicsNVVM.td index 9deed414b50..b0de7bacd2b 100644 --- a/include/llvm/IR/IntrinsicsNVVM.td +++ b/include/llvm/IR/IntrinsicsNVVM.td @@ -729,16 +729,20 @@ def llvm_anyi64ptr_ty : LLVMAnyPointerType; // (space)i64* [IntrReadWriteArgMem, NoCapture<0>]>; // Bar.Sync +// +// TODO: Remove NoDuplicate here after fixing up LLVM to handle convergent +// properly. See discussion in http://reviews.llvm.org/D16941 and +// http://reviews.llvm.org/D12246. def int_cuda_syncthreads : GCCBuiltin<"__syncthreads">, - Intrinsic<[], [], [IntrNoDuplicate]>; + Intrinsic<[], [], [IntrNoDuplicate, IntrConvergent]>; def int_nvvm_barrier0 : GCCBuiltin<"__nvvm_bar0">, - Intrinsic<[], [], [IntrNoDuplicate]>; + Intrinsic<[], [], [IntrNoDuplicate, IntrConvergent]>; def int_nvvm_barrier0_popc : GCCBuiltin<"__nvvm_bar0_popc">, - Intrinsic<[llvm_i32_ty], [llvm_i32_ty], [IntrNoDuplicate]>; + Intrinsic<[llvm_i32_ty], [llvm_i32_ty], [IntrNoDuplicate, IntrConvergent]>; def int_nvvm_barrier0_and : GCCBuiltin<"__nvvm_bar0_and">, - Intrinsic<[llvm_i32_ty], [llvm_i32_ty], [IntrNoDuplicate]>; + Intrinsic<[llvm_i32_ty], [llvm_i32_ty], [IntrNoDuplicate, IntrConvergent]>; def int_nvvm_barrier0_or : GCCBuiltin<"__nvvm_bar0_or">, - Intrinsic<[llvm_i32_ty], [llvm_i32_ty], [IntrNoDuplicate]>; + Intrinsic<[llvm_i32_ty], [llvm_i32_ty], [IntrNoDuplicate, IntrConvergent]>; // Membar def int_nvvm_membar_cta : GCCBuiltin<"__nvvm_membar_cta">, diff --git a/test/Feature/intrinsic-noduplicate.ll b/test/Feature/intrinsic-noduplicate.ll index 9a2b0aba5bd..1ffe6ac563c 100644 --- a/test/Feature/intrinsic-noduplicate.ll +++ b/test/Feature/intrinsic-noduplicate.ll @@ -1,9 +1,9 @@ ; RUN: llvm-as < %s | llvm-dis | FileCheck %s -; Make sure LLVM knows about the noduplicate attribute on the +; Make sure LLVM knows about the convergent and noduplicate attributes on the ; llvm.cuda.syncthreads intrinsic. declare void @llvm.cuda.syncthreads() ; CHECK: declare void @llvm.cuda.syncthreads() #[[ATTRNUM:[0-9]+]] -; CHECK: attributes #[[ATTRNUM]] = { noduplicate nounwind } +; CHECK: attributes #[[ATTRNUM]] = { convergent noduplicate nounwind }