[llvm-bugs] [Bug 35197] New: [LTO] undefined reference to global variable that was used only in asm
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Nov 3 12:30:26 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=35197
Bug ID: 35197
Summary: [LTO] undefined reference to global variable that was
used only in asm
Product: new-bugs
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: ilia.taraban at intel.com
CC: llvm-bugs at lists.llvm.org
This test fails at linkage with "undefined reference" with LTO:
================= nice.c ==============
int f[2];
int
main()
{
__asm {
mov f[rax], rax
}
return 0;
}
=======================================
>>> clang -v
clang version 6.0.0 (trunk 317339)
Target: x86_64-unknown-linux-gnu
Thread model: posix
...
>>> clang -c -O0 -fasm-blocks nice.c
>>> clang -O1 nice.o
But fails with -flto
>>> clang -c -O0 -fasm-blocks nice.c -flto
>>> clang -O1 -flto nice.o
/tmp/lto-llvm-61977c.o:ld-temp.o:function main: error: undefined reference to
'f'
clang-6.0: error: linker command failed with exit code 1 (use -v to see
invocation)
>>> clang -O1 -flto nice.o -Wl,-plugin-opt,-opt-bisect-limit=1
BISECT: running pass (1) Dead Global Elimination on module (ld-temp.o)
...
BISECT: NOT running pass (46) X86 LEA Fixup on function (main)
/tmp/lto-llvm-7d6d61.o:ld-temp.o:function main: error: undefined reference to
'f'
clang-6.0: error: linker command failed with exit code 1 (use -v to see
invocation)
If we look at nice.o, we'll see that we still have variable 'f' before linkage
stage:
================= nice.o.ll ===========
@f = common global [2 x i32] zeroinitializer, align 4
; Function Attrs: noinline nounwind optnone uwtable
define i32 @main() #0 {
entry:
%retval = alloca i32, align 4
store i32 0, i32* %retval, align 4
call void asm sideeffect inteldialect "mov f[rax], rax",
"~{dirflag},~{fpsr},~{flags}"() #1, !srcloc !2
ret i32 0
}
=======================================
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171103/4c806368/attachment.html>
More information about the llvm-bugs
mailing list