Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

llvm get called function name using llvm instruction

Tags:

llvm

I want to know if an llvm::intruction is a function call and if so what is the name of the fucntion it is calling to.

Also is there a way to get llvm::CallInst from an llvm::Instruction?

like image 763
Awaid Shaheen Avatar asked Oct 18 '25 15:10

Awaid Shaheen


1 Answers

Instruction* I = ...
if (isa<CallInst>(I)) {
  StringRef name = cast<CallInst>(I).getCalledFunction().getName();
  ...
}

For more information on this, see the relevant section in LLVM Programmer's Manual. In general, I wholeheartedly recommend this guide for beginners.

like image 188
Oak Avatar answered Oct 22 '25 06:10

Oak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!