[llvm-bugs] [Bug 34268] New: JITting of x32 code on x64 fails with crash or instruction selection error.

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Aug 21 14:18:50 PDT 2017


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

            Bug ID: 34268
           Summary: JITting of x32 code on x64 fails with crash or
                    instruction selection error.
           Product: libraries
           Version: 4.0
          Hardware: Macintosh
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: OrcJIT
          Assignee: unassignedbugs at nondot.org
          Reporter: 1101.debian at gmail.com
                CC: llvm-bugs at lists.llvm.org

I compile a simple code:

// main.c
#include <stdio.h>

int square(int x) {
  return x * x;
}

int main() {
  printf("%d\n", square(4));
  return 0;
}

Using the following command:

> clang-4.0 main.c -c -emit-llvm -m32

Then I try to run the bitcode using lli. Based on jit kind it either crashes or
shows an instruction selection error:

> lli-4.0 -jit-kind=orc-mcjit main.bc
0  libLLVM-4.0.so.1 0x00007fa69adc49a8
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 56
1  libLLVM-4.0.so.1 0x00007fa69adc2b2e llvm::sys::RunSignalHandlers() + 62
2  libLLVM-4.0.so.1 0x00007fa69adc2c7c
3  libpthread.so.0  0x00007fa69a4aa390
4  libpthread.so.0  0x00007fa69d81e026
Stack dump:
0.      Program arguments: lli-4.0 -jit-kind=orc-mcjit main.bc
fish: “lli-4.0 -jit-kind=orc-mcjit mai…” terminated by signal SIGSEGV (Address
boundary error)

> lli-4.0  main.bc
0  libLLVM-4.0.so.1 0x00007f2377ae19a8
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 56
1  libLLVM-4.0.so.1 0x00007f2377adfb2e llvm::sys::RunSignalHandlers() + 62
2  libLLVM-4.0.so.1 0x00007f2377adfc7c
3  libpthread.so.0  0x00007f23771c7390
4  libpthread.so.0  0x00007f237a53b026
Stack dump:
0.      Program arguments: lli-4.0 main.bc
fish: “lli-4.0  main.bc” terminated by signal SIGSEGV (Address boundary error)

> lli-4.0 -jit-kind=orc-lazy main.bc
LLVM ERROR: Cannot select: 0x199d480: ch,glue = X86ISD::CALL 0x199d418,
0x199d758, Register:i32 %EDI, Register:i32 %ESI, Register:i8 %AL,
RegisterMask:Untyped, 0x199d418:1
  0x199d758: i32 = X86ISD::Wrapper TargetGlobalAddress:i32<i32 (i8*, ...)*
@printf> 0
    0x199d140: i32 = TargetGlobalAddress<i32 (i8*, ...)* @printf> 0
  0x199ce00: i32 = Register %EDI
  0x199d2e0: i32 = Register %ESI
  0x199d3b0: i8 = Register %AL
  0x199ced0: Untyped = RegisterMask
  0x199d418: ch,glue = CopyToReg 0x199d348, Register:i8 %AL, Constant:i8<0>,
0x199d348:1
    0x199d3b0: i8 = Register %AL
    0x199d210: i8 = Constant<0>
    0x199d348: ch,glue = CopyToReg 0x199d278, Register:i32 %ESI, 0x199d070,
0x199d278:1
      0x199d2e0: i32 = Register %ESI
      0x199d070: i32,ch,glue = CopyFromReg 0x199cfa0, Register:i32 %EAX,
0x199cfa0:1
        0x199d008: i32 = Register %EAX
        0x199cfa0: ch,glue = callseq_end 0x199cf38, TargetConstant:i32<0>,
TargetConstant:i32<0>, 0x199cf38:1
          0x199cd30: i32 = TargetConstant<0>
          0x199cd30: i32 = TargetConstant<0>
          0x199cf38: ch,glue = X86ISD::CALL 0x199ce68, 0x199d7c0, Register:i32
%EDI, RegisterMask:Untyped, 0x199ce68:1
            0x199d7c0: i32 = X86ISD::Wrapper TargetGlobalAddress:i32<i32 (i32)*
@square> 0
              0x199d0d8: i32 = TargetGlobalAddress<i32 (i32)* @square> 0
            0x199ce00: i32 = Register %EDI
            0x199ced0: Untyped = RegisterMask
            0x199ce68: ch,glue = CopyToReg 0x199cd98, Register:i32 %EDI,
Constant:i32<4>
              0x199ce00: i32 = Register %EDI
              0x199ccc8: i32 = Constant<4>
      0x199d278: ch,glue = CopyToReg 0x199d1a8, Register:i32 %EDI, 0x199d6f0
        0x199ce00: i32 = Register %EDI
        0x199d6f0: i32 = X86ISD::Wrapper TargetGlobalAddress:i32<[4 x i8]*
@"$static.0"> 0
          0x199d688: i32 = TargetGlobalAddress<[4 x i8]* @"$static.0"> 0
In function: main

===

I tested it only on Linux, but other systems might be affected as well.

-- 
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/20170821/9f20bba1/attachment.html>


More information about the llvm-bugs mailing list