diff options
author | Zequan Wu <zequanwu@google.com> | 2022-04-28 16:17:12 -0700 |
---|---|---|
committer | Zequan Wu <zequanwu@google.com> | 2022-04-28 16:18:16 -0700 |
commit | 4fe2ab5279408c02eeeb52ee3e6ba7827dde463d (patch) | |
tree | 2bb8e23d2aea28fba829d9ad29e53202e10335ec /llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp | |
parent | bfcb2c1119d902108a861448937bf4babb6951fb (diff) | |
download | llvm-4fe2ab5279408c02eeeb52ee3e6ba7827dde463d.zip llvm-4fe2ab5279408c02eeeb52ee3e6ba7827dde463d.tar.gz llvm-4fe2ab5279408c02eeeb52ee3e6ba7827dde463d.tar.bz2 |
Revert "[DebugInfo][InstrRef] Describe value sizes when spilt to stack"
This reverts commit a15b66e76d1ecff625a4bbb4a46ff83a43138f49.
This causes linker to crash at assertion: `Assertion failed: !Expr->isComplex(), file C:\b\s\w\ir\cache\builder\src\third_party\llvm\llvm\lib\CodeGen\LiveDebugValues\InstrRefBasedImpl.cpp, line 907`.
Diffstat (limited to 'llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp')
-rw-r--r-- | llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp | 69 |
1 files changed, 9 insertions, 60 deletions
diff --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp index d8fc35b..ab1fb3f7 100644 --- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp +++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp @@ -870,70 +870,19 @@ MachineInstrBuilder MLocTracker::emitLoc(Optional<LocIdx> MLoc, // the variable is. if (Offset == 0) { const SpillLoc &Spill = SpillLocs[SpillID.id()]; + Expr = TRI.prependOffsetExpression(Expr, DIExpression::ApplyOffset, + Spill.SpillOffset); unsigned Base = Spill.SpillBase; MIB.addReg(Base); + MIB.addImm(0); - // There are several ways we can dereference things, and several inputs - // to consider: - // * NRVO variables will appear with IsIndirect set, but should have - // nothing else in their DIExpressions, - // * Variables with DW_OP_stack_value in their expr already need an - // explicit dereference of the stack location, - // * Values that don't match the variable size need DW_OP_deref_size, - // * Everything else can just become a simple location expression. - - // We need to use deref_size whenever there's a mismatch between the - // size of value and the size of variable portion being read. - // Additionally, we should use it whenever dealing with stack_value - // fragments, to avoid the consumer having to determine the deref size - // from DW_OP_piece. - bool UseDerefSize = false; - unsigned ValueSizeInBits = getLocSizeInBits(*MLoc); - unsigned DerefSizeInBytes = ValueSizeInBits / 8; - if (auto Fragment = Var.getFragment()) { - unsigned VariableSizeInBits = Fragment->SizeInBits; - if (VariableSizeInBits != ValueSizeInBits || Expr->isComplex()) - UseDerefSize = true; - } else if (auto Size = Var.getVariable()->getSizeInBits()) { - if (*Size != ValueSizeInBits) { - UseDerefSize = true; - } - } - + // Being on the stack makes this location indirect; if it was _already_ + // indirect though, we need to add extra indirection. See this test for + // a scenario where this happens: + // llvm/test/DebugInfo/X86/spill-nontrivial-param.ll if (Properties.Indirect) { - // This is something like an NRVO variable, where the pointer has been - // spilt to the stack. It should end up being a memory location, with - // the pointer to the variable loaded off the stack with a deref: - assert(!Expr->isComplex()); - Expr = TRI.prependOffsetExpression( - Expr, DIExpression::ApplyOffset | DIExpression::DerefAfter, - Spill.SpillOffset); - MIB.addImm(0); - } else if (UseDerefSize) { - // We're loading a value off the stack that's not the same size as the - // variable. Add / subtract stack offset, explicitly deref with a size, - // and add DW_OP_stack_value if not already present. - SmallVector<uint64_t, 2> Ops = {dwarf::DW_OP_deref_size, - DerefSizeInBytes}; - Expr = DIExpression::prependOpcodes(Expr, Ops, true); - unsigned Flags = DIExpression::StackValue | DIExpression::ApplyOffset; - Expr = TRI.prependOffsetExpression(Expr, Flags, Spill.SpillOffset); - MIB.addReg(0); - } else if (Expr->isComplex()) { - // A variable with no size ambiguity, but with extra elements in it's - // expression. Manually dereference the stack location. - assert(Expr->isComplex()); - Expr = TRI.prependOffsetExpression( - Expr, DIExpression::ApplyOffset | DIExpression::DerefAfter, - Spill.SpillOffset); - MIB.addReg(0); - } else { - // A plain value that has been spilt to the stack, with no further - // context. Request a location expression, marking the DBG_VALUE as - // IsIndirect. - Expr = TRI.prependOffsetExpression(Expr, DIExpression::ApplyOffset, - Spill.SpillOffset); - MIB.addImm(0); + std::vector<uint64_t> Elts = {dwarf::DW_OP_deref}; + Expr = DIExpression::append(Expr, Elts); } } else { // This is a stack location with a weird subregister offset: emit an undef |