LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 27653 - BOUND instruction has swapped arguments
Summary: BOUND instruction has swapped arguments
Status: RESOLVED FIXED
Alias: None
Product: tools
Classification: Unclassified
Component: TableGen (show other bugs)
Version: 3.8
Hardware: PC Linux
: P normal
Assignee: Maya Madhavan
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-05 03:38 PDT by Rudolf Marek
Modified: 2018-02-14 13:55 PST (History)
4 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rudolf Marek 2016-05-05 03:38:13 PDT
//./clang-3.8 -c a.S -m32 -save-temps

//a.S is this:
.section .text
.global _start
_start:

//GCC accept this
//bound %eax, (%ecx)

//CLANG wants this
bound (%ecx), %eax

//both generate:
//62 01                	bound  %eax,(%ecx)
Comment 1 Rudolf Marek 2016-05-05 03:44:17 PDT
/tmp/xxxx/bin $ ./llvm-objdump -d a.o 

a.o:	file format ELF32-i386

Disassembly of section .text:
_start:
./llvm-objdump: warning: invalid instruction encoding

/tmp/xxxx/bin $ objdump -d a.o

a.o:     file format elf32-i386


Disassembly of section .text:

00000000 <_start>:
   0:	62 01                	bound  %eax,(%ecx)
Comment 2 Rudolf Marek 2016-06-16 16:31:58 PDT
Hi again,

I found this in GAS, tc-i386.c

 /* All intel opcodes have reversed operands except for "bound" and
     "enter".  We also don't reverse intersegment "jmp" and "call"
     instructions with 2 immediate operands so that the immediate segment
     precedes the offset, as it does when in AT&T mode. */

Plus according to and source it seems that also INVLPGA could have similar problem. 

See https://sourceware.org/binutils/docs/as/i386_002dVariations.html

Thanks,
Rudolf
Comment 3 Maya Madhavan 2018-02-13 14:33:25 PST
Change approved:
https://reviews.llvm.org/D43243
Comment 4 Craig Topper 2018-02-14 13:55:34 PST
Fixed in r325178