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

Andrew Savonichev via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 28 06:34:00 PST 2026


asavonic wrote:

> How does your PR handle the case of multiple modules in LTO? How do the module flags get merged?

`global-asm-symbols` and `global-asm-symvers` module flags are emitted with [`Append`](https://github.com/llvm/llvm-project/blob/6074f9b6246686e61e48d9e3aafc1c2069f93e5a/llvm/include/llvm/IR/Module.h#L141) behavior. When modules are linked, we have a joined list of symbols from both modules. Global inline assembly lines are concatenated.

Let's take `LTO/AArch64/global-inline-asm-flags.ll` test as an example:

- The first module defines symbols for `baz`, `baz at VER` and `foo at LINKEDVER`:
```
!0 = !{i32 5, !"global-asm-symbols", !1}
!1 = !{!2, !3, !4}
!2 = !{!"baz", i32 2050}
!3 = !{!"baz at VER", i32 2050}
!4 = !{!"foo at LINKEDVER", i32 2050}
```

- The second module from `Inputs/` directory defines `bar`, `bar at VER`, `foo at ANOTHERVER`, `foo`, `foo at VER`.
```
!1 = !{i32 5, !"global-asm-symbols", !2}
!2 = !{!3, !4, !5, !6, !7}
!3 = !{!"bar", i32 2050}
!4 = !{!"bar at VER", i32 2050}
!5 = !{!"foo at ANOTHERVER", i32 2050}
!6 = !{!"foo", i32 2050}
!7 = !{!"foo at VER", i32 2050}
```

- When these modules are linked, the resulting module contains all these symbols:
```
!0 = distinct !{i32 5, !"global-asm-symbols", !1}
!1 = distinct !{!2, !3, !4, !5, !6, !7, !8, !9}
!2 = !{!"baz", i32 2050}
!3 = !{!"baz at VER", i32 2050}
!4 = !{!"foo at LINKEDVER", i32 2050}
!5 = !{!"bar", i32 2050}
!6 = !{!"bar at VER", i32 2050}
!7 = !{!"foo at ANOTHERVER", i32 2050}
!8 = !{!"foo", i32 2050}
!9 = !{!"foo at VER", i32 2050}
```
Same happens for `global-asm-symvers`, but list elements are lists instead of pairs.

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


More information about the cfe-commits mailing list