diff options
author | Robert Widmann <devteam.codafi@gmail.com> | 2018-03-30 17:49:53 +0000 |
---|---|---|
committer | Robert Widmann <devteam.codafi@gmail.com> | 2018-03-30 17:49:53 +0000 |
commit | 478fce9ebfa809e0f75741bbcf1de1a7a379f5c4 (patch) | |
tree | 400a138835389691a03eb7368aa1847d322daf09 /llvm/include/llvm-c | |
parent | 5f8c3e85aae8f0a34c69053e746af439622bf96e (diff) | |
download | bcm5719-llvm-478fce9ebfa809e0f75741bbcf1de1a7a379f5c4.tar.gz bcm5719-llvm-478fce9ebfa809e0f75741bbcf1de1a7a379f5c4.zip |
[LLVM-C] Finish exception instruction bindings - Round 2
Summary:
Previous revision caused a leak in the echo test that got caught by the ASAN bots because of missing free of the handlers array and was reverted in r328759. Resubmitting the patch with that correction.
Add support for cleanupret, catchret, catchpad, cleanuppad and catchswitch and their associated accessors.
Test is modified from SimplifyCFG because it contains many diverse usages of these instructions.
Reviewers: whitequark, deadalnix
Reviewed By: whitequark
Subscribers: llvm-commits, vlad.tsyrklevich
Differential Revision: https://reviews.llvm.org/D45100
llvm-svn: 328883
Diffstat (limited to 'llvm/include/llvm-c')
-rw-r--r-- | llvm/include/llvm-c/Core.h | 79 |
1 files changed, 73 insertions, 6 deletions
diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h index e1f1191d083..ddc7fe79384 100644 --- a/llvm/include/llvm-c/Core.h +++ b/llvm/include/llvm-c/Core.h @@ -2555,11 +2555,12 @@ LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst); /** * Obtain the argument count for a call instruction. * - * This expects an LLVMValueRef that corresponds to a llvm::CallInst or - * llvm::InvokeInst. + * This expects an LLVMValueRef that corresponds to a llvm::CallInst, + * llvm::InvokeInst, or llvm:FuncletPadInst. * * @see llvm::CallInst::getNumArgOperands() * @see llvm::InvokeInst::getNumArgOperands() + * @see llvm::FuncletPadInst::getNumArgOperands() */ unsigned LLVMGetNumArgOperands(LLVMValueRef Instr); @@ -2644,9 +2645,12 @@ LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef InvokeInst); /** * Return the unwind destination basic block. * - * This only works on llvm::InvokeInst instructions. + * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and + * llvm::CatchSwitchInst instructions. * * @see llvm::InvokeInst::getUnwindDest() + * @see llvm::CleanupReturnInst::getUnwindDest() + * @see llvm::CatchSwitchInst::getUnwindDest() */ LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef InvokeInst); @@ -2662,9 +2666,12 @@ void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B); /** * Set the unwind destination basic block. * - * This only works on llvm::InvokeInst instructions. + * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and + * llvm::CatchSwitchInst instructions. * * @see llvm::InvokeInst::setUnwindDest() + * @see llvm::CleanupReturnInst::setUnwindDest() + * @see llvm::CatchSwitchInst::setUnwindDest() */ void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B); @@ -2893,11 +2900,26 @@ LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn, LLVMValueRef *Args, unsigned NumArgs, LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, const char *Name); +LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef); + +/* Exception Handling */ +LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn); LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef PersFn, unsigned NumClauses, const char *Name); -LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn); -LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef); +LLVMValueRef LLVMBuildCleanupRet(LLVMBuilderRef B, LLVMValueRef CatchPad, + LLVMBasicBlockRef BB); +LLVMValueRef LLVMBuildCatchRet(LLVMBuilderRef B, LLVMValueRef CatchPad, + LLVMBasicBlockRef BB); +LLVMValueRef LLVMBuildCatchPad(LLVMBuilderRef B, LLVMValueRef ParentPad, + LLVMValueRef *Args, unsigned NumArgs, + const char *Name); +LLVMValueRef LLVMBuildCleanupPad(LLVMBuilderRef B, LLVMValueRef ParentPad, + LLVMValueRef *Args, unsigned NumArgs, + const char *Name); +LLVMValueRef LLVMBuildCatchSwitch(LLVMBuilderRef B, LLVMValueRef ParentPad, + LLVMBasicBlockRef UnwindBB, + unsigned NumHandlers, const char *Name); /* Add a case to the switch instruction */ void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal, @@ -2921,6 +2943,51 @@ LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad); /* Set the 'cleanup' flag in the landingpad instruction */ void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val); +/* Add a destination to the catchswitch instruction */ +void LLVMAddHandler(LLVMValueRef CatchSwitch, LLVMBasicBlockRef Dest); + +/* Get the number of handlers on the catchswitch instruction */ +unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch); + +/** + * Obtain the basic blocks acting as handlers for a catchswitch instruction. + * + * The Handlers parameter should point to a pre-allocated array of + * LLVMBasicBlockRefs at least LLVMGetNumHandlers() large. On return, the + * first LLVMGetNumHandlers() entries in the array will be populated + * with LLVMBasicBlockRef instances. + * + * @param CatchSwitch The catchswitch instruction to operate on. + * @param Handlers Memory address of an array to be filled with basic blocks. + */ +void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers); + +/* Funclets */ + +/* Get the number of funcletpad arguments. */ +LLVMValueRef LLVMGetArgOperand(LLVMValueRef Funclet, unsigned i); + +/* Set a funcletpad argument at the given index. */ +void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, LLVMValueRef value); + +/** + * Get the parent catchswitch instruction of a catchpad instruction. + * + * This only works on llvm::CatchPadInst instructions. + * + * @see llvm::CatchPadInst::getCatchSwitch() + */ +LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad); + +/** + * Set the parent catchswitch instruction of a catchpad instruction. + * + * This only works on llvm::CatchPadInst instructions. + * + * @see llvm::CatchPadInst::setCatchSwitch() + */ +void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad, LLVMValueRef CatchSwitch); + /* Arithmetic */ LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); |