[LLVMdev] AllocaInst for FunctionType?

Alexander Poddey alexander.poddey at gmx.net
Thu Jan 15 03:05:02 PST 2015


Hi,
I'm trying to get my head around c++ - IR - c++ API and getting used 
tramform manual information to code.


The manual states alloca is defined for <type>. FunstionType is a type, so 
alloca for functionType should be possible? Not?


If we have a valid Module *m  

we can get an allocate instruction allocating space for a non-argumented 
function as follows:

AllocaInst* pa2 = new AllocaInst( FunctionType::get( 
            Type::getVoidTy(m->getContext()), false  )
   , 1, "myName");


but how about nonvar-argumented functions? E.g. I32,I16

std::vector<Type*>FuncTy_args;
FuncTy_args.push_back(IntegerType::get(mod->getContext(), 32));
FuncTy_args.push_back(IntegerType::get(mod->getContext(), 16));


AllocaInst* pa3 = new AllocaInst( FunctionType::get( 
    Type::getVoidTy(m->getContext()), FuncTy_args ,false  )
    , 1, "MyName");


does this make sense?
I guess this might not be correct, because we explicitely introduce 
FuncTy_args, where we only would like to know the 'necessary memory 
footprint' of it, for alloca to be able to allocate it, not?

Alex






More information about the llvm-dev mailing list