[llvm-bugs] [Bug 36144] New: Operands of the form '0b' in jump instructions in X86 Intel dialect inline assembly are not recognised as valid.

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jan 30 00:48:28 PST 2018


https://bugs.llvm.org/show_bug.cgi?id=36144

            Bug ID: 36144
           Summary: Operands of the form '0b' in jump instructions in X86
                    Intel dialect inline assembly are not recognised as
                    valid.
           Product: new-bugs
           Version: trunk
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: tom.paul.murray at gmail.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 19771
  --> https://bugs.llvm.org/attachment.cgi?id=19771&action=edit
C++ source file, compilation of which with Clang reproduces the issue

Overview:
Using operands of the form '0b' (a numbered label appearing earlier in source
relative to current source position) in jump instructions (any jump
instruction, jmp, je, jne, jz, jnz etc.) in inline 
 intel dialect x86 assembly causes an 'Invalid operand for instruction'
compilation error. In earlier versions (specific versions listed below) of
clang this compiled correctly, producing code with the jmp target replaced with
the correct label generated from the numbered label in the inline assembly.

Steps to Reproduce:
1. Download the attached source 'x86IntelInlineAsmJmpToLabelRelativeTest.cpp'
2. Using a version of clang 5.0 or greater (including trunk), attempt to
compile this using: clang x86IntelInlineAsmJmpToLabelRelativeTest.cpp -o
x86IntelInlineAsmJmpToLabelRelativeTest
3. Observe the compilation error on line 17 of
x86IntelInlineAsmJmpToLabelRelativeTest.cpp - "Invalid operand for instruction"

Actual Results:
The program fails to compile.

Expected Results:
The program compiles successfully, with the target of the jump instruction
replaced with the correct label generated from the numbered label in the inline
assembly.

Build Date & Hardware where bug was first encountered:
26 Jan 2018 - Xcode 9.3 Beta 1 (9Q98q), Apple LLVM version 9.1.0
(clang-902.0.30) - Mac OS 10.13.3 (17D47)

Additional Builds and Platforms:
Clang 5.0.0 (non-Xcode version) release reproduced the issue.
Clang 4.0.0 and 4.0.1 (non-Xcode version) releases did not reproduce the issue.
Locally compiled build of Clang on trunk (@ SVN revision 323529) reproduced the
issue.

Additional information:
The attached code performs the same operation twice, first using Intel syntax,
then using AT&T syntax to demonstrate the issue exists only in the Intel syntax
path.

A brief investigation seems to show this arises from an ambiguity when parsing
operands to instructions in Intel syntax after handling of MASM style Intel
syntax was added in r280555. Because MASM allows integer literals of the form
'011010b', '0b' is a valid integer literal representing value 0. The code in
lib/MC/MCParser/AsmLexer.cpp - llvm::AsmLexer::LexDigit() with MASM style Intel
assembly handling consumes the 'b' suffix on the literal. This means the
special handling of positionally relative jump targets in
lib/Target/X86/AsmParser/X86AsmParser.cpp -
X86AsmParser::ParseIntelExpression() can no longer correctly detect this form
of jump target, and incorrectly identifies the jump instruction's operand as
just an integer which causes a compilation error.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180130/c9242acd/attachment-0001.html>


More information about the llvm-bugs mailing list