<div dir="ltr">Hi, the <a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap">http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap</a> bot has been <a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/4842/steps/check-llvm%20asan/logs/stdio">failing</a> since this change was committed.</div><br><div class="gmail_quote"><div dir="ltr">On Wed, Mar 28, 2018 at 8:46 PM Robert Widmann via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: codafi<br>
Date: Wed Mar 28 20:43:15 2018<br>
New Revision: 328759<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=328759&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=328759&view=rev</a><br>
Log:<br>
[LLVM-C] Finish exception instruction bindings<br>
<br>
Summary:<br>
Add support for cleanupret, catchret, catchpad, cleanuppad and catchswitch and their associated accessors.<br>
<br>
Test is modified from SimplifyCFG because it contains many diverse usages of these instructions.<br>
<br>
Reviewers: whitequark, deadalnix, echristo<br>
<br>
Reviewed By: echristo<br>
<br>
Subscribers: llvm-commits, harlanhaskins<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D44496" rel="noreferrer" target="_blank">https://reviews.llvm.org/D44496</a><br>
<br>
Modified:<br>
llvm/trunk/include/llvm-c/Core.h<br>
llvm/trunk/lib/IR/Core.cpp<br>
llvm/trunk/test/Bindings/llvm-c/echo.ll<br>
llvm/trunk/tools/llvm-c-test/echo.cpp<br>
<br>
Modified: llvm/trunk/include/llvm-c/Core.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=328759&r1=328758&r2=328759&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=328759&r1=328758&r2=328759&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm-c/Core.h (original)<br>
+++ llvm/trunk/include/llvm-c/Core.h Wed Mar 28 20:43:15 2018<br>
@@ -2555,11 +2555,12 @@ LLVMValueRef LLVMInstructionClone(LLVMVa<br>
/**<br>
* Obtain the argument count for a call instruction.<br>
*<br>
- * This expects an LLVMValueRef that corresponds to a llvm::CallInst or<br>
- * llvm::InvokeInst.<br>
+ * This expects an LLVMValueRef that corresponds to a llvm::CallInst,<br>
+ * llvm::InvokeInst, or llvm:FuncletPadInst.<br>
*<br>
* @see llvm::CallInst::getNumArgOperands()<br>
* @see llvm::InvokeInst::getNumArgOperands()<br>
+ * @see llvm::FuncletPadInst::getNumArgOperands()<br>
*/<br>
unsigned LLVMGetNumArgOperands(LLVMValueRef Instr);<br>
<br>
@@ -2644,9 +2645,12 @@ LLVMBasicBlockRef LLVMGetNormalDest(LLVM<br>
/**<br>
* Return the unwind destination basic block.<br>
*<br>
- * This only works on llvm::InvokeInst instructions.<br>
+ * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and<br>
+ * llvm::CatchSwitchInst instructions.<br>
*<br>
* @see llvm::InvokeInst::getUnwindDest()<br>
+ * @see llvm::CleanupReturnInst::getUnwindDest()<br>
+ * @see llvm::CatchSwitchInst::getUnwindDest()<br>
*/<br>
LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef InvokeInst);<br>
<br>
@@ -2662,9 +2666,12 @@ void LLVMSetNormalDest(LLVMValueRef Invo<br>
/**<br>
* Set the unwind destination basic block.<br>
*<br>
- * This only works on llvm::InvokeInst instructions.<br>
+ * Works on llvm::InvokeInst, llvm::CleanupReturnInst, and<br>
+ * llvm::CatchSwitchInst instructions.<br>
*<br>
* @see llvm::InvokeInst::setUnwindDest()<br>
+ * @see llvm::CleanupReturnInst::setUnwindDest()<br>
+ * @see llvm::CatchSwitchInst::setUnwindDest()<br>
*/<br>
void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);<br>
<br>
@@ -2893,11 +2900,26 @@ LLVMValueRef LLVMBuildInvoke(LLVMBuilder<br>
LLVMValueRef *Args, unsigned NumArgs,<br>
LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,<br>
const char *Name);<br>
+LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);<br>
+<br>
+/* Exception Handling */<br>
+LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);<br>
LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,<br>
LLVMValueRef PersFn, unsigned NumClauses,<br>
const char *Name);<br>
-LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);<br>
-LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);<br>
+LLVMValueRef LLVMBuildCleanupRet(LLVMBuilderRef B, LLVMValueRef CatchPad,<br>
+ LLVMBasicBlockRef BB);<br>
+LLVMValueRef LLVMBuildCatchRet(LLVMBuilderRef B, LLVMValueRef CatchPad,<br>
+ LLVMBasicBlockRef BB);<br>
+LLVMValueRef LLVMBuildCatchPad(LLVMBuilderRef B, LLVMValueRef ParentPad,<br>
+ LLVMValueRef *Args, unsigned NumArgs,<br>
+ const char *Name);<br>
+LLVMValueRef LLVMBuildCleanupPad(LLVMBuilderRef B, LLVMValueRef ParentPad,<br>
+ LLVMValueRef *Args, unsigned NumArgs,<br>
+ const char *Name);<br>
+LLVMValueRef LLVMBuildCatchSwitch(LLVMBuilderRef B, LLVMValueRef ParentPad,<br>
+ LLVMBasicBlockRef UnwindBB,<br>
+ unsigned NumHandlers, const char *Name);<br>
<br>
/* Add a case to the switch instruction */<br>
void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,<br>
@@ -2921,6 +2943,51 @@ LLVMBool LLVMIsCleanup(LLVMValueRef Land<br>
/* Set the 'cleanup' flag in the landingpad instruction */<br>
void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);<br>
<br>
+/* Add a destination to the catchswitch instruction */<br>
+void LLVMAddHandler(LLVMValueRef CatchSwitch, LLVMBasicBlockRef Dest);<br>
+<br>
+/* Get the number of handlers on the catchswitch instruction */<br>
+unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch);<br>
+<br>
+/**<br>
+ * Obtain the basic blocks acting as handlers for a catchswitch instruction.<br>
+ *<br>
+ * The Handlers parameter should point to a pre-allocated array of<br>
+ * LLVMBasicBlockRefs at least LLVMGetNumHandlers() large. On return, the<br>
+ * first LLVMGetNumHandlers() entries in the array will be populated<br>
+ * with LLVMBasicBlockRef instances.<br>
+ *<br>
+ * @param CatchSwitch The catchswitch instruction to operate on.<br>
+ * @param Handlers Memory address of an array to be filled with basic blocks.<br>
+ */<br>
+void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers);<br>
+<br>
+/* Funclets */<br>
+<br>
+/* Get the number of funcletpad arguments. */<br>
+LLVMValueRef LLVMGetArgOperand(LLVMValueRef Funclet, unsigned i);<br>
+<br>
+/* Set a funcletpad argument at the given index. */<br>
+void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, LLVMValueRef value);<br>
+<br>
+/**<br>
+ * Get the parent catchswitch instruction of a catchpad instruction.<br>
+ *<br>
+ * This only works on llvm::CatchPadInst instructions.<br>
+ *<br>
+ * @see llvm::CatchPadInst::getCatchSwitch()<br>
+ */<br>
+LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad);<br>
+<br>
+/**<br>
+ * Set the parent catchswitch instruction of a catchpad instruction.<br>
+ *<br>
+ * This only works on llvm::CatchPadInst instructions.<br>
+ *<br>
+ * @see llvm::CatchPadInst::setCatchSwitch()<br>
+ */<br>
+void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad, LLVMValueRef CatchSwitch);<br>
+<br>
/* Arithmetic */<br>
LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,<br>
const char *Name);<br>
<br>
Modified: llvm/trunk/lib/IR/Core.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Core.cpp?rev=328759&r1=328758&r2=328759&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Core.cpp?rev=328759&r1=328758&r2=328759&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/IR/Core.cpp (original)<br>
+++ llvm/trunk/lib/IR/Core.cpp Wed Mar 28 20:43:15 2018<br>
@@ -2196,12 +2196,15 @@ LLVMValueRef LLVMInstructionClone(LLVMVa<br>
return nullptr;<br>
}<br>
<br>
-/*--.. Call and invoke instructions ........................................--*/<br>
-<br>
unsigned LLVMGetNumArgOperands(LLVMValueRef Instr) {<br>
+ if (FuncletPadInst *FPI = dyn_cast<FuncletPadInst>(unwrap(Instr))) {<br>
+ return FPI->getNumArgOperands();<br>
+ }<br>
return CallSite(unwrap<Instruction>(Instr)).getNumArgOperands();<br>
}<br>
<br>
+/*--.. Call and invoke instructions ........................................--*/<br>
+<br>
unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr) {<br>
return CallSite(unwrap<Instruction>(Instr)).getCallingConv();<br>
}<br>
@@ -2284,6 +2287,11 @@ LLVMBasicBlockRef LLVMGetNormalDest(LLVM<br>
}<br>
<br>
LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef Invoke) {<br>
+ if (CleanupReturnInst *CRI = dyn_cast<CleanupReturnInst>(unwrap(Invoke))) {<br>
+ return wrap(CRI->getUnwindDest());<br>
+ } else if (CatchSwitchInst *CSI = dyn_cast<CatchSwitchInst>(unwrap(Invoke))) {<br>
+ return wrap(CSI->getUnwindDest());<br>
+ }<br>
return wrap(unwrap<InvokeInst>(Invoke)->getUnwindDest());<br>
}<br>
<br>
@@ -2292,6 +2300,11 @@ void LLVMSetNormalDest(LLVMValueRef Invo<br>
}<br>
<br>
void LLVMSetUnwindDest(LLVMValueRef Invoke, LLVMBasicBlockRef B) {<br>
+ if (CleanupReturnInst *CRI = dyn_cast<CleanupReturnInst>(unwrap(Invoke))) {<br>
+ return CRI->setUnwindDest(unwrap(B));<br>
+ } else if (CatchSwitchInst *CSI = dyn_cast<CatchSwitchInst>(unwrap(Invoke))) {<br>
+ return CSI->setUnwindDest(unwrap(B));<br>
+ }<br>
unwrap<InvokeInst>(Invoke)->setUnwindDest(unwrap(B));<br>
}<br>
<br>
@@ -2513,10 +2526,53 @@ LLVMValueRef LLVMBuildLandingPad(LLVMBui<br>
return wrap(unwrap(B)->CreateLandingPad(unwrap(Ty), NumClauses, Name));<br>
}<br>
<br>
+LLVMValueRef LLVMBuildCatchPad(LLVMBuilderRef B, LLVMValueRef ParentPad,<br>
+ LLVMValueRef *Args, unsigned NumArgs,<br>
+ const char *Name) {<br>
+ return wrap(unwrap(B)->CreateCatchPad(unwrap(ParentPad),<br>
+ makeArrayRef(unwrap(Args), NumArgs),<br>
+ Name));<br>
+}<br>
+<br>
+LLVMValueRef LLVMBuildCleanupPad(LLVMBuilderRef B, LLVMValueRef ParentPad,<br>
+ LLVMValueRef *Args, unsigned NumArgs,<br>
+ const char *Name) {<br>
+ if (ParentPad == nullptr) {<br>
+ Type *Ty = Type::getTokenTy(unwrap(B)->getContext());<br>
+ ParentPad = wrap(Constant::getNullValue(Ty));<br>
+ }<br>
+ return wrap(unwrap(B)->CreateCleanupPad(unwrap(ParentPad),<br>
+ makeArrayRef(unwrap(Args), NumArgs),<br>
+ Name));<br>
+}<br>
+<br>
LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn) {<br>
return wrap(unwrap(B)->CreateResume(unwrap(Exn)));<br>
}<br>
<br>
+LLVMValueRef LLVMBuildCatchSwitch(LLVMBuilderRef B, LLVMValueRef ParentPad,<br>
+ LLVMBasicBlockRef UnwindBB,<br>
+ unsigned NumHandlers, const char *Name) {<br>
+ if (ParentPad == nullptr) {<br>
+ Type *Ty = Type::getTokenTy(unwrap(B)->getContext());<br>
+ ParentPad = wrap(Constant::getNullValue(Ty));<br>
+ }<br>
+ return wrap(unwrap(B)->CreateCatchSwitch(unwrap(ParentPad), unwrap(UnwindBB),<br>
+ NumHandlers, Name));<br>
+}<br>
+<br>
+LLVMValueRef LLVMBuildCatchRet(LLVMBuilderRef B, LLVMValueRef CatchPad,<br>
+ LLVMBasicBlockRef BB) {<br>
+ return wrap(unwrap(B)->CreateCatchRet(unwrap<CatchPadInst>(CatchPad),<br>
+ unwrap(BB)));<br>
+}<br>
+<br>
+LLVMValueRef LLVMBuildCleanupRet(LLVMBuilderRef B, LLVMValueRef CatchPad,<br>
+ LLVMBasicBlockRef BB) {<br>
+ return wrap(unwrap(B)->CreateCleanupRet(unwrap<CleanupPadInst>(CatchPad),<br>
+ unwrap(BB)));<br>
+}<br>
+<br>
LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef B) {<br>
return wrap(unwrap(B)->CreateUnreachable());<br>
}<br>
@@ -2551,6 +2607,40 @@ void LLVMSetCleanup(LLVMValueRef Landing<br>
unwrap<LandingPadInst>(LandingPad)->setCleanup(Val);<br>
}<br>
<br>
+void LLVMAddHandler(LLVMValueRef CatchSwitch, LLVMBasicBlockRef Dest) {<br>
+ unwrap<CatchSwitchInst>(CatchSwitch)->addHandler(unwrap(Dest));<br>
+}<br>
+<br>
+unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch) {<br>
+ return unwrap<CatchSwitchInst>(CatchSwitch)->getNumHandlers();<br>
+}<br>
+<br>
+void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers) {<br>
+ CatchSwitchInst *CSI = unwrap<CatchSwitchInst>(CatchSwitch);<br>
+ for (CatchSwitchInst::handler_iterator I = CSI->handler_begin(),<br>
+ E = CSI->handler_end(); I != E; ++I)<br>
+ *Handlers++ = wrap(*I);<br>
+}<br>
+<br>
+LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad) {<br>
+ return wrap(unwrap<CatchPadInst>(CatchPad)->getCatchSwitch());<br>
+}<br>
+<br>
+void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad, LLVMValueRef CatchSwitch) {<br>
+ unwrap<CatchPadInst>(CatchPad)<br>
+ ->setCatchSwitch(unwrap<CatchSwitchInst>(CatchSwitch));<br>
+}<br>
+<br>
+/*--.. Funclets ...........................................................--*/<br>
+<br>
+LLVMValueRef LLVMGetArgOperand(LLVMValueRef Funclet, unsigned i) {<br>
+ return wrap(unwrap<FuncletPadInst>(Funclet)->getArgOperand(i));<br>
+}<br>
+<br>
+void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, LLVMValueRef value) {<br>
+ unwrap<FuncletPadInst>(Funclet)->setArgOperand(i, unwrap(value));<br>
+}<br>
+<br>
/*--.. Arithmetic ..........................................................--*/<br>
<br>
LLVMValueRef LLVMBuildAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS,<br>
<br>
Modified: llvm/trunk/test/Bindings/llvm-c/echo.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/llvm-c/echo.ll?rev=328759&r1=328758&r2=328759&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/llvm-c/echo.ll?rev=328759&r1=328758&r2=328759&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/Bindings/llvm-c/echo.ll (original)<br>
+++ llvm/trunk/test/Bindings/llvm-c/echo.ll Wed Mar 28 20:43:15 2018<br>
@@ -122,3 +122,38 @@ do:<br>
done:<br>
ret i32 %p<br>
}<br>
+<br>
+declare void @personalityFn()<br>
+<br>
+define void @exn() personality void ()* @personalityFn {<br>
+entry:<br>
+ invoke void @decl()<br>
+ to label %via.cleanup unwind label %exn.dispatch<br>
+via.cleanup:<br>
+ invoke void @decl()<br>
+ to label %via.catchswitch unwind label %cleanup.inner<br>
+cleanup.inner:<br>
+ %cp.inner = cleanuppad within none []<br>
+ cleanupret from %cp.inner unwind label %exn.dispatch<br>
+via.catchswitch:<br>
+ invoke void @decl()<br>
+ to label %exit unwind label %dispatch.inner<br>
+dispatch.inner:<br>
+ %cs.inner = catchswitch within none [label %pad.inner] unwind label %exn.dispatch<br>
+pad.inner:<br>
+ %catch.inner = catchpad within %cs.inner [i32 0]<br>
+ catchret from %catch.inner to label %exit<br>
+exn.dispatch:<br>
+ %cs = catchswitch within none [label %pad1, label %pad2] unwind label %cleanup<br>
+pad1:<br>
+ catchpad within %cs [i32 1]<br>
+ unreachable<br>
+pad2:<br>
+ catchpad within %cs [i32 2]<br>
+ unreachable<br>
+cleanup:<br>
+ %cp = cleanuppad within none []<br>
+ cleanupret from %cp unwind to caller<br>
+exit:<br>
+ ret void<br>
+}<br>
<br>
Modified: llvm/trunk/tools/llvm-c-test/echo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-c-test/echo.cpp?rev=328759&r1=328758&r2=328759&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-c-test/echo.cpp?rev=328759&r1=328758&r2=328759&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-c-test/echo.cpp (original)<br>
+++ llvm/trunk/tools/llvm-c-test/echo.cpp Wed Mar 28 20:43:15 2018<br>
@@ -146,8 +146,8 @@ struct TypeCloner {<br>
return LLVMMetadataTypeInContext(Ctx);<br>
case LLVMX86_MMXTypeKind:<br>
return LLVMX86MMXTypeInContext(Ctx);<br>
- default:<br>
- break;<br>
+ case LLVMTokenTypeKind:<br>
+ return LLVMTokenTypeInContext(Ctx);<br>
}<br>
<br>
fprintf(stderr, "%d is not a supported typekind\n", Kind);<br>
@@ -311,6 +311,13 @@ static LLVMValueRef clone_constant_impl(<br>
return LLVMGetUndef(TypeCloner(M).Clone(Cst));<br>
}<br>
<br>
+ // Try null<br>
+ if (LLVMIsNull(Cst)) {<br>
+ check_value_kind(Cst, LLVMConstantTokenNoneValueKind);<br>
+ LLVMTypeRef Ty = TypeCloner(M).Clone(Cst);<br>
+ return LLVMConstNull(Ty);<br>
+ }<br>
+<br>
// Try float literal<br>
if (LLVMIsAConstantFP(Cst)) {<br>
check_value_kind(Cst, LLVMConstantFPValueKind);<br>
@@ -631,6 +638,57 @@ struct FunCloner {<br>
LLVMSetCleanup(Dst, LLVMIsCleanup(Src));<br>
break;<br>
}<br>
+ case LLVMCleanupRet: {<br>
+ LLVMValueRef CatchPad = CloneValue(LLVMGetOperand(Src, 0));<br>
+ LLVMBasicBlockRef Unwind = nullptr;<br>
+ if (LLVMBasicBlockRef UDest = LLVMGetUnwindDest(Src))<br>
+ Unwind = DeclareBB(UDest);<br>
+ Dst = LLVMBuildCleanupRet(Builder, CatchPad, Unwind);<br>
+ break;<br>
+ }<br>
+ case LLVMCatchRet: {<br>
+ LLVMValueRef CatchPad = CloneValue(LLVMGetOperand(Src, 0));<br>
+ LLVMBasicBlockRef SuccBB = DeclareBB(LLVMGetSuccessor(Src, 0));<br>
+ Dst = LLVMBuildCatchRet(Builder, CatchPad, SuccBB);<br>
+ break;<br>
+ }<br>
+ case LLVMCatchPad: {<br>
+ LLVMValueRef ParentPad = CloneValue(LLVMGetParentCatchSwitch(Src));<br>
+ SmallVector<LLVMValueRef, 8> Args;<br>
+ int ArgCount = LLVMGetNumArgOperands(Src);<br>
+ for (int i = 0; i < ArgCount; i++)<br>
+ Args.push_back(CloneValue(LLVMGetOperand(Src, i)));<br>
+ Dst = LLVMBuildCatchPad(Builder, ParentPad,<br>
+ Args.data(), ArgCount, Name);<br>
+ break;<br>
+ }<br>
+ case LLVMCleanupPad: {<br>
+ LLVMValueRef ParentPad = CloneValue(LLVMGetOperand(Src, 0));<br>
+ SmallVector<LLVMValueRef, 8> Args;<br>
+ int ArgCount = LLVMGetNumArgOperands(Src);<br>
+ for (int i = 0; i < ArgCount; i++)<br>
+ Args.push_back(CloneValue(LLVMGetArgOperand(Src, i)));<br>
+ Dst = LLVMBuildCleanupPad(Builder, ParentPad,<br>
+ Args.data(), ArgCount, Name);<br>
+ break;<br>
+ }<br>
+ case LLVMCatchSwitch: {<br>
+ LLVMValueRef ParentPad = CloneValue(LLVMGetOperand(Src, 0));<br>
+ LLVMBasicBlockRef UnwindBB = nullptr;<br>
+ if (LLVMBasicBlockRef UDest = LLVMGetUnwindDest(Src)) {<br>
+ UnwindBB = DeclareBB(UDest);<br>
+ }<br>
+ unsigned NumHandlers = LLVMGetNumHandlers(Src);<br>
+ Dst = LLVMBuildCatchSwitch(Builder, ParentPad, UnwindBB, NumHandlers, Name);<br>
+ if (NumHandlers > 0) {<br>
+ LLVMBasicBlockRef *Handlers = static_cast<LLVMBasicBlockRef*>(<br>
+ safe_malloc(NumHandlers * sizeof(LLVMBasicBlockRef)));<br>
+ LLVMGetHandlers(Src, Handlers);<br>
+ for (unsigned i = 0; i < NumHandlers; i++)<br>
+ LLVMAddHandler(Dst, DeclareBB(Handlers[i]));<br>
+ }<br>
+ break;<br>
+ }<br>
case LLVMExtractValue: {<br>
LLVMValueRef Agg = CloneValue(LLVMGetOperand(Src, 0));<br>
if (LLVMGetNumIndices(Src) != 1)<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>