| Issue |
181310
|
| Summary |
Bug: x86-64 inline assembly fails with "symbol is already defined" for local labels under optimization (-O1+)
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
ammarfaizi2
|
Ammar Faizi - 2026-02-13
## **Summary**
When compiling x86-64 inline assembly that contains explicitly named
local labels (e.g., `.Lcoro_resume_task_ret_addr`), Clang throws a
"symbol is already defined" error if optimizations (`-O1`, `-O2`, `-O3`)
are enabled. The exact same code compiles successfully at `-O0` in Clang,
and works perfectly across all optimization levels in GCC.
## **Steps to Reproduce**
1. Take the source code from this Gist: https://gist.github.com/ammarfaizi2/9072d28a270218567fe4ae9ab4166f0b
2. Compile the source using Clang with optimization enabled:
`clang -O1` (or `-O2`, `-O3`)
## **Expected Behavior**
The code should compile successfully without throwing duplicate symbol
errors, mirroring the behavior of `clang -O0` and `gcc -O[0-3]`.
## **Actual Behavior**
The compilation fails during the assembly phase because the optimizer
emits the same local labels multiple times.
**Error Output:**
```sh
<source>:367:3: error: symbol '.Lcoro_resume_task_ret_addr' is already defined
367 | ".Lcoro_resume_task_ret_addr:\n\t"
| ^
<inline asm>:12:1: note: instantiated into assembly here
12 | .Lcoro_resume_task_ret_addr:
| ^
<source>:315:3: error: symbol '.Lcoro_start_task_ret_addr' is already defined
315 | ".Lcoro_start_task_ret_addr:\n\t"
| ^
<inline asm>:14:1: note: instantiated into assembly here
14 | .Lcoro_start_task_ret_addr:
| ^
2 errors generated.
Compiler returned: 1
```
## **Reproducer Links**
* **Clang (Failing at -O1):** Godbolt Link https://godbolt.org/z/xYdhM3jWj
* **GCC (Succeeding at all levels):** Godbolt Link https://godbolt.org/z/x4GTPvMjM
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs