[LLVMdev] llvm interpreter cannot execute llvm-gcc generated bitcode

Kristaps Straupe kstraupe at gmail.com
Thu Jan 28 08:52:06 PST 2010


We are compiling a very large C project in llvm and trying to execute
it in interpreter. There is a problem with executing the generated

We are using lli.exe and llvm-gcc.exe from official 2.6 LLVM release.

We have localized the problem to following c code:
int f(unsigned char x) __attribute__((noinline));

int f(unsigned char x)
  return x - 1;

int main()
   return f(1);

Which generates following llvm assembly:
; ModuleID = 'a.o'
target datalayout =
target triple = "i386-mingw32"

define i32 @f(i8 zeroext %x) nounwind readnone noinline {
  %0 = zext i8 %x to i32                          ; <i32> [#uses=1]
  %1 = add i32 %0, -1                             ; <i32> [#uses=1]
  ret i32 %1

define i32 @main() nounwind readnone {
  %0 = tail call i32 @f(i8 zeroext 1) nounwind    ; <i32> [#uses=1]
  ret i32 %0

Finally calling it with:
llvm-gcc -c -emit-llvm -O2 a.c
lli -force-interpreter a.o

Yields us:
"Assertion failed: width > BitWidth && "Invalid APInt ZeroExtend
request", file c:/proj/llvm/src/lib/Support/APInt.cpp, line 1064"
where both width and BitWidth have value "32".

Removing this assert in llvm source makes more similar (APInt related)
asserts fail later.

Is that a problem with llvm-gcc or is there a fix in llvm source available?

Thank you and we hope to hear from you soon.

More information about the llvm-dev mailing list