[LLVMdev] What am I doing wrong here...

Sarah Thompson thompson at email.arc.nasa.gov
Tue Oct 30 15:33:24 PDT 2007


I'm getting a 'function arguments must be value types' assertion from 
the following (abridged) code. Basically, I'm writing a pass that 
inserts llvm.frameaddress intrinsic calls everywhere 'interesting' that 
passes on the result by calling the C function void mcp_trace_stack(char 
*ptr). First I grab the functions themselves:

  Constant *MCPTraceStack, *LLVMFrameAddress;    
   
  std::vector<const Type*> argstype;
  argstype.push_back(PointerType::get(Type::Int8Ty));
       
  FunctionType *FT = FunctionType::get(Type::VoidTy, argstype, false);
  MCPTraceStack = M.getOrInsertFunction("mcp_trace_stack", FT);

  std::vector<const Type*> frargstype;
  frargstype.push_back(Type::VoidTy);

  FunctionType *FA = FunctionType::get(PointerType::get(Type::Int8Ty), 
frargstype, false);
  LLVMFrameAddress = M.getOrInsertFunction("llvm.frameaddress", FA);

then (in the pass itself) I use a code fragment like the following:

  CallInst *faddr = new CallInst(LLVMFrameAddress, "", np);
  new CallInst(MCPTraceStack, faddr, "", np);

which  compiles fine, but at run-time (under opt) the pass aborts with 
an assertion. I realise I've probably done something subtly wrong, but 
I've been prodding at this for ages now and I just can't find it.

Thank you in advance,
Sarah



More information about the llvm-dev mailing list