intel / intel/llvm

[DeviceSanitizer] clang-offload-bundler .tgtsym filter no longer matches per-module sanitizer metadata globals

Open
#22,914 2 comments 0 reactions 1 assignee Assigned to @zhaomaosu View on GitHub
bug
Dominant language
LLVM
Stars
1.5k
Forks
854
Avg merge
3d 17h
Merged PRs (30d)
137

Description

### Describe the bug

`makeTargetSymbolTable()` in `clang/lib/Driver/OffloadBundler.cpp` excludes sanitizer-internal
globals from the `.tgtsym` section using **exact** name comparison:

https://github.com/intel/llvm/blob/sycl/clang/lib/Driver/OffloadBundler.cpp#L755-L761

```cpp
if (SF->isIR() &&
(Name == "llvm.used" || Name == "llvm.compiler.used" ||
Name == "__AsanDeviceGlobalMetadata" ||
Name == "__MsanDeviceGlobalMetadata" ||
Name == "__TsanDeviceGlobalMetadata" ||
Name == "__AsanKernelMetadata" || Name == "__MsanKernelMetadata" ||
Name == "__TsanKernelMetadata"))
continue;
```

This filter was added by #17399 ("Skip adding device sanitizers internal variable to bundler
symbol table") with the stated rationale that these "are sanitizer internal variables, and
should not be bundled to the symbol table."

Commit 0941896bca24 (#22567, "[DeviceSanitizer] Make sanitizer metadata globals per-module
unique") renamed all six of these globals to carry a per-module unique id suffix:

- AddressSanitizer.cpp:1511 — ("__AsanKernelMetadata_" + computeMetadataUniqueId(M)).str()
- AddressSanitizer.cpp:3133 — ("__AsanDeviceGlobalMetadata_" + ...)
- MemorySanitizer.cpp:1314 — ("__MsanKernelMetadata_" + ...)
- MemorySanitizer.cpp:1076 — ("__MsanDeviceGlobalMetadata_" + ...)
- ThreadSanitizer.cpp:727 — ("__TsanKernelMetadata_" + ...)
- ThreadSanitizer.cpp:556 — ("__TsanDeviceGlobalMetadata_" + ...)

#22567 did not update OffloadBundler.cpp, so the exact comparisons no longer match and these
globals are now emitted into .tgtsym, contrary to #17399's intent.

### To reproduce

### Environment

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.