]> granicus.if.org Git - clang/commitdiff
[OPENMP] Fix for PR30632: Name mangling issue.
authorAlexey Bataev <a.bataev@hotmail.com>
Tue, 15 Nov 2016 13:15:20 +0000 (13:15 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Tue, 15 Nov 2016 13:15:20 +0000 (13:15 +0000)
Reworked fix after comments from Richard Smith. We must skip all
CapturedDecl-based contexts when trying to get correct mangling number
context.

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

lib/Sema/SemaLambda.cpp
test/OpenMP/for_lastprivate_codegen.cpp

index fb3ac072f1eeb48ce5e4074579a49dd905512656..0715650b8a25c5416136a4c3ed816fc1c0f623bd 100644 (file)
@@ -317,12 +317,13 @@ Sema::getCurrentMangleNumberContext(const DeclContext *DC,
   case Normal: {
     //  -- the bodies of non-exported nonspecialized template functions
     //  -- the bodies of inline functions
-    auto *CD = dyn_cast<CapturedDecl>(CurContext);
     if ((IsInNonspecializedTemplate &&
          !(ManglingContextDecl && isa<ParmVarDecl>(ManglingContextDecl))) ||
-        isInInlineFunction(CurContext) || CD) {
+        isInInlineFunction(CurContext)) {
       ManglingContextDecl = nullptr;
-      return &Context.getManglingNumberContext(CD ? CD->getParent() : DC);
+      while (auto *CD = dyn_cast<CapturedDecl>(DC))
+        DC = CD->getParent();
+      return &Context.getManglingNumberContext(DC);
     }
 
     ManglingContextDecl = nullptr;
index 4df4fef7c768e6270b4154c725b9d27957655415..f0fba042c58ad90bf4dee8ea777075830937ea40 100644 (file)
@@ -40,7 +40,7 @@ struct SS {
     for (a = 0; a < 2; ++a)
 #ifdef LAMBDA
       [&]() {
-        ++this->a, --b, (this)->c /= 1;
+        --this->a, ++b, (this)->c *= 2;
 #pragma omp parallel
 #pragma omp for lastprivate(b)
         for (b = 0; b < 2; ++b)
@@ -189,7 +189,7 @@ int main() {
     // LAMBDA: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 1, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, [[SS_TY]]*)* [[SS_MICROTASK:@.+]] to void
     // LAMBDA: call void @__kmpc_for_static_init_4(
     // LAMBDA-NOT: getelementptr inbounds [[SS_TY]], [[SS_TY]]* %{{.+}}, i32 0, i32 0
-    // LAMBDA: call void {{.+}} [[SS_LAMBDA:@[^ ]+]]
+    // LAMBDA: call{{.*}} void [[SS_LAMBDA1:@[^ ]+]]
     // LAMBDA: call void @__kmpc_for_static_fini(%
     // LAMBDA: ret
 
@@ -199,7 +199,7 @@ int main() {
     // LAMBDA: getelementptr {{.*}}[[SS_TY]], [[SS_TY]]* %{{.*}}, i32 0, i32 2
     // LAMBDA: call void @__kmpc_for_static_init_4(
     // LAMBDA-NOT: getelementptr {{.*}}[[SS_TY]], [[SS_TY]]*
-    // LAMBDA: call{{.*}} void
+    // LAMBDA: call{{.*}} void [[SS_LAMBDA:@[^ ]+]]
     // LAMBDA: call void @__kmpc_for_static_fini(
     // LAMBDA: br i1
     // LAMBDA: [[B_REF:%.+]] = getelementptr {{.*}}[[SS_TY]], [[SS_TY]]* %{{.*}}, i32 0, i32 1
@@ -235,6 +235,9 @@ int main() {
     // LAMBDA: br label
     // LAMBDA: ret void
 
+    // LAMBDA: define internal void @{{.+}}(i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SS_TY]]* %{{.+}})
+    // LAMBDA: ret void
+
     // LAMBDA: define{{.*}} internal{{.*}} void [[OMP_REGION]](i32* noalias %{{.+}}, i32* noalias %{{.+}}, i32* dereferenceable(4) [[SIVAR:%.+]])
     // LAMBDA: alloca i{{[0-9]+}},
     // LAMBDA: alloca i{{[0-9]+}},