[PATCH] D124937: [ThreadSanitizer] Add fallback DebugLocation for instrumentation calls

Marco Elver via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 4 09:36:55 PDT 2022


melver created this revision.
melver added reviewers: dvyukov, nickdesaulniers.
Herald added a subscriber: hiraditya.
Herald added a project: All.
melver requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.

This is problematic for inserted calls, where the enclosing function has
debug info but the call ends up without a DebugLocation in e.g. LTO
builds that verify that both the enclosing function and calls to
inlinable functions have debug info attached.

This issue was noticed in Linux kernel KCSAN builds with LTO and debug
info enabled:

  | ...
  | inlinable function call in a function with debug info must have a !dbg location
  |   call void @__tsan_read8(i8* %432)
  | ...

To fix, ensure that all calls to the runtime have a DebugLocation
attached, where the possibility exists that the insertion-point might
not have any DebugLocation attached to it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124937

Files:
  llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
  llvm/test/Instrumentation/ThreadSanitizer/missing_dbg.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124937.427042.patch
Type: text/x-patch
Size: 6843 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220504/c448c312/attachment.bin>


More information about the llvm-commits mailing list