Generate better location ranges for some register-described variables.
authorAlexey Samsonov <vonosmas@gmail.com>
Mon, 9 Jun 2014 21:53:47 +0000 (21:53 +0000)
committerAlexey Samsonov <vonosmas@gmail.com>
Mon, 9 Jun 2014 21:53:47 +0000 (21:53 +0000)
commitf4a702c079674120bbc95c3474602334274c6046
tree0d3a5da1a336cd2e80bc91c35616e8937e180717
parented7d283ce5d205309dd0adf35496c5ecd29d70c5
Generate better location ranges for some register-described variables.

Don't terminate location ranges for register-described variables
at the end of machine basic block if this register is never modified
in the function body, except for the prologue and epilogue. Prologue
location is guessed by FrameSetup flags on MachineInstructions, while
epilogue location is deduced from debug locations of instructions
in the basic blocks ending with return instructions.

This patch is mostly targeted to fix non-trivial debug locations for
variables addressed via stack and frame pointers.

It is not really a generic fix. We can still produce poor debug info
for register-described variables if this register *is* modified somewhere
in the function, but in unrelated places. This might be the case for the debug
info in optimized binaries (e.g. for local variables in inlined functions).
LiveDebugVariables pass in CodeGen attempts to fix this problem by adjusting
DBG_VALUE instructions, but this pass is tied to greedy register allocator,
which is used in optimized builds only. Proper fix would likely involve
generalizing LiveDebugVariables to all register allocators. See more discussion
in http://reviews.llvm.org/D3933 review thread.

I'm proceeding with this patch to fix immediate severe problems and
important cases, e.g. fix completely broken debug info with AddressSanitizer
and fix PR19307 (missing debug info for by-value std::string arguments).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210492 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp
test/DebugInfo/AArch64/struct_by_value.ll
test/DebugInfo/X86/debug-loc-asan.ll [new file with mode: 0644]
test/DebugInfo/X86/debug-loc-offset.ll
test/DebugInfo/X86/pr19307.ll [new file with mode: 0644]