diff options
author | Djordje Todorovic <djordje.todorovic@rt-rk.com> | 2019-09-27 13:52:43 +0000 |
---|---|---|
committer | Djordje Todorovic <djordje.todorovic@rt-rk.com> | 2019-09-27 13:52:43 +0000 |
commit | eb4c98ca3d2590bad9f6542afbf3a7824d2b53fa (patch) | |
tree | ea2bdd9a12f6fa7e46e7c2124a1b720096d9f36d /llvm/lib/CodeGen | |
parent | 2319eb65473ecdab00381d696ae2e0b4564b60a8 (diff) | |
download | bcm5719-llvm-eb4c98ca3d2590bad9f6542afbf3a7824d2b53fa.tar.gz bcm5719-llvm-eb4c98ca3d2590bad9f6542afbf3a7824d2b53fa.zip |
[DebugInfo] Exclude memory location values as parameter entry values
Abandon describing of loaded values due to safety concerns. Loaded
values are described as derefed memory location at caller point.
At callee we can unintentionally change that memory location which
would lead to different entry being printed value before and after
the memory location clobbering. This problem is described in
llvm.org/PR43343.
Patch by Nikola Prica
Differential Revision: https://reviews.llvm.org/D67717
llvm-svn: 373089
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp | 7 | ||||
-rw-r--r-- | llvm/lib/CodeGen/TargetInstrInfo.cpp | 12 |
2 files changed, 5 insertions, 14 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp index 52e5109dbf9..ea42e60344d 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp @@ -246,8 +246,8 @@ bool DwarfExpression::addMachineRegExpression(const TargetRegisterInfo &TRI, // a call site parameter expression and if that expression is just a register // location, emit it with addBReg and offset 0, because we should emit a DWARF // expression representing a value, rather than a location. - if (!isMemoryLocation() && !HasComplexExpression && (!isParameterValue() || - isEntryValue())) { + if (!isMemoryLocation() && !HasComplexExpression && + (!isParameterValue() || isEntryValue())) { for (auto &Reg : DwarfRegs) { if (Reg.DwarfRegNo >= 0) addReg(Reg.DwarfRegNo, Reg.Comment); @@ -413,6 +413,9 @@ void DwarfExpression::addExpression(DIExpressionCursor &&ExprCursor, break; case dwarf::DW_OP_deref: assert(!isRegisterLocation()); + // For more detailed explanation see llvm.org/PR43343. + assert(!isParameterValue() && "Parameter entry values should not be " + "dereferenced due to safety reasons."); if (!isMemoryLocation() && ::isMemoryLocation(ExprCursor)) // Turning this into a memory location description makes the deref // implicit. diff --git a/llvm/lib/CodeGen/TargetInstrInfo.cpp b/llvm/lib/CodeGen/TargetInstrInfo.cpp index 0e9eb77ea26..2108fc6fecf 100644 --- a/llvm/lib/CodeGen/TargetInstrInfo.cpp +++ b/llvm/lib/CodeGen/TargetInstrInfo.cpp @@ -1133,18 +1133,6 @@ TargetInstrInfo::describeLoadedValue(const MachineInstr &MI) const { } else if (MI.isMoveImmediate()) { Op = &MI.getOperand(1); return ParamLoadedValue(*Op, Expr); - } else if (MI.hasOneMemOperand()) { - int64_t Offset; - const auto &TRI = MF->getSubtarget().getRegisterInfo(); - const auto &TII = MF->getSubtarget().getInstrInfo(); - const MachineOperand *BaseOp; - - if (!TII->getMemOperandWithOffset(MI, BaseOp, Offset, TRI)) - return None; - - Expr = DIExpression::prepend(Expr, DIExpression::DerefAfter, Offset); - Op = BaseOp; - return ParamLoadedValue(*Op, Expr); } return None; |