aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/IntrinsicInst.cpp
diff options
context:
space:
mode:
authorgbtozers <stephen.tozer@sony.com>2020-09-30 19:15:44 +0100
committerStephen Tozer <Stephen.Tozer@Sony.com>2021-03-11 13:33:49 +0000
commitc0f3dfb9f119bb5f22dd8846f5502b6abaf026d3 (patch)
tree2cc0da19c4c2e97515466cbdf9273105603d4c87 /llvm/lib/IR/IntrinsicInst.cpp
parentea834c8365ca7c4f0b491f5de98c521df9401ea9 (diff)
downloadllvm-c0f3dfb9f119bb5f22dd8846f5502b6abaf026d3.zip
llvm-c0f3dfb9f119bb5f22dd8846f5502b6abaf026d3.tar.gz
llvm-c0f3dfb9f119bb5f22dd8846f5502b6abaf026d3.tar.bz2
[DebugInfo] Use variadic debug values to salvage BinOps and GEP instrs with non-const operands
This patch improves salvageDebugInfoImpl by allowing it to salvage arithmetic operations with two or more non-const operands; this includes the GetElementPtr instruction, and most Binary Operator instructions. These salvages produce DIArgList locations and are only valid for dbg.values, as currently variadic DIExpressions must use DW_OP_stack_value. This functionality is also only added for salvageDebugInfoForDbgValues; other functions that directly call salvageDebugInfoImpl (such as in ISel or Coroutine frame building) can be updated in a later patch. Differential Revision: https://reviews.llvm.org/D91722
Diffstat (limited to 'llvm/lib/IR/IntrinsicInst.cpp')
-rw-r--r--llvm/lib/IR/IntrinsicInst.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/IR/IntrinsicInst.cpp b/llvm/lib/IR/IntrinsicInst.cpp
index 55bc314..adac693 100644
--- a/llvm/lib/IR/IntrinsicInst.cpp
+++ b/llvm/lib/IR/IntrinsicInst.cpp
@@ -117,6 +117,23 @@ void DbgVariableIntrinsic::replaceVariableLocationOp(unsigned OpIdx,
0, MetadataAsValue::get(getContext(), DIArgList::get(getContext(), MDs)));
}
+void DbgVariableIntrinsic::addVariableLocationOps(ArrayRef<Value *> NewValues,
+ DIExpression *NewExpr) {
+ assert(NewExpr->hasAllLocationOps(getNumVariableLocationOps() +
+ NewValues.size()) &&
+ "NewExpr for debug variable intrinsic does not reference every "
+ "location operand.");
+ assert(!is_contained(NewValues, nullptr) && "New values must be non-null");
+ setArgOperand(2, MetadataAsValue::get(getContext(), NewExpr));
+ SmallVector<ValueAsMetadata *, 4> MDs;
+ for (auto *VMD : location_ops())
+ MDs.push_back(getAsMetadata(VMD));
+ for (auto *VMD : NewValues)
+ MDs.push_back(getAsMetadata(VMD));
+ setArgOperand(
+ 0, MetadataAsValue::get(getContext(), DIArgList::get(getContext(), MDs)));
+}
+
Optional<uint64_t> DbgVariableIntrinsic::getFragmentSizeInBits() const {
if (auto Fragment = getExpression()->getFragmentInfo())
return Fragment->SizeInBits;