[LLVMdev] [PATCH] Detect Haswell subarchitecture (i.e. using -march=native)

Adam Strzelecki ono at java.pl
Thu Sep 12 14:12:39 PDT 2013

> Anyway, thanks very much for the information. Hopefully that'll let me
> track things down.

Let me know if you need some more information or dumps.

> Would you mind me taking a day or so to investigate what's going on
> here properly? Introducing a volatile to work around a bug in Clang
> itself just seems perverse to me. (And we shouldn't let a CodeGen bug
> dictate how we implement our functions either).

Looking at the assembly there's something wrong with SI that is not getting saved anywhere after CPUID and 0x20 bit test before it gets overwritten by LEA.

 332:	mov    eax,0x7
 337:	mov    rsi,rbx
 33a:	cpuid  
 33c:	xchg   rsi,rbx
 33f:	and    esi,0x20
 342:	shr    esi,0x5
 345:	lea    rbp,[rip+0x0]        # 34c <llvm::sys::getHostCPUName()+0xbc>
 34c:	lea    r12,[rip+0x0]        # 353 <llvm::sys::getHostCPUName()+0xc3>
 353:	cmove  rbp,r12
 357:	lea    rdi,[rsp+0x188]
 35f:	lea    rsi,[rip+0x0]        # 366 <llvm::sys::getHostCPUName()+0xd6>

In both other cases (2) & (3) SI is saved into stack region.

> I promise I'll do the review of your code after that.



More information about the llvm-dev mailing list