[LLVMdev] Is this value an integer type?

Zheng Wang jason.wangz at gmail.com
Mon May 17 07:02:39 PDT 2010


Hello,

I have a problem of dumping a value. Here is the llvm assembly code:

---
 %322 = getelementptr inbounds [76 x [4 x i8]]* @i_tc0_table, i32 0,
i32 %305, i32 %321 ; <i8*> [#uses=1]
 %323 = load i8* %322, align 1                   ; <i8> [#uses=1]
 store i8 %323, i8* %89, align 1
--

I want to dump %323 to a library function whose prototype is:

recordStore(const char*, unsigned int, unsigned, int)

But my passer stuck at CallInst::init, because llvm complains %323
does not have the same type as the recordStore's is declared.

 assert((i >= FTy->getNumParams() ||
            FTy->getParamType(i)== Params[i]->getType()) &&
           "Calling a function with a bad signature!");

This is strange because the fourth argument of recordStore has been
declared as: "IntegerType::get(getGlobalContext(), 32)"

If I somehow replace the assert statement as:

assert(...
            FTy->getParamType(i)->getTypeID() ==
Params[i]->getType()->getTypeID()) ...);

, it passes this line but will fail at some point later on.

My questions are:

***** Why %323  is different from the Integer type I has declared?
***** Why two values with the same TypeID are different?

The following code is OK for my passer if I want to dump %3.

 %3 = add i32 %1, -1                             ; <i32> [#uses=1]
  store i32 %3, i32* %0, align 4

A final question, how can I dump %323 in the first example?

Cheers,
Zheng



More information about the llvm-dev mailing list