[LLVMdev] LLC Bug x86 with thread local storage

Patrick Marlier patrick.marlier at unine.ch
Wed Jul 7 04:52:13 PDT 2010


On 06/22/2010 11:11 AM, Patrick Marlier wrote:
 > On 06/21/2010 08:21 PM, Eric Christopher wrote:
 >> On Jun 21, 2010, at 2:56 AM, Patrick Marlier wrote:
 >>
 >>
 >>> Hello,
 >>>
 >>> This bug affects all LLVM versions from 2.6 to trunk :
 >>> http://llvm.org/bugs/show_bug.cgi?id=5081
 >>>
 >>> The workaround I found is to add this :
 >>>
 >>> Index: lib/Target/X86/X86Instr64bit.td
 >>> ===================================================================
 >>> --- lib/Target/X86/X86Instr64bit.td     (revision 105882)
 >>> +++ lib/Target/X86/X86Instr64bit.td     (working copy)
 >>> @@ -1832,6 +1832,8 @@
 >>>              (MOV64ri64i32 tjumptable  :$dst)>, Requires<[SmallCode]>;
 >>>    def : Pat<(i64 (X86Wrapper tglobaladdr :$dst)),
 >>>              (MOV64ri64i32 tglobaladdr :$dst)>, Requires<[SmallCode]>;
 >>> +def : Pat<(i64 (X86Wrapper tglobaltlsaddr :$dst)),
 >>> +          (MOV64ri32 tglobaltlsaddr :$dst)>, Requires<[SmallCode]>;
 >>>    def : Pat<(i64 (X86Wrapper texternalsym:$dst)),
 >>>              (MOV64ri64i32 texternalsym:$dst)>, Requires<[SmallCode]>;
 >>>    def : Pat<(i64 (X86Wrapper tblockaddress:$dst)),
 >>>
 >>> Unfortunately, I am 100% confident with this modification since I 
am not an expert of LLVM and I doubt a bit about the conversion for 32 
bit to 64bit.
 >>>
 >>> If someone could approve it or help me with this bug it will be 
wonderful.
 >>>
 >> I think it just needs support in all of those cases for the tls 
immediate type (for example your test would have still failed in kernel 
mode).  I've gone ahead and added that in r106433 and it passes the 
testcase in a few different codegen modes, but don't have any way of 
testing on linux at the moment so if you can test the codegen that would 
be appreciated.
 >>
 >> Thanks!
 >>
 >> -eric
 > Actually, now llc works with the testcase but the generated code is
 > wrong if you try to compile it with "as".
 >
 > $ as select.s
 > select.s: Assembler messages:
 > select.s:8: Error: relocated field and relocation type differ in 
signedness
 >
 > select.s
 > 8:        movl    $tm_nest_level at TPOFF, %ecx
 > 9:        movq    %fs:0, %rax

Which one is correct ?
- movl    $tm_nest_level at TPOFF, %ecx
or
- movq    $tm_nest_level at TPOFF, %rcx
or
- movl    tm_nest_level at TPOFF, %ecx

Otherwise, Is there a way to remove this $ character?

I found that it is here in lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp

void X86ATTInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
                                      raw_ostream &O) {
   const MCOperand &Op = MI->getOperand(OpNo);
   if (Op.isReg()) {
     O << '%' << getRegisterName(Op.getReg());
   } else if (Op.isImm()) {
     ...
   } else {
     assert(Op.isExpr() && "unknown operand kind in printOperand");
// HERE I remove the '$' to make it work
     O << '$' << *Op.getExpr();
   }

I hope someone is good in this thing!

Thank you for your help,

Patrick Marlier.




More information about the llvm-dev mailing list