Skip to content

Commit 27285df

Browse files
authored
Refine metadata handling during instruction hoisting
1 parent 9490d58 commit 27285df

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3387,11 +3387,13 @@ bool SimplifyCFGOpt::speculativelyExecuteBB(BranchInst *BI,
33873387
// Metadata can be dependent on the condition we are hoisting above.
33883388
// Strip all UB-implying metadata on the instruction. Drop the debug loc
33893389
// to avoid making it appear as if the condition is a constant, which would
3390-
// be misleading while debugging.
3390+
// be misleading while debugging. However, make sure to keep debug info
3391+
// for calls as inlinable function calls in a function with debug info must
3392+
// have a !dbg location.
33913393
// Similarly strip attributes that maybe dependent on condition we are
33923394
// hoisting above.
33933395
for (auto &I : make_early_inc_range(*ThenBB)) {
3394-
if (!SpeculatedStoreValue || &I != SpeculatedStore) {
3396+
if (!SpeculatedStoreValue || &I != SpeculatedStore && !isa<CallBase>(&I)) {
33953397
I.setDebugLoc(DebugLoc::getDropped());
33963398
}
33973399
I.dropUBImplyingAttrsAndMetadata();

0 commit comments

Comments
 (0)