Skip to content

Commit a850473

Browse files
committed
[OMPIRBuilder] Don't discard the debug record from entry block.
When we get a function back from CodeExtractor, we disard its entry block after coping its instructions into the entry block we prepared. While copying the instructions, the terminator is discarded for obvious reasons. But if there were some debug values attached to the terminator, those are useful and needs to be copied.
1 parent 712c213 commit a850473

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,8 +788,13 @@ void OpenMPIRBuilder::finalize(Function *Fn) {
788788
Instruction &I = *It;
789789
It++;
790790

791-
if (I.isTerminator())
791+
if (I.isTerminator()) {
792+
// Absorb any debug value that terminator may have
793+
if (OI.EntryBB->getTerminator())
794+
OI.EntryBB->getTerminator()->adoptDbgRecords(
795+
&ArtificialEntry, I.getIterator(), false);
792796
continue;
797+
}
793798

794799
I.moveBeforePreserving(*OI.EntryBB, OI.EntryBB->getFirstInsertionPt());
795800
}

0 commit comments

Comments
 (0)