[llvm] [Linker] Do not keep a private member of a non-prevailing comdat group (PR #69143)

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 26 14:54:11 PDT 2023


rnk wrote:

Won't your change do the wrong thing for cases like this? https://gcc.godbolt.org/z/qYfbEY1Ee
``` 
static int arr[32];
int *useit() { return &arr[0]; }
```
Compile with: `-O2 -emit-llvm --target=x86_64-windows-msvc -fsanitize=address`

Relevant IR output:
```
$arr = comdat nodeduplicate
@arr = internal global { [32 x i32], [32 x i8] } zeroinitializer, comdat, align 32
...
@__asan_global_arr = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint (ptr @arr to i64), i64 128, i64 160, i64 ptrtoint (ptr @___asan_gen_.1 to i64), i64 ptrtoint (ptr @___asan_gen_ to i64), i64 0, i64 0, i64 -1 }, section ".ASAN$GL", comdat($arr), align 64
```

Alright, so I've convinced myself that this works today because ASan uses the `nodeduplicate` type here, which gives us the "both" selection kind, and we get the desired semantics.

https://github.com/llvm/llvm-project/pull/69143


More information about the llvm-commits mailing list