[LLVMdev] Problem with 32 and 64bit binaries

Ivanov Ivan ivan.i at samsung.com
Fri Jun 27 03:18:14 PDT 2014


Hi, all.

I am generating LLVM IR code for x64 platform using LLVM 64bit libraries ,
and for some reason I need to move to 32bit.

But after building 32bit libraries I found that IR code generates
incorrectly and it causes segfault.

For example, instead of generating function call it generates function phi.

 

64bit libs:

init:                                             ; preds = %pre_entry

  call void @Init()

  br label %entry

 

32bit libs:

init:

       phi void [ @Init(), <null operand!> ]

       br label entry

 

 

Or other example. Instead of this:

lpad:                                             ; preds = %entry

  %lpad1 = landingpad { i8*, i32 } personality i32 (...)*
@__gxx_personality_v0

          catch i8* bitcast (i8** @_ZTIPKc to i8*)

  %exn = extractvalue { i8*, i32 } %lpad1, 0
<------

  store i8* %exn, i8** %exn.slot

  %ehselector = extractvalue { i8*, i32 } %lpad1, 1

  store i32 %ehselector, i32* %ehselector.slot

  br label %catch

 

catch:                                            ; preds = %lpad

  %exn2 = load i8** %exn.slot

  %1 = call i8* @__cxa_begin_catch(i8* %exn2)

  call void (i8*, ...)* @_printf(i8* %1)
<--------

  br label %ret

 

I get this code:

lpad:                                             ; preds = %entry

  %lpad1 = landingpad { i8*, i32 } personality i32 (...)*
@__gxx_personality_v0

          catch i8* bitcast (i8** @_ZTIPKc to i8*)

  %exn = shufflevector { i8*, i32 } %lpad1
<---------

  store i8* %exn, i8** %exn.slot

  %ehselector = shufflevector { i8*, i32 } %lpad1

  store i32 %ehselector, i32* %ehselector.slot

  br label %catch

 

catch:                                            ; preds = %lpad

  %exn2 = load i8** %exn.slot

  %1 = phi i8* [ %exn2, <null operand!> ], [ @__cxa_begin_catch,
Segmentation fault (core dumped)

 

Anyone can tell me what is it? Is it a bug of LLVM or our codegen?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140627/68dcf2db/attachment.html>


More information about the llvm-dev mailing list