https://bugs.llvm.org/show_bug.cgi?id=51308

            Bug ID: 51308
           Summary: invalid symbol redefinition when -O2 enabled
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]

Following code can be successfully compiled by O0 optimization on, but not O2.

Example code:
---
#include <stdio.h>

int func() {
    int filter;
    asm volatile(
        "  leaq _filter(%%rip), %%rax\n"
        "  jmp _out\n"
        "_filter:\n"
        ".ascii \"\\040\"\n"
        "_out:"
        : "=rax"(filter)
        :
        :);
    return filter;
}
int main() {
    printf("%#x", func());
    return 0;
}
---

Error message:
---
<source>:8:10: error: symbol '_filter' is already defined
        "_filter:\n"
         ^
<inline asm>:3:1: note: instantiated into assembly here
_filter:
^
<source>:10:10: error: symbol '_out' is already defined
        "_out:"
         ^
<inline asm>:5:1: note: instantiated into assembly here
_out:
^
2 errors generated.
ASM generation compiler returned: 1
<source>:8:10: error: symbol '_filter' is already defined
        "_filter:\n"
         ^
<inline asm>:3:1: note: instantiated into assembly here
_filter:
^
<source>:10:10: error: symbol '_out' is already defined
        "_out:"
         ^
<inline asm>:5:1: note: instantiated into assembly here
_out:
^
2 errors generated.
Execution build compiler returned: 1
---

It affects 11.0, 12.0, and trunk.

Trunk O0: https://godbolt.org/z/7afYjhGzc
Trunk O2: https://godbolt.org/z/6K71Tde6s

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to