[clang] [llvm] [clang][LTO] Emit symbols for global inline assembly as module flags (PR #174995)

Andrew Savonichev via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 29 06:24:05 PST 2026


asavonic wrote:

I'm not sure what is supposed to happen when we have duplicated symbols in LTO. `llvm-lto` gives `symbol 'bar' is already defined` error, so it is not supported.

`llvm-lto2` allows for "non-prevaling" symbols. For such symbols it injects `.lto_discard bar` to make AsmParser skip the corresponding label:
```
module asm ".lto_discard bar"
module asm ".text"
module asm ".balign 16"
module asm ".globl bar"          <--
module asm "bar:"                <-- these lines are ignored because of .lto_discard 
module asm "pacib     x30, x27"
module asm "retab"
module asm ".previous"
```

`global-asm-symbols` must stay consistent with the resulting assembly, so we must exclude discarded symbols. This can be done using `AppendUnique` module flag behavior, or by changing the flag in LTO.

I don't know how this is supposed to work for symvers though. If a symver is duplicated, it appears in `.lto_discard` like a regular symbol, but AsmParser cannot parse this syntax:
```
<inline asm>:1:22: unexpected token
.lto_discard bar, bar at VER
```
I'll run some more tests and figure out what we can do here.

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


More information about the llvm-commits mailing list