Author: abataev Date: Tue Oct 17 09:47:34 2017 New Revision: 316011 URL: http://llvm.org/viewvc/llvm-project?rev=316011&view=rev Log: [OPENMP] Fix capturing of boolean variables in debug mode.
If the variables is boolean and we generating inner function with real types, the codegen may crash because of not loading boolean value from memory. Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=316011&r1=316010&r2=316011&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original) +++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Tue Oct 17 09:47:34 2017 @@ -501,9 +501,10 @@ CodeGenFunction::GenerateOpenMPCapturedS llvm::Value *CallArg; auto I = LocalAddrs.find(Arg); if (I != LocalAddrs.end()) { - LValue LV = - WrapperCGF.MakeAddrLValue(I->second.second, Arg->getType(), - AlignmentSource::Decl); + LValue LV = WrapperCGF.MakeAddrLValue( + I->second.second, + I->second.first ? I->second.first->getType() : Arg->getType(), + AlignmentSource::Decl); CallArg = WrapperCGF.EmitLoadOfScalar(LV, SourceLocation()); } else { auto EI = VLASizes.find(Arg); @@ -516,7 +517,7 @@ CodeGenFunction::GenerateOpenMPCapturedS CallArg = WrapperCGF.EmitLoadOfScalar(LV, SourceLocation()); } } - CallArgs.emplace_back(CallArg); + CallArgs.emplace_back(WrapperCGF.EmitFromMemory(CallArg, Arg->getType())); } CGM.getOpenMPRuntime().emitOutlinedFunctionCall(WrapperCGF, S.getLocStart(), F, CallArgs); Modified: cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp?rev=316011&r1=316010&r2=316011&view=diff ============================================================================== --- cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp (original) +++ cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp Tue Oct 17 09:47:34 2017 @@ -11,7 +11,7 @@ int main() { int c[10][10][10]; #pragma omp target parallel firstprivate(a, b) map(tofrom \ : c) map(tofrom \ - : bb) + : bb) if (a) { int &f = c[1][1][1]; int &g = a; @@ -54,7 +54,7 @@ int main() { return 0; } -// CHECK: define internal void @__omp_offloading{{[^(]+}}([10 x [10 x [10 x i32]]] addrspace(1)* {{[^,]+}}, i32 {{[^,]+}}, [10 x [10 x i32]]* {{[^,]+}}, i8 addrspace(1)* noalias{{[^)]+}}) +// CHECK: define internal void @__omp_offloading{{[^(]+}}([10 x [10 x [10 x i32]]] addrspace(1)* {{[^,]+}}, i32 {{[^,]+}}, [10 x [10 x i32]]* {{[^,]+}}, i8 addrspace(1)* noalias{{[^,]+}}, i1 {{[^)]+}}) // CHECK: addrspacecast [10 x [10 x [10 x i32]]] addrspace(1)* %{{.+}} to [10 x [10 x [10 x i32]]]* // CHECK: call void [[NONDEBUG_WRAPPER:.+]](i32* {{[^,]+}}, i32* {{[^,]+}}, [10 x [10 x [10 x i32]]]* {{[^,]+}}, i64 {{[^,]+}}, [10 x [10 x i32]]* {{[^,]+}}, i8* {{[^)]+}}) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits