diff options
author | Jeremy Morse <jeremy.morse@sony.com> | 2025-07-16 14:13:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-16 14:13:53 +0100 |
commit | 5328c732a47705363cd289cb281cbd0d3ccbb8fc (patch) | |
tree | 6e3fafdc4edd881f9e3b9c60bd35bbda33caa311 /llvm/lib/Transforms/Utils/CloneFunction.cpp | |
parent | 9ea27b841cdf3c702b5e0bc696eb404492dbc79f (diff) | |
download | llvm-5328c732a47705363cd289cb281cbd0d3ccbb8fc.zip llvm-5328c732a47705363cd289cb281cbd0d3ccbb8fc.tar.gz llvm-5328c732a47705363cd289cb281cbd0d3ccbb8fc.tar.bz2 |
[DebugInfo] Strip more debug-intrinsic code from local utils (#149037)
SROA and a few other facilities use generic-lambdas and some overloaded
functions to deal with both intrinsics and debug-records at the same time.
As part of stripping out intrinsic support, delete a swathe of this code
from things in the Utils directory.
This is a large diff, but is mostly about removing functions that were
duplicated during the migration to debug records. I've taken a few
opportunities to replace comments about "intrinsics" with "records",
and replace generic lambdas with plain lambdas (I believe this makes
it more readable).
All of this is chipping away at intrinsic-specific code until we get to
removing parts of findDbgUsers, which is the final boss -- we can't
remove that until almost everything else is gone.
Diffstat (limited to 'llvm/lib/Transforms/Utils/CloneFunction.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/CloneFunction.cpp | 30 |
1 files changed, 5 insertions, 25 deletions
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp index fccb73a..b187208 100644 --- a/llvm/lib/Transforms/Utils/CloneFunction.cpp +++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp @@ -576,9 +576,8 @@ void PruningFunctionCloner::CloneBlock( } // Eagerly remap operands to the newly cloned instruction, except for PHI - // nodes for which we defer processing until we update the CFG. Also defer - // debug intrinsic processing because they may contain use-before-defs. - if (!isa<PHINode>(NewInst) && !isa<DbgVariableIntrinsic>(NewInst)) { + // nodes for which we defer processing until we update the CFG. + if (!isa<PHINode>(NewInst)) { RemapInstruction(NewInst, VMap, ModuleLevelChanges ? RF_None : RF_NoModuleLevelChanges); @@ -733,15 +732,6 @@ void llvm::CloneAndPruneIntoFromInst(Function *NewFunc, const Function *OldFunc, StartingInst = &StartingBB->front(); } - // Collect debug intrinsics for remapping later. - SmallVector<const DbgVariableIntrinsic *, 8> DbgIntrinsics; - for (const auto &BB : *OldFunc) { - for (const auto &I : BB) { - if (const auto *DVI = dyn_cast<DbgVariableIntrinsic>(&I)) - DbgIntrinsics.push_back(DVI); - } - } - // Clone the entry block, and anything recursively reachable from it. std::vector<const BasicBlock *> CloneWorklist; PFC.CloneBlock(StartingBB, StartingInst->getIterator(), CloneWorklist); @@ -899,21 +889,11 @@ void llvm::CloneAndPruneIntoFromInst(Function *NewFunc, const Function *OldFunc, // Restore attributes. NewFunc->setAttributes(Attrs); - // Remap debug intrinsic operands now that all values have been mapped. - // Doing this now (late) preserves use-before-defs in debug intrinsics. If + // Remap debug records operands now that all values have been mapped. + // Doing this now (late) preserves use-before-defs in debug records. If // we didn't do this, ValueAsMetadata(use-before-def) operands would be // replaced by empty metadata. This would signal later cleanup passes to - // remove the debug intrinsics, potentially causing incorrect locations. - for (const auto *DVI : DbgIntrinsics) { - if (DbgVariableIntrinsic *NewDVI = - cast_or_null<DbgVariableIntrinsic>(VMap.lookup(DVI))) - RemapInstruction(NewDVI, VMap, - ModuleLevelChanges ? RF_None : RF_NoModuleLevelChanges, - TypeMapper, Materializer); - } - - // Do the same for DbgVariableRecords, touching all the instructions in the - // cloned range of blocks. + // remove the debug records, potentially causing incorrect locations. Function::iterator Begin = cast<BasicBlock>(VMap[StartingBB])->getIterator(); for (BasicBlock &BB : make_range(Begin, NewFunc->end())) { for (Instruction &I : BB) { |