[Local] Do not move around dbg.declares during replaceDbgDeclare
authorVedant Kumar <vsk@apple.com>
Mon, 10 Feb 2020 23:37:56 +0000 (15:37 -0800)
committerVedant Kumar <vsk@apple.com>
Thu, 13 Feb 2020 22:35:02 +0000 (14:35 -0800)
commit8e77b33b3c67aa8f2580671b019eeb3862651ecb
treeebfe79d45c64878c7aa696f5fa6c69c61b813c7b
parent19b62b79db1bb154b40e8baba9a28ab8aa935b6b
[Local] Do not move around dbg.declares during replaceDbgDeclare

replaceDbgDeclare is used to update the descriptions of stack variables
when they are moved (e.g. by ASan or SafeStack). A side effect of
replaceDbgDeclare is that it moves dbg.declares around in the
instruction stream (typically by hoisting them into the entry block).
This behavior was introduced in llvm/r227544 to fix an assertion failure
(llvm.org/PR22386), but no longer appears to be necessary.

Hoisting a dbg.declare generally does not create problems. Usually,
dbg.declare either describes an argument or an alloca in the entry
block, and backends have special handling to emit locations for these.
In optimized builds, LowerDbgDeclare places dbg.values in the right
spots regardless of where the dbg.declare is. And no one uses
replaceDbgDeclare to handle things like VLAs.

However, there doesn't seem to be a positive case for moving
dbg.declares around anymore, and this reordering can get in the way of
understanding other bugs. I propose getting rid of it.

Testing: stage2 RelWithDebInfo sanitized build, check-llvm

rdar://59397340

Differential Revision: https://reviews.llvm.org/D74517
llvm/include/llvm/Transforms/Utils/Local.h
llvm/lib/CodeGen/SafeStack.cpp
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/lib/Transforms/Utils/Local.cpp
llvm/test/Instrumentation/AddressSanitizer/debug_info.ll
llvm/test/Instrumentation/AddressSanitizer/local_stack_base.ll
llvm/test/Transforms/Inline/alloca-dbgdeclare-merge.ll
llvm/test/Transforms/Inline/alloca-dbgdeclare.ll
llvm/test/Transforms/Inline/inline_dbg_declare.ll
llvm/unittests/Transforms/Utils/LocalTest.cpp