aditya vishnubhotla
2008-Feb-19 09:11 UTC
[LLVMdev] Problem with variable argument intrinsics
Hi,
I tried creating variable argument intrinsics which
are to be placeholders for some instructions which
should not be executed by the backend.
Kindly help me with the errors in my "migrate_begin"
intrinsic creation
//Additions made to Intrinsics.td file:
def llvm_migrate_begin : LLVMType<iAny>;
def int_migrate_begin :
Intrinsic<[llvm_migrate_begin,llvm_vararg_ty],[IntrWriteMem],"llvm.migrate_begin">;
//A section of the code which deals with the
//"migrate_begin" intrinsic creation is as follows:
const Type **Tys=(const
Type**)calloc(extTys.size(),sizeof(Type*)); /*
extTys
vector contains data types(pointers) of formal
parameters of the
function "f" */
int i=0;
for(vector<const Type*>::iterator
it=extTys.begin(),e=extTys.end();it!=e;it++)
{Tys[i++]=*it;}
extTys.clear();
Module *M = bbp->getParent()->getParent();
Function *f Intrinsic::getDeclaration(M,Intrinsic::migrate_begin,Tys,i);
/*
migrate_begin intrinsic creation */
CallInst* CI = new CallInst(f,"migrate_begin",bbp);
/*bbp is pointer to basic block where
intrinsic is to be inserted*/
//Errors:
Overloaded intrinsic has incorrect suffix: '.i32.i32'.
It should be '.i32'
i32 (...)* @llvm.migrate_begin.i32.i32
Overloaded intrinsic has incorrect suffix:
'.i32.i32.i32'. It should be '.i32'
i32 (...)* @llvm.migrate_begin.i32.i32.i32
Broken module found, compilation aborted!
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search.
http://tools.search.yahoo.com/newsearch/category.php?category=shopping
On Feb 19, 2008, at 1:11 AM, aditya vishnubhotla wrote:> Hi, > I tried creating variable argument intrinsics which > are to be placeholders for some instructions which > should not be executed by the backend. > > Kindly help me with the errors in my "migrate_begin" > intrinsic creation > > //Additions made to Intrinsics.td file: > > def llvm_migrate_begin : LLVMType<iAny>; > def int_migrate_begin : > Intrinsic<[llvm_migrate_begin,llvm_vararg_ty], > [IntrWriteMem],"llvm.migrate_begin">;This says that the return type is overloaded (because it's iAny). But that's the only overloaded part here; using variadic argument lists is different from overloading.> > > Overloaded intrinsic has incorrect suffix: '.i32.i32'. > It should be '.i32' > i32 (...)* @llvm.migrate_begin.i32.i32 > > Overloaded intrinsic has incorrect suffix: > '.i32.i32.i32'. It should be '.i32' > i32 (...)* @llvm.migrate_begin.i32.i32.i32The suffix has a part for each overloaded type in the function type. Since only the return type is overloaded, the verifier is expecting only one type to be passed into getDeclaration. Dan
Hi,
Thank You for the advice and we were able to solve
that problem by the following modifications to the
Instrinsics.td file.
But I now have an "Invalid Intrinsic name" error
This error occurs presumably because the created
intrinsic is named:
llvm.migrate_begin.i32
Intrinsics.gen checks for a string length of 18
(i.e. the length without the .i32).
Kindly help me through it.
//Additions made to Intrinsics.td file:
def int_migrate_begin :
Intrinsic<[llvm_i32_ty,llvm_vararg_ty],
[IntrWriteMem],"llvm.migrate_begin">;
//A section of the code which deals with the
//"migrate_begin" intrinsic creation is as follows:
const Type **Tys=(const
Type**)calloc(extTys.size(),sizeof(Type*));
/*extTys vector contains function type of the
function "f" */
int i=0;
for(vector<const Type*>::iterator
it=extTys.begin(),e=extTys.end();it!=e;it++)
{Tys[i++]=*it;}
extTys.clear();
Module *M = bbp->getParent()->getParent();
Function *f
Intrinsic::getDeclaration(M,Intrinsic::migrate_begin,Tys,i);
/* migrate_begin intrinsic creation */
CallInst* CI = new CallInst(f,"migrate_begin");
//Error:
NAME:llvm.migrate_begin.i32
opt: Function.cpp:293: unsigned int
llvm::Function::getIntrinsicID(bool)
const: Assertion `noAssert && "Invalid LLVM intrinsic
name"' failed.
P.S:
> --- Dan Gohman <gohman at apple.com> wrote:
> On Feb 19, 2008, at 1:11 AM, aditya vishnubhotla
>
> wrote:
> > Hi,
> > I tried creating variable argument intrinsics
>
> which
>
> > are to be placeholders for some instructions
which
> > should not be executed by the backend.
> >
> > Kindly help me with the errors in my
>
> "migrate_begin"
>
> > intrinsic creation
> >
> > //Additions made to Intrinsics.td file:
> >
> > def llvm_migrate_begin : LLVMType<iAny>;
> > def int_migrate_begin :
> > Intrinsic<[llvm_migrate_begin,llvm_vararg_ty],
> > [IntrWriteMem],"llvm.migrate_begin">;
>
> This says that the return type is overloaded
> (because it's iAny). But
> that's
> the only overloaded part here; using variadic> > argument lists is
> different
> from overloading.
>
> > Overloaded intrinsic has incorrect suffix:
>
> '.i32.i32'.
>
> > It should be '.i32'
> > i32 (...)* @llvm.migrate_begin.i32.i32
> >
> > Overloaded intrinsic has incorrect suffix:
> > '.i32.i32.i32'. It should be '.i32'
> > i32 (...)* @llvm.migrate_begin.i32.i32.i32
>
> The suffix has a part for each overloaded type in
> the function type.
> Since only
> the return type is overloaded, the verifier is
> expecting only one type
> to be passed
> into getDeclaration.
>> Dan
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs