[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH for-4.9 v3 3/3] x86/atomic: fix cmpxchg16b inline assembly to work with clang



On Mon, Apr 10, 2017 at 02:34:35PM +0100, Roger Pau Monne wrote:
> clang doesn't understand the "=A" register constrain when used with 64bits
> assembly and spits out an internal error:
> 
> fatal error: error in backend: Cannot select: 0x7f9fb89c9390: i64 = 
> build_pair 0x7f9fb89c92b0,
>       0x7f9fb89c9320
>   0x7f9fb89c92b0: i32,ch,glue = CopyFromReg 0x7f9fb89c9240, Register:i32 
> %EAX, 0x7f9fb89c9240:1
>     0x7f9fb89c8c20: i32 = Register %EAX
>     0x7f9fb89c9240: ch,glue = inlineasm 0x7f9fb89c90f0,
> TargetExternalSymbol:i64'lock; cmpxchg16b $1', MDNode:ch<0x7f9fb8476c38>,
> TargetConstant:i64<25>, TargetConstant:i32<18>, Register:i32 %EAX, 
> Register:i32
> %EDX, TargetConstant:i32<196622>, 0x7f9fb89c87c0, TargetConstant:i32<9>,
> Register:i64 %RCX, TargetConstant:i32<9>, Register:i64 %RBX,
> TargetConstant:i32<9>, Register:i64 %RDX, TargetConstant:i32<9>, Register:i64
> %RAX, TargetConstant:i32<196622>, 0x7f9fb89c87c0, TargetConstant:i32<12>,
> Register:i32 %EFLAGS, 0x7f9fb89c90f0:1
>       0x7f9fb89c8a60: i64 = TargetExternalSymbol'lock; cmpxchg16b $1'
>       0x7f9fb89c8b40: i64 = TargetConstant<25>
>       0x7f9fb89c8bb0: i32 = TargetConstant<18>
>       0x7f9fb89c8c20: i32 = Register %EAX
>       0x7f9fb89c8c90: i32 = Register %EDX
>       0x7f9fb89c8d00: i32 = TargetConstant<196622>
>       0x7f9fb89c87c0: i64,ch = load<LD8[%4]> 0x7f9fb9053da0, 
> FrameIndex:i64<1>, undef:i64
>         0x7f9fb9053a90: i64 = FrameIndex<1>
>         0x7f9fb9053e80: i64 = undef
>       0x7f9fb89c8e50: i32 = TargetConstant<9>
>       0x7f9fb89c8d70: i64 = Register %RCX
>       0x7f9fb89c8e50: i32 = TargetConstant<9>
>       0x7f9fb89c8ec0: i64 = Register %RBX
>       0x7f9fb89c8e50: i32 = TargetConstant<9>
>       0x7f9fb89c8fa0: i64 = Register %RDX
>       0x7f9fb89c8e50: i32 = TargetConstant<9>
>       0x7f9fb89c9080: i64 = Register %RAX
> [...]
> 
> Fix this by specifying "rdx:rax" manually using the "d" and "a" constraints.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> ---
> Cc: Jan Beulich <jbeulich@xxxxxxxx>
> Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> ---
> Changes since v2:
>  - New in this version.
> 
> ---
> NB: this is the only usage of "=A" on 64bit assembly in Xen. I will send a bug
> report upstream to get this fixed, so that clang properly understands "=A" for
> 64bit assembly as "RDX:RAX", but in the meantime I would like to get this
> patch accepted so the clang build can be functional again.
> 
> Upstream bug report can be found at: 
> http://bugs.llvm.org/show_bug.cgi?id=32594

And this has now been fixed upstream, for the record:

http://llvm.org/viewvc/llvm-project?view=revision&revision=300404

Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.