diff options
author | Stephen Tozer <stephen.tozer@sony.com> | 2025-06-11 18:42:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-11 17:42:10 +0100 |
commit | aa8a1fa6f515f45db55365b9c1f8453ded24ed32 (patch) | |
tree | b8559342c20da2f6dbbd1d1306719f3be30b1009 /llvm/lib/Transforms/Utils/InlineFunction.cpp | |
parent | f1575de4c5de9268f92eea1641af755a477e4ee4 (diff) | |
download | llvm-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/InlineFunction.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/InlineFunction.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index 7a9605b..f47c467 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -1775,6 +1775,7 @@ static Value *HandleByValArgument(Type *ByValType, Value *Arg, AllocaInst *NewAlloca = new AllocaInst(ByValType, Arg->getType()->getPointerAddressSpace(), nullptr, Alignment, Arg->getName()); + NewAlloca->setDebugLoc(DebugLoc::getCompilerGenerated()); NewAlloca->insertBefore(Caller->begin()->begin()); IFI.StaticAllocas.push_back(NewAlloca); @@ -3258,6 +3259,8 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI, // Add an unconditional branch to make this look like the CallInst case... CreatedBranchToNormalDest = BranchInst::Create(II->getNormalDest(), CB.getIterator()); + // We intend to replace this DebugLoc with another later. + CreatedBranchToNormalDest->setDebugLoc(DebugLoc::getTemporary()); // Split the basic block. This guarantees that no PHI nodes will have to be // updated due to new incoming edges, and make the invoke case more @@ -3359,6 +3362,12 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI, Returns[0]->eraseFromParent(); ReturnBB->eraseFromParent(); } else if (!CB.use_empty()) { + // In this case there are no returns to use, so there is no clear source + // location for the "return". + // FIXME: It may be correct to use the scope end line of the function here, + // since this likely means we are falling out of the function. + if (CreatedBranchToNormalDest) + CreatedBranchToNormalDest->setDebugLoc(DebugLoc::getUnknown()); // No returns, but something is using the return value of the call. Just // nuke the result. CB.replaceAllUsesWith(PoisonValue::get(CB.getType())); |