r320826 - [OPENMP] Codegen `declare simd` for function declarations.
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 15 08:28:31 PST 2017
Author: abataev
Date: Fri Dec 15 08:28:31 2017
New Revision: 320826
URL: http://llvm.org/viewvc/llvm-project?rev=320826&view=rev
Log:
[OPENMP] Codegen `declare simd` for function declarations.
Previously the attributes were emitted only for function definitions.
Patch adds emission of the attributes for function declarations.
Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/OpenMP/declare_simd_codegen.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=320826&r1=320825&r2=320826&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Dec 15 08:28:31 2017
@@ -899,10 +899,6 @@ void CodeGenFunction::StartFunction(Glob
}
}
- 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));
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=320826&r1=320825&r2=320826&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Dec 15 08:28:31 2017
@@ -1238,6 +1238,9 @@ void CodeGenModule::SetFunctionAttribute
// 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) {
Modified: cfe/trunk/test/OpenMP/declare_simd_codegen.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_simd_codegen.cpp?rev=320826&r1=320825&r2=320826&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/declare_simd_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/declare_simd_codegen.cpp Fri Dec 15 08:28:31 2017
@@ -8,11 +8,22 @@
#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"
More information about the cfe-commits
mailing list