From: Alexey Bataev Date: Tue, 15 Nov 2016 13:15:20 +0000 (+0000) Subject: [OPENMP] Fix for PR30632: Name mangling issue. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=764f811a3eb55646c3b1bcb886be60ef09549e9e;p=clang [OPENMP] Fix for PR30632: Name mangling issue. 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 --- diff --git a/lib/Sema/SemaLambda.cpp b/lib/Sema/SemaLambda.cpp index fb3ac072f1..0715650b8a 100644 --- a/lib/Sema/SemaLambda.cpp +++ b/lib/Sema/SemaLambda.cpp @@ -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(CurContext); if ((IsInNonspecializedTemplate && !(ManglingContextDecl && isa(ManglingContextDecl))) || - isInInlineFunction(CurContext) || CD) { + isInInlineFunction(CurContext)) { ManglingContextDecl = nullptr; - return &Context.getManglingNumberContext(CD ? CD->getParent() : DC); + while (auto *CD = dyn_cast(DC)) + DC = CD->getParent(); + return &Context.getManglingNumberContext(DC); } ManglingContextDecl = nullptr; diff --git a/test/OpenMP/for_lastprivate_codegen.cpp b/test/OpenMP/for_lastprivate_codegen.cpp index 4df4fef7c7..f0fba042c5 100644 --- a/test/OpenMP/for_lastprivate_codegen.cpp +++ b/test/OpenMP/for_lastprivate_codegen.cpp @@ -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]+}},