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)
commit8000e2734ec5f45c9c56a54b8a1b19375572ec4e
tree9016f5ee5900219f0135533622a842bad537779f
parent7ea91b2892c6ce88c8df6be46e198ff271a03705
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).

llvm-svn: 210492
llvm/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp
llvm/test/DebugInfo/AArch64/struct_by_value.ll
llvm/test/DebugInfo/X86/debug-loc-asan.ll [new file with mode: 0644]
llvm/test/DebugInfo/X86/debug-loc-offset.ll
llvm/test/DebugInfo/X86/pr19307.ll [new file with mode: 0644]