Skip to content

Commit 0d443a0

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. llvm#135161
1 parent 04e49d8 commit 0d443a0

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
@@ -812,8 +812,13 @@ void OpenMPIRBuilder::finalize(Function *Fn) {
812812
Instruction &I = *It;
813813
It++;
814814

815-
if (I.isTerminator())
815+
if (I.isTerminator()) {
816+
// Absorb any debug value that terminator may have
817+
if (OI.EntryBB->getTerminator())
818+
OI.EntryBB->getTerminator()->adoptDbgRecords(
819+
&ArtificialEntry, I.getIterator(), false);
816820
continue;
821+
}
817822

818823
I.moveBeforePreserving(*OI.EntryBB, OI.EntryBB->getFirstInsertionPt());
819824
}

0 commit comments

Comments
 (0)