I have three questions:
1) What are the differences between Invoke and Call operations in IR codes of LLVM?
2) Why Call instruction is not considered as Terminator operation in BasicBlocks here?
3) Is it possible for both of the Invoke and Call operations to generate indirect Calls in assembly level language?
Thank you in advance,
Regarding 3), it's not clear whether you're asking w.r.t. writing a) an own backend or b) regarding an existing backend.
a) yes, obviously / generally you could generate anything you want if you'd implement that in your backend. b) which backend? i.e. ARM's call already is an indirect branch (i.e. bl instruction) while X86's CALL has side effects on X86 HW (i.e. saving return address, also non-functional side effects like support for call-stack branch prediction) and hence can't just be replaced by an indirect call without emulation what CALL would do. AFAIK a CALL emulation using indirect branches is not part of X86's LLVM backend.
invoke and call are used to make a call to a function. call instruction is the normal C-style call where program resumes from the next instruction following the function call once function returns.
invoke can be used to handle exception in a way that when the function did not return normally, it would 'resume' from a different basic block (a.k.a landing pad). the landing pad would have the information to handle exception.
indirect calls can be generated using both call and invoke instructions AIUI. More details are in the llvm langref: https://llvm.org/docs/LangRef.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With