Skip to content

Commit e367b9b

Browse files
ddpaganronlieb
authored andcommitted
[clang][OpenMP] Fix target data if/logical expression assert fail
Fixed assertion failure Basic Block in function 'main' does not have terminator! label %land.end caused by premature setting of CodeGenIP upon entry to emitTargetDataCalls, where subsequent evaluation of logical expression created new basic blocks, leaving CodeGenIP pointing to the wrong basic block. CodeGenIP is now set near the end of the function, just prior to generating a comparison of the logical expression result (from the if clause) which uses CodeGenIP to insert new IR. Fixes SWDEV-422794/AOMP issue llvm#601 Test already exists in smoke-fail/issue601_if_clause Change-Id: I792141db01b0f030705ec0742c9d9fb1255f036a
1 parent 992452c commit e367b9b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

clang/lib/CodeGen/CGOpenMPRuntime.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10640,11 +10640,6 @@ void CGOpenMPRuntime::emitTargetDataCalls(
1064010640
PrePostActionTy NoPrivAction;
1064110641

1064210642
using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
10643-
InsertPointTy AllocaIP(CGF.AllocaInsertPt->getParent(),
10644-
CGF.AllocaInsertPt->getIterator());
10645-
InsertPointTy CodeGenIP(CGF.Builder.GetInsertBlock(),
10646-
CGF.Builder.GetInsertPoint());
10647-
llvm::OpenMPIRBuilder::LocationDescription OmpLoc(CodeGenIP);
1064810643

1064910644
llvm::Value *IfCondVal = nullptr;
1065010645
if (IfCond)
@@ -10724,6 +10719,11 @@ void CGOpenMPRuntime::emitTargetDataCalls(
1072410719
// Source location for the ident struct
1072510720
llvm::Value *RTLoc = emitUpdateLocation(CGF, D.getBeginLoc());
1072610721

10722+
InsertPointTy AllocaIP(CGF.AllocaInsertPt->getParent(),
10723+
CGF.AllocaInsertPt->getIterator());
10724+
InsertPointTy CodeGenIP(CGF.Builder.GetInsertBlock(),
10725+
CGF.Builder.GetInsertPoint());
10726+
llvm::OpenMPIRBuilder::LocationDescription OmpLoc(CodeGenIP);
1072710727
CGF.Builder.restoreIP(OMPBuilder.createTargetData(
1072810728
OmpLoc, AllocaIP, CodeGenIP, DeviceID, IfCondVal, Info, GenMapInfoCB,
1072910729
/*MapperFunc=*/nullptr, BodyCB, DeviceAddrCB, CustomMapperCB, RTLoc));

0 commit comments

Comments
 (0)