https://llvm.org/bugs/show_bug.cgi?id=26389
Bug ID: 26389 Summary: [x86-64] clang generate wrong instruction for cygwin Product: clang Version: 3.8 Hardware: PC OS: All Status: NEW Severity: normal Priority: P Component: LLVM Codegen Assignee: unassignedclangb...@nondot.org Reporter: swig...@gmail.com CC: llvm-bugs@lists.llvm.org Classification: Unclassified when access data that may be far away (than 4G) on x86-64, clang generate a wrong instruction cause program fail to run (Segment fault). sample code: test.cpp: [code] struct OSTREAM { char buf[100]; } ; extern OSTREAM cout; extern void show(void*); int main() { show(&cout); } [/code] command: clang -target x86_64-pc-cygwin -S -o - ext.cpp output: [code] .text .def main; .scl 2; .type 32; .endef .globl main .align 16, 0x90 main: # @main .Ltmp0: .seh_proc main # BB#0: pushq %rbp .Ltmp1: .seh_pushreg 5 subq $32, %rsp .Ltmp2: .seh_stackalloc 32 leaq 32(%rsp), %rbp .Ltmp3: .seh_setframe 5, 32 .Ltmp4: .seh_endprologue callq __main leaq cout(%rip), %rcx <=============== WRONG!! callq _Z4showPv xorl %eax, %eax addq $32, %rsp popq %rbp retq .seh_handlerdata .text .Ltmp5: .seh_endproc [/code] look at the leaq instruction, when cout is far than 4G away, this will take an invalid address and then cause a segment fault. If target is x86_64-pc-linux-gnu, the generated instruction is movabsq that works. This is a reduced test case. I can show it on clang 3.8 on ubuntu. the orignal case is that I found clang compiled program failed to run cout<<"hello"<<endl on 64 bits msys2 on windows7 x64. $ clang --version Ubuntu clang version 3.8.0-svn257311-1~exp1 (trunk) (based on LLVM 3.8.0) Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/lib/llvm-3.8/bin -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs