Re: r364080 - [OPENMP]Fix PR42068: Vla type is not captured.
Thanks, will fix this ASAP. Best regards, Alexey Bataev > 24 июня 2019 г., в 1:37, Yvan Roux написал(а): > > Hi Alexey, > > This commit broke ARM bots, logs are availabale here: > > http://lab.llvm.org:8011/builders/clang-cmake-armv8-quick/builds/13627/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Aparallel_codegen.cpp > > Thanks, > Yvan > > On Fri, 21 Jun 2019 at 19:25, Alexey Bataev via cfe-commits > wrote: >> >> Author: abataev >> Date: Fri Jun 21 10:28:41 2019 >> New Revision: 364080 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=364080&view=rev >> Log: >> [OPENMP]Fix PR42068: Vla type is not captured. >> >> If the variably modified type is declared outside of the captured region >> and then used in the cast expression along with array subscript >> expression, the type is not captured and it leads to the compiler crash. >> >> Modified: >>cfe/trunk/lib/Sema/SemaExpr.cpp >>cfe/trunk/test/OpenMP/parallel_codegen.cpp >> >> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=364080&r1=364079&r2=364080&view=diff >> == >> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) >> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Jun 21 10:28:41 2019 >> @@ -4737,6 +4737,33 @@ Sema::CreateBuiltinArraySubscriptExpr(Ex >> assert(VK == VK_RValue || LangOpts.CPlusPlus || >> !ResultType.isCForbiddenLValueType()); >> >> + if (LHSExp->IgnoreParenImpCasts()->getType()->isVariablyModifiedType() && >> + FunctionScopes.size() > 1) { >> +if (auto *TT = >> +LHSExp->IgnoreParenImpCasts()->getType()->getAs()) >> { >> + for (auto I = FunctionScopes.rbegin(), >> +E = std::prev(FunctionScopes.rend()); >> + I != E; ++I) { >> +auto *CSI = dyn_cast(*I); >> +if (CSI == nullptr) >> + break; >> +DeclContext *DC = nullptr; >> +if (auto *LSI = dyn_cast(CSI)) >> + DC = LSI->CallOperator; >> +else if (auto *CRSI = dyn_cast(CSI)) >> + DC = CRSI->TheCapturedDecl; >> +else if (auto *BSI = dyn_cast(CSI)) >> + DC = BSI->TheDecl; >> +if (DC) { >> + if (DC->containsDecl(TT->getDecl())) >> +break; >> + captureVariablyModifiedType( >> + Context, LHSExp->IgnoreParenImpCasts()->getType(), CSI); >> +} >> + } >> +} >> + } >> + >> return new (Context) >> ArraySubscriptExpr(LHSExp, RHSExp, ResultType, VK, OK, RLoc); >> } >> >> Modified: cfe/trunk/test/OpenMP/parallel_codegen.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_codegen.cpp?rev=364080&r1=364079&r2=364080&view=diff >> == >> --- cfe/trunk/test/OpenMP/parallel_codegen.cpp (original) >> +++ cfe/trunk/test/OpenMP/parallel_codegen.cpp Fri Jun 21 10:28:41 2019 >> @@ -15,16 +15,20 @@ >> // CHECK-DEBUG-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* } >> // CHECK-DEBUG-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] >> c";unknown;unknown;0;0;;\00" >> // CHECK-DEBUG-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr global >> %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds >> ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) } >> -// CHECK-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant [{{.+}} x >> i8] c";{{.*}}parallel_codegen.cpp;main;[[@LINE+15]];1;;\00" >> -// CHECK-DEBUG-DAG: [[LOC2:@.+]] = private unnamed_addr constant [{{.+}} x >> i8] c";{{.*}}parallel_codegen.cpp;tmain;[[@LINE+7]];1;;\00" >> +// CHECK-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant [{{.+}} x >> i8] c";{{.*}}parallel_codegen.cpp;main;[[@LINE+19]];1;;\00" >> +// CHECK-DEBUG-DAG: [[LOC2:@.+]] = private unnamed_addr constant [{{.+}} x >> i8] c";{{.*}}parallel_codegen.cpp;tmain;[[@LINE+8]];1;;\00" >> >> template >> void foo(T argc) {} >> >> template >> int tmain(T argc) { >> + typedef double (*chunk_t)[argc[0][0]]; >> #pragma omp parallel >> + { >> foo(argc); >> + chunk_t var;(void)var[0][0]; >> + } >> return 0; >> } >> >> @@ -90,7 +94,7 @@ int main (int argc, char **argv) { >> >> // CHECK: define linkonce_odr {{[a-z\_\b]*[ ]?i32}} [[TMAIN]](i8** >> %argc) >> // CHECK: store i8** %argc, i8*** [[ARGC_ADDR:%.+]], >> -// CHECK-NEXT: call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, >> ...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 1, void >> (i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***)* [[OMP_OUTLINED:@.+]] >> to void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]]) >> +// CHECK: call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, >> ...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 2, void >> (i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***, i64)* >> [[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*),
Re: r364080 - [OPENMP]Fix PR42068: Vla type is not captured.
Hi Alexey, This commit broke ARM bots, logs are availabale here: http://lab.llvm.org:8011/builders/clang-cmake-armv8-quick/builds/13627/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Aparallel_codegen.cpp Thanks, Yvan On Fri, 21 Jun 2019 at 19:25, Alexey Bataev via cfe-commits wrote: > > Author: abataev > Date: Fri Jun 21 10:28:41 2019 > New Revision: 364080 > > URL: http://llvm.org/viewvc/llvm-project?rev=364080&view=rev > Log: > [OPENMP]Fix PR42068: Vla type is not captured. > > If the variably modified type is declared outside of the captured region > and then used in the cast expression along with array subscript > expression, the type is not captured and it leads to the compiler crash. > > Modified: > cfe/trunk/lib/Sema/SemaExpr.cpp > cfe/trunk/test/OpenMP/parallel_codegen.cpp > > Modified: cfe/trunk/lib/Sema/SemaExpr.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=364080&r1=364079&r2=364080&view=diff > == > --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) > +++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Jun 21 10:28:41 2019 > @@ -4737,6 +4737,33 @@ Sema::CreateBuiltinArraySubscriptExpr(Ex >assert(VK == VK_RValue || LangOpts.CPlusPlus || > !ResultType.isCForbiddenLValueType()); > > + if (LHSExp->IgnoreParenImpCasts()->getType()->isVariablyModifiedType() && > + FunctionScopes.size() > 1) { > +if (auto *TT = > +LHSExp->IgnoreParenImpCasts()->getType()->getAs()) { > + for (auto I = FunctionScopes.rbegin(), > +E = std::prev(FunctionScopes.rend()); > + I != E; ++I) { > +auto *CSI = dyn_cast(*I); > +if (CSI == nullptr) > + break; > +DeclContext *DC = nullptr; > +if (auto *LSI = dyn_cast(CSI)) > + DC = LSI->CallOperator; > +else if (auto *CRSI = dyn_cast(CSI)) > + DC = CRSI->TheCapturedDecl; > +else if (auto *BSI = dyn_cast(CSI)) > + DC = BSI->TheDecl; > +if (DC) { > + if (DC->containsDecl(TT->getDecl())) > +break; > + captureVariablyModifiedType( > + Context, LHSExp->IgnoreParenImpCasts()->getType(), CSI); > +} > + } > +} > + } > + >return new (Context) >ArraySubscriptExpr(LHSExp, RHSExp, ResultType, VK, OK, RLoc); > } > > Modified: cfe/trunk/test/OpenMP/parallel_codegen.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_codegen.cpp?rev=364080&r1=364079&r2=364080&view=diff > == > --- cfe/trunk/test/OpenMP/parallel_codegen.cpp (original) > +++ cfe/trunk/test/OpenMP/parallel_codegen.cpp Fri Jun 21 10:28:41 2019 > @@ -15,16 +15,20 @@ > // CHECK-DEBUG-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* } > // CHECK-DEBUG-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] > c";unknown;unknown;0;0;;\00" > // CHECK-DEBUG-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr global > %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 > x i8], [23 x i8]* [[STR]], i32 0, i32 0) } > -// CHECK-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant [{{.+}} x > i8] c";{{.*}}parallel_codegen.cpp;main;[[@LINE+15]];1;;\00" > -// CHECK-DEBUG-DAG: [[LOC2:@.+]] = private unnamed_addr constant [{{.+}} x > i8] c";{{.*}}parallel_codegen.cpp;tmain;[[@LINE+7]];1;;\00" > +// CHECK-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant [{{.+}} x > i8] c";{{.*}}parallel_codegen.cpp;main;[[@LINE+19]];1;;\00" > +// CHECK-DEBUG-DAG: [[LOC2:@.+]] = private unnamed_addr constant [{{.+}} x > i8] c";{{.*}}parallel_codegen.cpp;tmain;[[@LINE+8]];1;;\00" > > template > void foo(T argc) {} > > template > int tmain(T argc) { > + typedef double (*chunk_t)[argc[0][0]]; > #pragma omp parallel > + { >foo(argc); > + chunk_t var;(void)var[0][0]; > + } >return 0; > } > > @@ -90,7 +94,7 @@ int main (int argc, char **argv) { > > // CHECK: define linkonce_odr {{[a-z\_\b]*[ ]?i32}} [[TMAIN]](i8** > %argc) > // CHECK: store i8** %argc, i8*** [[ARGC_ADDR:%.+]], > -// CHECK-NEXT: call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, > ...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 1, void > (i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***)* [[OMP_OUTLINED:@.+]] to > void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]]) > +// CHECK: call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, > ...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 2, void > (i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***, i64)* > [[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]], i64 > %{{.+}}) > // CHECK-NEXT: ret i32 0 > // CHECK-NEXT: } > // CHECK-DEBUG: define linkonce_odr i32 [[TMAIN]](i8** %argc) > @@ -101,23 +105,23 @@ int main (int argc, char **argv) { > // CHECK-DEBUG
r364080 - [OPENMP]Fix PR42068: Vla type is not captured.
Author: abataev Date: Fri Jun 21 10:28:41 2019 New Revision: 364080 URL: http://llvm.org/viewvc/llvm-project?rev=364080&view=rev Log: [OPENMP]Fix PR42068: Vla type is not captured. If the variably modified type is declared outside of the captured region and then used in the cast expression along with array subscript expression, the type is not captured and it leads to the compiler crash. Modified: cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/test/OpenMP/parallel_codegen.cpp Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=364080&r1=364079&r2=364080&view=diff == --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Jun 21 10:28:41 2019 @@ -4737,6 +4737,33 @@ Sema::CreateBuiltinArraySubscriptExpr(Ex assert(VK == VK_RValue || LangOpts.CPlusPlus || !ResultType.isCForbiddenLValueType()); + if (LHSExp->IgnoreParenImpCasts()->getType()->isVariablyModifiedType() && + FunctionScopes.size() > 1) { +if (auto *TT = +LHSExp->IgnoreParenImpCasts()->getType()->getAs()) { + for (auto I = FunctionScopes.rbegin(), +E = std::prev(FunctionScopes.rend()); + I != E; ++I) { +auto *CSI = dyn_cast(*I); +if (CSI == nullptr) + break; +DeclContext *DC = nullptr; +if (auto *LSI = dyn_cast(CSI)) + DC = LSI->CallOperator; +else if (auto *CRSI = dyn_cast(CSI)) + DC = CRSI->TheCapturedDecl; +else if (auto *BSI = dyn_cast(CSI)) + DC = BSI->TheDecl; +if (DC) { + if (DC->containsDecl(TT->getDecl())) +break; + captureVariablyModifiedType( + Context, LHSExp->IgnoreParenImpCasts()->getType(), CSI); +} + } +} + } + return new (Context) ArraySubscriptExpr(LHSExp, RHSExp, ResultType, VK, OK, RLoc); } Modified: cfe/trunk/test/OpenMP/parallel_codegen.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_codegen.cpp?rev=364080&r1=364079&r2=364080&view=diff == --- cfe/trunk/test/OpenMP/parallel_codegen.cpp (original) +++ cfe/trunk/test/OpenMP/parallel_codegen.cpp Fri Jun 21 10:28:41 2019 @@ -15,16 +15,20 @@ // CHECK-DEBUG-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* } // CHECK-DEBUG-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00" // CHECK-DEBUG-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr global %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) } -// CHECK-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant [{{.+}} x i8] c";{{.*}}parallel_codegen.cpp;main;[[@LINE+15]];1;;\00" -// CHECK-DEBUG-DAG: [[LOC2:@.+]] = private unnamed_addr constant [{{.+}} x i8] c";{{.*}}parallel_codegen.cpp;tmain;[[@LINE+7]];1;;\00" +// CHECK-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant [{{.+}} x i8] c";{{.*}}parallel_codegen.cpp;main;[[@LINE+19]];1;;\00" +// CHECK-DEBUG-DAG: [[LOC2:@.+]] = private unnamed_addr constant [{{.+}} x i8] c";{{.*}}parallel_codegen.cpp;tmain;[[@LINE+8]];1;;\00" template void foo(T argc) {} template int tmain(T argc) { + typedef double (*chunk_t)[argc[0][0]]; #pragma omp parallel + { foo(argc); + chunk_t var;(void)var[0][0]; + } return 0; } @@ -90,7 +94,7 @@ int main (int argc, char **argv) { // CHECK: define linkonce_odr {{[a-z\_\b]*[ ]?i32}} [[TMAIN]](i8** %argc) // CHECK: store i8** %argc, i8*** [[ARGC_ADDR:%.+]], -// CHECK-NEXT: call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***)* [[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]]) +// CHECK: call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 2, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***, i64)* [[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]], i64 %{{.+}}) // CHECK-NEXT: ret i32 0 // CHECK-NEXT: } // CHECK-DEBUG: define linkonce_odr i32 [[TMAIN]](i8** %argc) @@ -101,23 +105,23 @@ int main (int argc, char **argv) { // CHECK-DEBUG-NEXT: store i8** %argc, i8*** [[ARGC_ADDR:%.+]], // CHECK-DEBUG: [[KMPC_LOC_PSOURCE_REF:%.+]] = getelementptr inbounds %struct.ident_t, %struct.ident_t* [[LOC_2_ADDR]], i32 0, i32 4 // CHECK-DEBUG-NEXT: store i8* getelementptr inbounds ([{{.+}} x i8], [{{.+}} x i8]* [[LOC2]], i32 0, i32 0), i8** [[KMPC_LOC_PSOURCE_REF]] -// CHECK-DEBUG-NEXT: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[LOC_2_ADDR]], i32 1, void (i32*, i32*, ...)* bitc