aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorStephen Tozer <stephen.tozer@sony.com>2025-06-11 18:42:10 +0200
committerGitHub <noreply@github.com>2025-06-11 17:42:10 +0100
commitaa8a1fa6f515f45db55365b9c1f8453ded24ed32 (patch)
treeb8559342c20da2f6dbbd1d1306719f3be30b1009 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp
parentf1575de4c5de9268f92eea1641af755a477e4ee4 (diff)
downloadllvm-aa8a1fa6f515f45db55365b9c1f8453ded24ed32.zip
llvm-aa8a1fa6f515f45db55365b9c1f8453ded24ed32.tar.gz
llvm-aa8a1fa6f515f45db55365b9c1f8453ded24ed32.tar.bz2
[DLCov][NFC] Annotate intentionally-blank DebugLocs in existing code (#136192)
Following the work in PR #107279, this patch applies the annotative DebugLocs, which indicate that a particular instruction is intentionally missing a location for a given reason, to existing sites in the compiler where their conditions apply. This is NFC in ordinary LLVM builds (each function `DebugLoc::getFoo()` is inlined as `DebugLoc()`), but marks the instruction in coverage-tracking builds so that it will be ignored by Debugify, allowing only real errors to be reported. From a developer standpoint, it also communicates the intentionality and reason for a missing DebugLoc. Some notes for reviewers: - The difference between `I->dropLocation()` and `I->setDebugLoc(DebugLoc::getDropped())` is that the former _may_ decide to keep some debug info alive, while the latter will always be empty; in this patch, I always used the latter (even if the former could technically be correct), because the former could result in some (barely) different output, and I'd prefer to keep this patch purely NFC. - I've generally documented the uses of `DebugLoc::getUnknown()`, with the exception of the vectorizers - in summary, they are a huge cause of dropped source locations, and I don't have the time or the domain knowledge currently to solve that, so I've plastered it all over them as a form of "fixme".
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index e221022..975ce3b 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1137,7 +1137,7 @@ static void cloneInstructionsIntoPredecessorBlockAndUpdateSSAUses(
// branch, drop it. When we fold the bonus instructions we want to make
// sure we reset their debug locations in order to avoid stepping on
// dead code caused by folding dead branches.
- NewBonusInst->setDebugLoc(DebugLoc());
+ NewBonusInst->setDebugLoc(DebugLoc::getDropped());
} else if (const DebugLoc &DL = NewBonusInst->getDebugLoc()) {
mapAtomInstance(DL, VMap);
}
@@ -2821,7 +2821,8 @@ static void mergeCompatibleInvokesImpl(ArrayRef<InvokeInst *> Invokes,
// so just form a new block with unreachable terminator.
BasicBlock *MergedNormalDest = BasicBlock::Create(
Ctx, II0BB->getName() + ".cont", Func, InsertBeforeBlock);
- new UnreachableInst(Ctx, MergedNormalDest);
+ auto *UI = new UnreachableInst(Ctx, MergedNormalDest);
+ UI->setDebugLoc(DebugLoc::getTemporary());
MergedInvoke->setNormalDest(MergedNormalDest);
}
@@ -3389,7 +3390,7 @@ bool SimplifyCFGOpt::speculativelyExecuteBB(BranchInst *BI,
if (!SpeculatedStoreValue || &I != SpeculatedStore) {
// Don't update the DILocation of dbg.assign intrinsics.
if (!isa<DbgAssignIntrinsic>(&I))
- I.setDebugLoc(DebugLoc());
+ I.setDebugLoc(DebugLoc::getDropped());
}
I.dropUBImplyingAttrsAndMetadata();
@@ -5707,7 +5708,8 @@ static void createUnreachableSwitchDefault(SwitchInst *Switch,
BasicBlock *NewDefaultBlock = BasicBlock::Create(
BB->getContext(), BB->getName() + ".unreachabledefault", BB->getParent(),
OrigDefaultBlock);
- new UnreachableInst(Switch->getContext(), NewDefaultBlock);
+ auto *UI = new UnreachableInst(Switch->getContext(), NewDefaultBlock);
+ UI->setDebugLoc(DebugLoc::getTemporary());
Switch->setDefaultDest(&*NewDefaultBlock);
if (DTU) {
SmallVector<DominatorTree::UpdateType, 2> Updates;