]> granicus.if.org Git - clang/commitdiff
[OPENMP] Codegen `declare simd` for function declarations.
authorAlexey Bataev <a.bataev@hotmail.com>
Fri, 15 Dec 2017 16:28:31 +0000 (16:28 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Fri, 15 Dec 2017 16:28:31 +0000 (16:28 +0000)
Previously the attributes were emitted only for function definitions.
Patch adds emission of the attributes for function declarations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320826 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenFunction.cpp
lib/CodeGen/CodeGenModule.cpp
test/OpenMP/declare_simd_codegen.cpp

index a8dac422a6e41eab41690b17b43d6c59a1983942..f9155b2ba322915108cd33779830e1376cd516e2 100644 (file)
@@ -899,10 +899,6 @@ void CodeGenFunction::StartFunction(GlobalDecl GD,
     }
   }
 
-  if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D))
-    if (CGM.getLangOpts().OpenMP && FD->hasAttr<OMPDeclareSimdDeclAttr>())
-      CGM.getOpenMPRuntime().emitDeclareSimdFunction(FD, Fn);
-
   // Add no-jump-tables value.
   Fn->addFnAttr("no-jump-tables",
                 llvm::toStringRef(CGM.getCodeGenOpts().NoUseJumpTables));
index 421a1ad3d0dcd313a2bceb0888c19cf398254d8c..c59dc71da5960968a66cd1490362e8d1aff01769 100644 (file)
@@ -1238,6 +1238,9 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, llvm::Function *F,
   // is handled with better precision by the receiving DSO.
   if (!CodeGenOpts.SanitizeCfiCrossDso)
     CreateFunctionTypeMetadata(FD, F);
+
+  if (getLangOpts().OpenMP && FD->hasAttr<OMPDeclareSimdDeclAttr>())
+    getOpenMPRuntime().emitDeclareSimdFunction(FD, F);
 }
 
 void CodeGenModule::addUsedGlobal(llvm::GlobalValue *GV) {
index 47e951999b6a1ad3cb307c971ea77ea45e7a23ac..9ae476677c42eeed94c9a2ebf9c2f4b54d38ad6f 100644 (file)
@@ -5,14 +5,25 @@
 #ifndef HEADER
 #define HEADER
 
+#pragma omp declare simd linear(d : 8)
+#pragma omp declare simd inbranch simdlen(32)
+#pragma omp declare simd notinbranch
+void add_1(float *d);
+
 #pragma omp declare simd linear(d : 8)
 #pragma omp declare simd inbranch simdlen(32)
 #pragma omp declare simd notinbranch
 void add_1(float *d) {}
 
+#pragma omp declare simd linear(d : 8)
+#pragma omp declare simd inbranch simdlen(32)
+#pragma omp declare simd notinbranch
+void add_2(float *d);
+
 #pragma omp declare simd aligned(hp, hp2)
 template <class C>
 void h(C *hp, C *hp2, C *hq, C *lin) {
+  add_2(0);
 }
 
 // Explicit specialization with <C=int>.
@@ -110,6 +121,7 @@ double foo(double x) { return 0; }
 // CHECK-DAG: define {{.+}}@_Z3bax2VVPdi(
 // CHECK-DAG: define {{.+}}@_Z3fooPffi(
 // CHECK-DAG: define {{.+}}@_Z3food(
+// CHECK-DAG: declare {{.+}}@_Z5add_2Pf(
 
 // CHECK-DAG: "_ZGVbM4l8__Z5add_1Pf"
 // CHECK-DAG: "_ZGVbN4l8__Z5add_1Pf"
@@ -277,6 +289,23 @@ double foo(double x) { return 0; }
 // CHECK-DAG: "_ZGVeM16ua16vl1__Z3fooPffi"
 // CHECK-DAG: "_ZGVeN16ua16vl1__Z3fooPffi"
 
+// CHECK-DAG: "_ZGVbM4l8__Z5add_2Pf"
+// CHECK-DAG: "_ZGVbN4l8__Z5add_2Pf"
+// CHECK-DAG: "_ZGVcM8l8__Z5add_2Pf"
+// CHECK-DAG: "_ZGVcN8l8__Z5add_2Pf"
+// CHECK-DAG: "_ZGVdM8l8__Z5add_2Pf"
+// CHECK-DAG: "_ZGVdN8l8__Z5add_2Pf"
+// CHECK-DAG: "_ZGVeM16l8__Z5add_2Pf"
+// CHECK-DAG: "_ZGVeN16l8__Z5add_2Pf"
+// CHECK-DAG: "_ZGVbM32v__Z5add_2Pf"
+// CHECK-DAG: "_ZGVcM32v__Z5add_2Pf"
+// CHECK-DAG: "_ZGVdM32v__Z5add_2Pf"
+// CHECK-DAG: "_ZGVeM32v__Z5add_2Pf"
+// CHECK-DAG: "_ZGVbN2v__Z5add_2Pf"
+// CHECK-DAG: "_ZGVcN4v__Z5add_2Pf"
+// CHECK-DAG: "_ZGVdN4v__Z5add_2Pf"
+// CHECK-DAG: "_ZGVeN8v__Z5add_2Pf"
+
 // CHECK-DAG: "_ZGVbN2v__Z3food"
 // CHECK-DAG: "_ZGVcN4v__Z3food"
 // CHECK-DAG: "_ZGVdN4v__Z3food"