]> granicus.if.org Git - llvm/commit
[SafeStack] Insert the deref after the offset
authorPetr Hosek <phosek@chromium.org>
Mon, 22 Jul 2019 18:52:42 +0000 (18:52 +0000)
committerPetr Hosek <phosek@chromium.org>
Mon, 22 Jul 2019 18:52:42 +0000 (18:52 +0000)
commit59c1bff047d08ac8755266dcaba79f397e8c9946
tree4ad160625fecc7957473e25a0e963df19478bd5e
parentb1a4ef46fe5daeb9837642187a527b821b37feea
[SafeStack] Insert the deref after the offset

While debugging code that uses SafeStack, we've noticed that LLVM
produces an invalid DWARF. Concretely, in the following example:

  int main(int argc, char* argv[]) {
    std::string value = "";
    printf("%s\n", value.c_str());
    return 0;
  }

DWARF would describe the value variable as being located at:

  DW_OP_breg14 R14+0, DW_OP_deref, DW_OP_constu 0x20, DW_OP_minus

The assembly to get this variable is:

  leaq    -32(%r14), %rbx

The order of operations in the DWARF symbols is incorrect in this case.
Specifically, the deref is incorrect; this appears to be incorrectly
re-inserted in repalceOneDbgValueForAlloca.

With this change which inserts the deref after the offset instead of
before it, LLVM produces correct DWARF:

  DW_OP_breg14 R14-32

Differential Revision: https://reviews.llvm.org/D64971

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366726 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Utils/Local.cpp
test/Transforms/SafeStack/X86/debug-loc2.ll