如何检查llvm callInst是否包含位转换



我的llvm是这样的:

call void bitcast (void (%struct.type1*, %opencl.image2d_t addrspace(1)*, i32, %struct.type1*)* @_Z36functype1 to void (%struct.type2*, %opencl.image2d_t addrspace(1)*, i32, %struct.type1*)*)(%struct.type2* sret %19, %opencl.image2d_t addrspace(1)* %237, i32 %238, %struct.type1* byval %sic_payload)

我想检查调用是一个实际的函数调用还是一个具有位转换的函数调用。有人知道怎么做吗?

I tried:

const CallInst *pInstCall = dyn_cast<CallInst>(&*it);
if (!pInstCall) continue;
dyn_cast<BitCastInst >(pInstCall->getCalledFunction());

你要找的是

if (auto *CstExpr = dyn_cast<ConstantExpr>(it->getOperand(0))) {
  // BitCastInst is an *Instrution*, here you have a *ConstantExpr* Bitcast
  if (CstExpr.isCast()) {
     // do something...
  }
}

最新更新