[ThreadSanitizer] Add fallback DebugLocation for memintrinsic calls
authorMarco Elver <elver@google.com>
Mon, 17 Jul 2023 14:58:23 +0000 (16:58 +0200)
committerMarco Elver <elver@google.com>
Mon, 17 Jul 2023 15:52:16 +0000 (17:52 +0200)
commit4eef2e30d6f89328a16d4f1d6b37f1c79afe850c
tree1a173fd9a554a5bca7264e4b24a2893f79964a84
parent913f7e93dac67ecff47bade862ba42f27cb68ca9
[ThreadSanitizer] Add fallback DebugLocation for memintrinsic calls

When building with debug info enabled, some load/store instructions do
not have a DebugLocation attached. When using the default IRBuilder, it
attempts to copy the DebugLocation from the insertion-point instruction.
When there's no DebugLocation, no attempt is made to add one.

Add a fallback DebugLocation with the help of InstrumentationIRBuilder for
memintrinsics. In particular, the compiler may optimize load/store without
debug info into memintrinsics, which then are missing debug info as well.
llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
llvm/test/Instrumentation/ThreadSanitizer/missing_dbg.ll