aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorCarlos Alberto Enciso <Carlos.Enciso@sony.com>2024-04-26 13:35:09 +0100
committerGitHub <noreply@github.com>2024-04-26 13:35:09 +0100
commit7696d36b4ed595bf9681fd379d1dcbaf30c1ef0a (patch)
treefd92ee1a15187ef9709a3c64cf5f0de4f6a1f111 /llvm/lib/Transforms/Utils/Local.cpp
parentc4c9d4f306732c854fa88d2f30c1a22bb025d0c9 (diff)
downloadllvm-7696d36b4ed595bf9681fd379d1dcbaf30c1ef0a.zip
llvm-7696d36b4ed595bf9681fd379d1dcbaf30c1ef0a.tar.gz
llvm-7696d36b4ed595bf9681fd379d1dcbaf30c1ef0a.tar.bz2
[Transforms] Debug values are not remapped when cloning. (#87747)
When cloning instructions from one basic block to another, the debug values are not remapped, in the same was as the normal instructions.
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 5f45609..f3cd310 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -3685,6 +3685,30 @@ DIExpression *llvm::getExpressionForConstant(DIBuilder &DIB, const Constant &C,
return nullptr;
}
+void llvm::remapDebugVariable(ValueToValueMapTy &Mapping, Instruction *Inst) {
+ auto RemapDebugOperands = [&Mapping](auto *DV, auto Set) {
+ for (auto *Op : Set) {
+ auto I = Mapping.find(Op);
+ if (I != Mapping.end())
+ DV->replaceVariableLocationOp(Op, I->second, /*AllowEmpty=*/true);
+ }
+ };
+ auto RemapAssignAddress = [&Mapping](auto *DA) {
+ auto I = Mapping.find(DA->getAddress());
+ if (I != Mapping.end())
+ DA->setAddress(I->second);
+ };
+ if (auto DVI = dyn_cast<DbgVariableIntrinsic>(Inst))
+ RemapDebugOperands(DVI, DVI->location_ops());
+ if (auto DAI = dyn_cast<DbgAssignIntrinsic>(Inst))
+ RemapAssignAddress(DAI);
+ for (DbgVariableRecord &DVR : filterDbgVars(Inst->getDbgRecordRange())) {
+ RemapDebugOperands(&DVR, DVR.location_ops());
+ if (DVR.isDbgAssign())
+ RemapAssignAddress(&DVR);
+ }
+}
+
namespace {
/// A potential constituent of a bitreverse or bswap expression. See