Ramkumar Ramachandra
2013-Jul-14 18:26 UTC
[LLVMdev] [PATCH] x86/asm: avoid mnemonics without type suffix
Linus Torvalds wrote:>> btrl $1, 0 >> btr $1, 0 >> btsl $1, 0 >> bts $1, 0 > > What the heck is that supposed to show?I was trying to show a reduced case where gas doesn't complain, but llvm-mc does. Try compiling this with llvm-mc, and you'll get: .text btrl $1, 0 in.s:2:1: error: ambiguous instructions require an explicit suffix (could be 'btrw', 'btrl', or 'btrq') btr $1, 0 ^ btsl $1, 0 in.s:4:1: error: ambiguous instructions require an explicit suffix (could be 'btsw', 'btsl', or 'btsq') bts $1, 0 ^ Obviously, I misunderstood something major and screwed up the commit message.> int main(int argc, char **argv) > { > asm("bt %1,%0":"=m" (**argv): "a" (argc)); > asm("bt %1,%0":"=m" (**argv): "a" ((unsigned long)(argc))); > }Right, so in: int main(int argc, char **argv) { asm("bts %1,%0":"=m" (**argv): "r" (argc)); asm("btsl %1,%0":"=m" (**argv): "r" (argc)); asm("btr %1,%0":"=m" (**argv): "r" ((unsigned long)(argc))); asm("btrq %1,%0":"=m" (**argv): "r" ((unsigned long)(argc))); } bts disambiguates to btsl, and btr disambiguates to btrq, as advertised. Is it dependent on whether I have a 32-bit machine or 64-bit machine, or just on the operand lengths? Either way, this is not a very enlightening example, because clang also compiles this fine, and doesn't complain about any ambiguity. To see the ambiguity I'm talking about, try to compile linux.git with clang; I'll paste one error: arch/x86/include/asm/bitops.h:129:15: error: ambiguous instructions require an explicit suffix (could be 'btrw', 'btrl', or 'btrq') asm volatile("btr %1,%0" : ADDR : "Ir" (nr)); ^ <inline asm>:1:2: note: instantiated into assembly here btr $0,(%rsi) ^ Since nr is an int, and ADDR is *(volatile long *), this should disambiguate to btrl, right? Any clue why clang is complaining?
Linus Torvalds
2013-Jul-14 18:34 UTC
[LLVMdev] [PATCH] x86/asm: avoid mnemonics without type suffix
On Sun, Jul 14, 2013 at 11:26 AM, Ramkumar Ramachandra <artagnon at gmail.com> wrote:> > I was trying to show a reduced case where gas doesn't complain, but > llvm-mc does. Try compiling this with llvm-mc, and you'll get:Ok. So your commit message and explanation was pure and utter tripe, and the real reason you want this is that llvm-mc is broken. Please fix llvm-mc instead, ok? If the intent of llvm is to be compatible with the gnu compiler tools, then it should do that. Plus the gas behavior is clearly superior, so why not just improve the llvm toolchain to match those improved semantics? Linus
Ramkumar Ramachandra
2013-Jul-14 18:49 UTC
[LLVMdev] [PATCH] x86/asm: avoid mnemonics without type suffix
Linus Torvalds wrote:> Ok. So your commit message and explanation was pure and utter tripe, > and the real reason you want this is that llvm-mc is broken. > > Please fix llvm-mc instead, ok? If the intent of llvm is to be > compatible with the gnu compiler tools, then it should do that. Plus > the gas behavior is clearly superior, so why not just improve the llvm > toolchain to match those improved semantics?Yep. I started the discussion on LLVMDev, and posted patches [1].>From the discussions on the list, many of the devs are claiming thatLLVM is "correct" and that linux.git needs to be patched. I'm not taking sides; I just want a solution to the problem. [1]: The archive is broken, but here are some pieces: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20130708/180968.html
Seemingly Similar Threads
- [LLVMdev] [PATCH] x86/asm: avoid mnemonics without type suffix
- [LLVMdev] [PATCH] x86/asm: avoid mnemonics without type suffix
- [LLVMdev] [PATCH] x86/asm: avoid mnemonics without type suffix
- [LLVMdev] [PATCH] x86/asm: avoid mnemonics without type suffix
- [LLVMdev] [PATCH] x86/asm: avoid mnemonics without type suffix