diff options
author | OCHyams <orlando.hyams@sony.com> | 2023-03-16 08:46:02 +0000 |
---|---|---|
committer | OCHyams <orlando.hyams@sony.com> | 2023-03-16 09:55:14 +0000 |
commit | af9e52208d76fa9ddcf68564ab5371f6434c62e5 (patch) | |
tree | dd1cfc3660af13bb41d76578280e5cdb3753f00e /llvm/lib/IR/IntrinsicInst.cpp | |
parent | d4320cb2a5ef1680e519fa6b7cfd3a2f88cfed16 (diff) | |
download | llvm-af9e52208d76fa9ddcf68564ab5371f6434c62e5.zip llvm-af9e52208d76fa9ddcf68564ab5371f6434c62e5.tar.gz llvm-af9e52208d76fa9ddcf68564ab5371f6434c62e5.tar.bz2 |
[DebugInfo][NFC] Add RawLocationWrapper to wrap location operand metadata [1/x]
RawLocationWrapper wraps the location operand of a debug intrinsic which may be
either (wrapped in MetadataAsValue) a DIArgList, ValueAsMetadata, or an empty
MDTuple. This class lets us avoid duplicating location handling code in a later
patch in this stack.
Reviewed By: StephenTozer
Differential Revision: https://reviews.llvm.org/D145909
Diffstat (limited to 'llvm/lib/IR/IntrinsicInst.cpp')
-rw-r--r-- | llvm/lib/IR/IntrinsicInst.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/llvm/lib/IR/IntrinsicInst.cpp b/llvm/lib/IR/IntrinsicInst.cpp index 0bafa5f..e120491 100644 --- a/llvm/lib/IR/IntrinsicInst.cpp +++ b/llvm/lib/IR/IntrinsicInst.cpp @@ -71,11 +71,9 @@ bool IntrinsicInst::mayLowerToFunctionCall(Intrinsic::ID IID) { /// intrinsics for variables. /// -iterator_range<DbgVariableIntrinsic::location_op_iterator> -DbgVariableIntrinsic::location_ops() const { - auto *MD = getRawLocation(); +iterator_range<location_op_iterator> RawLocationWrapper::location_ops() const { + Metadata *MD = getRawLocation(); assert(MD && "First operand of DbgVariableIntrinsic should be non-null."); - // If operand is ValueAsMetadata, return a range over just that operand. if (auto *VAM = dyn_cast<ValueAsMetadata>(MD)) { return {location_op_iterator(VAM), location_op_iterator(VAM + 1)}; @@ -89,8 +87,17 @@ DbgVariableIntrinsic::location_ops() const { location_op_iterator(static_cast<ValueAsMetadata *>(nullptr))}; } +iterator_range<location_op_iterator> +DbgVariableIntrinsic::location_ops() const { + return getWrappedLocation().location_ops(); +} + Value *DbgVariableIntrinsic::getVariableLocationOp(unsigned OpIdx) const { - auto *MD = getRawLocation(); + return getWrappedLocation().getVariableLocationOp(OpIdx); +} + +Value *RawLocationWrapper::getVariableLocationOp(unsigned OpIdx) const { + Metadata *MD = getRawLocation(); assert(MD && "First operand of DbgVariableIntrinsic should be non-null."); if (auto *AL = dyn_cast<DIArgList>(MD)) return AL->getArgs()[OpIdx]->getValue(); |