This fixes a false positive ODR violation that is reported by ASan when using LTO. In cases, where two constant globals have the same value, LTO will merge them, which breaks ASan's ODR detection. See the included testcase for an example.
Details
Details
- Reviewers
george.karpenkov steven_wu kcc eugenis filcab fjricci dvyukov - Commits
- rGe70e5fcc7eb0: [asan] Fix a false positive ODR violation due to LTO ConstantMerge pass…
rG8842da8e0708: [asan] Fix a false positive ODR violation due to LTO ConstantMerge pass [llvm…
rG584bd1080364: [asan] Fix a false positive ODR violation due to LTO ConstantMerge pass [llvm…
rG653f94df5365: [asan] Fix a false positive ODR violation due to LTO ConstantMerge pass…
rG0e06d37dba6e: [asan] Fix a false positive ODR violation due to LTO ConstantMerge pass [llvm…
rCRT327062: [asan] Fix a false positive ODR violation due to LTO ConstantMerge pass…
rL327062: [asan] Fix a false positive ODR violation due to LTO ConstantMerge pass…
rL327061: [asan] Fix a false positive ODR violation due to LTO ConstantMerge pass [llvm…
rL327053: [asan] Fix a false positive ODR violation due to LTO ConstantMerge pass [llvm…
rCRT327031: [asan] Fix a false positive ODR violation due to LTO ConstantMerge pass…
rL327031: [asan] Fix a false positive ODR violation due to LTO ConstantMerge pass…
rL327029: [asan] Fix a false positive ODR violation due to LTO ConstantMerge pass [llvm…
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
Comment Actions
LGTM.
The idea is to prevent LTO (ConstMerge pass) from merging global constants that has the same value, which has the same side-effect as linker merging two weak symbols that has ODR violation.
To be extra safe, there are some linkers that are capable of dedup functions and globals. Maybe a separate investigation to see if there is any linker dedup optimization can break this? Currently, ld64 doesn't dedup none weak symbols so it should be fine for now. Maybe check if lld does that?
Comment Actions
Thanks, yes, AFAIK, ld64 is fine and I don't really know how to test lld on Darwin (is it even supposed to work?).