This is an archive of the discontinued LLVM Phabricator instance.

[ThreadSanitizer] Add fallback DebugLocation for instrumentation calls
ClosedPublic

Authored by melver on May 4 2022, 9:36 AM.

Details

Summary

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.

Diff Detail

Event Timeline

melver created this revision.May 4 2022, 9:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 4 2022, 9:36 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
melver requested review of this revision.May 4 2022, 9:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 4 2022, 9:36 AM
nickdesaulniers accepted this revision.May 4 2022, 2:23 PM
nickdesaulniers added inline comments.
llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
197

plz don't use auto here.

This revision is now accepted and ready to land.May 4 2022, 2:23 PM
melver updated this revision to Diff 427295.May 5 2022, 6:14 AM
melver marked an inline comment as done.

Don't use auto.

This revision was landed with ongoing or failed builds.May 5 2022, 6:50 AM
This revision was automatically updated to reflect the committed changes.