From: Matt Arsenault Date: Mon, 13 Nov 2017 22:40:55 +0000 (+0000) Subject: OpenCL: Assume inline asm is convergent X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c20725e8f9d9d4079683e7035845d821d91f8367;p=clang OpenCL: Assume inline asm is convergent Already done for CUDA. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@318098 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index 6a78865fc9..7b1afab5f2 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/lib/CodeGen/CGStmt.cpp @@ -2149,10 +2149,11 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) { llvm::ConstantAsMetadata::get(Loc))); } - if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) { - // Conservatively, mark all inline asm blocks in CUDA as convergent - // (meaning, they may call an intrinsically convergent op, such as bar.sync, - // and so can't have certain optimizations applied around them). + if (getLangOpts().assumeFunctionsAreConvergent()) { + // Conservatively, mark all inline asm blocks in CUDA or OpenCL as + // convergent (meaning, they may call an intrinsically convergent op, such + // as bar.sync, and so can't have certain optimizations applied around + // them). Result->addAttribute(llvm::AttributeList::FunctionIndex, llvm::Attribute::Convergent); } diff --git a/test/CodeGenOpenCL/convergent.cl b/test/CodeGenOpenCL/convergent.cl index c46205bb9b..285b637ca6 100644 --- a/test/CodeGenOpenCL/convergent.cl +++ b/test/CodeGenOpenCL/convergent.cl @@ -126,6 +126,13 @@ void test_not_unroll() { // CHECK: declare spir_func void @nodupfun(){{[^#]*}} #[[attr3:[0-9]+]] +// CHECK-LABEL: @assume_convergent_asm +// CHECK: tail call void asm sideeffect "s_barrier", ""() #4 +kernel void assume_convergent_asm() +{ + __asm__ volatile("s_barrier"); +} + // CHECK: attributes #0 = { noinline norecurse nounwind " // CHECK: attributes #1 = { {{[^}]*}}convergent{{[^}]*}} } // CHECK: attributes #2 = { {{[^}]*}}convergent{{[^}]*}} }