Je suis assez nouveau avec LLVM et ayant du mal à creuser profondément dans la ligne IR suivante:Obtenez les arguments d'une fonction dans bitcasts dans les appels, LLVM
%call2 = call float bitcast (float (float, i32*)* @function to float (float, i32 addrspace(1)*)*)(float %11, i32 addrspace(1)* %arrayidx)
Ce que je dois extraire de c'est la ligne du type des arguments de la fonction (ie, (float% 11, i32 addrspace (1) *% arrayidx))
J'ai essayé ce qui suit, et j'ai joué un peu avec ConstExpr, mais je n'arrive pas à extraire ça addrspace (1)
for (Function::iterator block = F.begin(), blockEnd = F.end(); block != blockEnd; ++block) {
for (BasicBlock::iterator inst = block->begin(), instEnd = block->end(); inst != instEnd; ++inst) {
if (CallInst *call = dyn_cast<CallInst>(inst)) {
Function *calledFunction = call->getCalledFunction();
if (calledFunction == NULL) { // Called function is wrapped in a bitcast
Value* v = call->getCalledValue();
calledFunction = dyn_cast<Function>(v->stripPointerCasts());
FunctionType *ft = calledFunction->getFunctionType(); // This gives me the type "from" (the args without addrspace(1)
for(Function::arg_iterator arg = calledFunction->arg_begin(), marg_end = calledFunction->arg_end(); arg != marg_end ; arg++){
Type *argTy = arg->getType();
if (PointerType *ptrTy = dyn_cast<PointerType>(argTy)) {
if(ptrTy->getAddressSpace() !=0)
...
}
}
}
}
}
}
Le code ci-dessus me donne les types (float, i32 *) et non (float, i32 addrspace (1) *)
Une aide s'il vous plaît?
Excellent! Maintenant, cela a du sens. Je vous remercie. Savez-vous aussi comment je peux obtenir l'argument de retour? (% call2 dans ce cas) Je ne trouve rien qui soit lié à l'argument return d'un callinst dans http://llvm.org/docs/doxygen/html/classllvm_1_1CallInst.html – Shervin
@Shervin Le 'CallInst' lui-même est un' Value' qui correspond à la valeur de retour. –