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
On 05/17/2010 05:02 PM, Zheng Wang wrote:> 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)To pass an i8 as i32 you need either sign-, or zero-extension, i.e. %324 = zext i8 %323 to i32 call %recordStore(null, %324, i32 0) For example.> ***** Why %323 is different from the Integer type I has declared?i8 and i32 are different types Best regards, --Edwin
Hi Zheng,> %323 = load i8* %322, align 1 ;<i8> [#uses=1]the type of %323 is i8, as noted in the comment at the end of the line.> This is strange because the fourth argument of recordStore has been > declared as: "IntegerType::get(getGlobalContext(), 32)"This type is i32. Since i8 != i32, the types don't match. Ciao, Duncan.
Thanks all!! Problem Solved. :) 2010/5/17 Török Edwin <edwintorok at gmail.com>:> On 05/17/2010 05:02 PM, Zheng Wang wrote: >> 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) > > To pass an i8 as i32 you need either sign-, or zero-extension, i.e. > %324 = zext i8 %323 to i32 > call %recordStore(null, %324, i32 0) > > For example. >> ***** Why %323 is different from the Integer type I has declared? > > i8 and i32 are different types > > > Best regards, > --Edwin > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- Best regards, WANG Zheng