[llvm-bugs] [Bug 34306] New: Odd PC rel for thread local
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Aug 24 03:06:10 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=34306
Bug ID: 34306
Summary: Odd PC rel for thread local
Product: lld
Version: unspecified
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: COFF
Assignee: unassignedbugs at nondot.org
Reporter: ck at remobjects.com
CC: llvm-bugs at lists.llvm.org
With latest llvm/lld on Win32 (link flavor) I get an odd PC rel for thread
local statics:
_GetCurrent:
402000: 55 pushl %ebp
402001: 89 e5 movl %esp, %ebp
402003: e8 00 00 00 00 calll 0 <_GetCurrent+0x8>
402008: 58 popl %eax
402009: 8b 88 00 10 40 00 movl 4198400(%eax), %ecx
40200f: 64 8b 80 2c 00 00 00 movl %fs:44(%eax), %eax
402016: 8b 04 88 movl (%eax,%ecx,4), %eax
402019: 8b 80 00 00 00 00 movl (%eax), %eax
40201f: 5d popl %ebp
402020: c3 retl
notice 402009, which does a movl 4198400 (_tls_index)%eax, %ecx, where %eax is
PC, this crashes here and I'm having trouble seeing how this would ever work
since 4198400 is already the real address.
Steps:
- llvm-as.exe isl.out.ll
- lld.exe -flavor link isl.out.bc /entry:main /debug /opt:lldlto=0 /force
then disassemble it.
(Note that /force is only here for testcase purposes, it fails in a full
project without /force too)
Code:
; ModuleID = 'isl.out'
source_filename = "Island"
target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
target triple = "i686-pc-windows-msvc"
module asm ".globl _tls_array\0D"
module asm "_tls_array = 44\0D"
module asm ".globl __tls_array\0D"
module asm "__tls_array = 44"
@_tls_index = global i32 0
@fCurrent = thread_local global i8* null
define i8* @GetCurrent() #0 {
br label %1
; <label>:1: ; preds = %0
%2 = load i8*, i8** @fCurrent
ret i8* %2
}
declare void @DoSomething(i8*)
define void @main() {
%1 = call i8* @GetCurrent()
call void @DoSomething(i8* %1)
ret void
}
attributes #0 = { "no-frame-pointer-elim"="true"
"no-frame-pointer-elim-non-leaf" }
--
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/20170824/d4665851/attachment.html>
More information about the llvm-bugs
mailing list