1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

Revert "[LLVM-C] Finish exception instruction bindings"

This reverts commit r328759. It was causing LSan failures on sanitizer-x86_64-linux-bootstrap

llvm-svn: 328858
This commit is contained in:
Vlad Tsyrklevich 2018-03-30 06:21:28 +00:00
parent a24a5d9000
commit 9736436bca
4 changed files with 10 additions and 260 deletions

View File

@ -2555,12 +2555,11 @@ LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);
/**
* Obtain the argument count for a call instruction.
*
* This expects an LLVMValueRef that corresponds to a llvm::CallInst,
* llvm::InvokeInst, or llvm:FuncletPadInst.
* This expects an LLVMValueRef that corresponds to a llvm::CallInst or
* llvm::InvokeInst.
*
* @see llvm::CallInst::getNumArgOperands()
* @see llvm::InvokeInst::getNumArgOperands()
* @see llvm::FuncletPadInst::getNumArgOperands()
*/
unsigned LLVMGetNumArgOperands(LLVMValueRef Instr);
@ -2645,12 +2644,9 @@ LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef InvokeInst);
/**
* Return the unwind destination basic block.
*
* Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
* llvm::CatchSwitchInst instructions.
* This only works on llvm::InvokeInst instructions.
*
* @see llvm::InvokeInst::getUnwindDest()
* @see llvm::CleanupReturnInst::getUnwindDest()
* @see llvm::CatchSwitchInst::getUnwindDest()
*/
LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef InvokeInst);
@ -2666,12 +2662,9 @@ void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
/**
* Set the unwind destination basic block.
*
* Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
* llvm::CatchSwitchInst instructions.
* This only works on llvm::InvokeInst instructions.
*
* @see llvm::InvokeInst::setUnwindDest()
* @see llvm::CleanupReturnInst::setUnwindDest()
* @see llvm::CatchSwitchInst::setUnwindDest()
*/
void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
@ -2900,26 +2893,11 @@ 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 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);
LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
/* Add a case to the switch instruction */
void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
@ -2943,51 +2921,6 @@ 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);

View File

@ -2196,15 +2196,12 @@ LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst) {
return nullptr;
}
/*--.. Call and invoke instructions ........................................--*/
unsigned LLVMGetNumArgOperands(LLVMValueRef Instr) {
if (FuncletPadInst *FPI = dyn_cast<FuncletPadInst>(unwrap(Instr))) {
return FPI->getNumArgOperands();
}
return CallSite(unwrap<Instruction>(Instr)).getNumArgOperands();
}
/*--.. Call and invoke instructions ........................................--*/
unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr) {
return CallSite(unwrap<Instruction>(Instr)).getCallingConv();
}
@ -2287,11 +2284,6 @@ LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef Invoke) {
}
LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef Invoke) {
if (CleanupReturnInst *CRI = dyn_cast<CleanupReturnInst>(unwrap(Invoke))) {
return wrap(CRI->getUnwindDest());
} else if (CatchSwitchInst *CSI = dyn_cast<CatchSwitchInst>(unwrap(Invoke))) {
return wrap(CSI->getUnwindDest());
}
return wrap(unwrap<InvokeInst>(Invoke)->getUnwindDest());
}
@ -2300,11 +2292,6 @@ void LLVMSetNormalDest(LLVMValueRef Invoke, LLVMBasicBlockRef B) {
}
void LLVMSetUnwindDest(LLVMValueRef Invoke, LLVMBasicBlockRef B) {
if (CleanupReturnInst *CRI = dyn_cast<CleanupReturnInst>(unwrap(Invoke))) {
return CRI->setUnwindDest(unwrap(B));
} else if (CatchSwitchInst *CSI = dyn_cast<CatchSwitchInst>(unwrap(Invoke))) {
return CSI->setUnwindDest(unwrap(B));
}
unwrap<InvokeInst>(Invoke)->setUnwindDest(unwrap(B));
}
@ -2526,53 +2513,10 @@ LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
return wrap(unwrap(B)->CreateLandingPad(unwrap(Ty), NumClauses, Name));
}
LLVMValueRef LLVMBuildCatchPad(LLVMBuilderRef B, LLVMValueRef ParentPad,
LLVMValueRef *Args, unsigned NumArgs,
const char *Name) {
return wrap(unwrap(B)->CreateCatchPad(unwrap(ParentPad),
makeArrayRef(unwrap(Args), NumArgs),
Name));
}
LLVMValueRef LLVMBuildCleanupPad(LLVMBuilderRef B, LLVMValueRef ParentPad,
LLVMValueRef *Args, unsigned NumArgs,
const char *Name) {
if (ParentPad == nullptr) {
Type *Ty = Type::getTokenTy(unwrap(B)->getContext());
ParentPad = wrap(Constant::getNullValue(Ty));
}
return wrap(unwrap(B)->CreateCleanupPad(unwrap(ParentPad),
makeArrayRef(unwrap(Args), NumArgs),
Name));
}
LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn) {
return wrap(unwrap(B)->CreateResume(unwrap(Exn)));
}
LLVMValueRef LLVMBuildCatchSwitch(LLVMBuilderRef B, LLVMValueRef ParentPad,
LLVMBasicBlockRef UnwindBB,
unsigned NumHandlers, const char *Name) {
if (ParentPad == nullptr) {
Type *Ty = Type::getTokenTy(unwrap(B)->getContext());
ParentPad = wrap(Constant::getNullValue(Ty));
}
return wrap(unwrap(B)->CreateCatchSwitch(unwrap(ParentPad), unwrap(UnwindBB),
NumHandlers, Name));
}
LLVMValueRef LLVMBuildCatchRet(LLVMBuilderRef B, LLVMValueRef CatchPad,
LLVMBasicBlockRef BB) {
return wrap(unwrap(B)->CreateCatchRet(unwrap<CatchPadInst>(CatchPad),
unwrap(BB)));
}
LLVMValueRef LLVMBuildCleanupRet(LLVMBuilderRef B, LLVMValueRef CatchPad,
LLVMBasicBlockRef BB) {
return wrap(unwrap(B)->CreateCleanupRet(unwrap<CleanupPadInst>(CatchPad),
unwrap(BB)));
}
LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef B) {
return wrap(unwrap(B)->CreateUnreachable());
}
@ -2607,40 +2551,6 @@ void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val) {
unwrap<LandingPadInst>(LandingPad)->setCleanup(Val);
}
void LLVMAddHandler(LLVMValueRef CatchSwitch, LLVMBasicBlockRef Dest) {
unwrap<CatchSwitchInst>(CatchSwitch)->addHandler(unwrap(Dest));
}
unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch) {
return unwrap<CatchSwitchInst>(CatchSwitch)->getNumHandlers();
}
void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers) {
CatchSwitchInst *CSI = unwrap<CatchSwitchInst>(CatchSwitch);
for (CatchSwitchInst::handler_iterator I = CSI->handler_begin(),
E = CSI->handler_end(); I != E; ++I)
*Handlers++ = wrap(*I);
}
LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad) {
return wrap(unwrap<CatchPadInst>(CatchPad)->getCatchSwitch());
}
void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad, LLVMValueRef CatchSwitch) {
unwrap<CatchPadInst>(CatchPad)
->setCatchSwitch(unwrap<CatchSwitchInst>(CatchSwitch));
}
/*--.. Funclets ...........................................................--*/
LLVMValueRef LLVMGetArgOperand(LLVMValueRef Funclet, unsigned i) {
return wrap(unwrap<FuncletPadInst>(Funclet)->getArgOperand(i));
}
void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, LLVMValueRef value) {
unwrap<FuncletPadInst>(Funclet)->setArgOperand(i, unwrap(value));
}
/*--.. Arithmetic ..........................................................--*/
LLVMValueRef LLVMBuildAdd(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS,

View File

@ -122,38 +122,3 @@ do:
done:
ret i32 %p
}
declare void @personalityFn()
define void @exn() personality void ()* @personalityFn {
entry:
invoke void @decl()
to label %via.cleanup unwind label %exn.dispatch
via.cleanup:
invoke void @decl()
to label %via.catchswitch unwind label %cleanup.inner
cleanup.inner:
%cp.inner = cleanuppad within none []
cleanupret from %cp.inner unwind label %exn.dispatch
via.catchswitch:
invoke void @decl()
to label %exit unwind label %dispatch.inner
dispatch.inner:
%cs.inner = catchswitch within none [label %pad.inner] unwind label %exn.dispatch
pad.inner:
%catch.inner = catchpad within %cs.inner [i32 0]
catchret from %catch.inner to label %exit
exn.dispatch:
%cs = catchswitch within none [label %pad1, label %pad2] unwind label %cleanup
pad1:
catchpad within %cs [i32 1]
unreachable
pad2:
catchpad within %cs [i32 2]
unreachable
cleanup:
%cp = cleanuppad within none []
cleanupret from %cp unwind to caller
exit:
ret void
}

View File

@ -146,8 +146,8 @@ struct TypeCloner {
return LLVMMetadataTypeInContext(Ctx);
case LLVMX86_MMXTypeKind:
return LLVMX86MMXTypeInContext(Ctx);
case LLVMTokenTypeKind:
return LLVMTokenTypeInContext(Ctx);
default:
break;
}
fprintf(stderr, "%d is not a supported typekind\n", Kind);
@ -311,13 +311,6 @@ static LLVMValueRef clone_constant_impl(LLVMValueRef Cst, LLVMModuleRef M) {
return LLVMGetUndef(TypeCloner(M).Clone(Cst));
}
// Try null
if (LLVMIsNull(Cst)) {
check_value_kind(Cst, LLVMConstantTokenNoneValueKind);
LLVMTypeRef Ty = TypeCloner(M).Clone(Cst);
return LLVMConstNull(Ty);
}
// Try float literal
if (LLVMIsAConstantFP(Cst)) {
check_value_kind(Cst, LLVMConstantFPValueKind);
@ -638,57 +631,6 @@ struct FunCloner {
LLVMSetCleanup(Dst, LLVMIsCleanup(Src));
break;
}
case LLVMCleanupRet: {
LLVMValueRef CatchPad = CloneValue(LLVMGetOperand(Src, 0));
LLVMBasicBlockRef Unwind = nullptr;
if (LLVMBasicBlockRef UDest = LLVMGetUnwindDest(Src))
Unwind = DeclareBB(UDest);
Dst = LLVMBuildCleanupRet(Builder, CatchPad, Unwind);
break;
}
case LLVMCatchRet: {
LLVMValueRef CatchPad = CloneValue(LLVMGetOperand(Src, 0));
LLVMBasicBlockRef SuccBB = DeclareBB(LLVMGetSuccessor(Src, 0));
Dst = LLVMBuildCatchRet(Builder, CatchPad, SuccBB);
break;
}
case LLVMCatchPad: {
LLVMValueRef ParentPad = CloneValue(LLVMGetParentCatchSwitch(Src));
SmallVector<LLVMValueRef, 8> Args;
int ArgCount = LLVMGetNumArgOperands(Src);
for (int i = 0; i < ArgCount; i++)
Args.push_back(CloneValue(LLVMGetOperand(Src, i)));
Dst = LLVMBuildCatchPad(Builder, ParentPad,
Args.data(), ArgCount, Name);
break;
}
case LLVMCleanupPad: {
LLVMValueRef ParentPad = CloneValue(LLVMGetOperand(Src, 0));
SmallVector<LLVMValueRef, 8> Args;
int ArgCount = LLVMGetNumArgOperands(Src);
for (int i = 0; i < ArgCount; i++)
Args.push_back(CloneValue(LLVMGetArgOperand(Src, i)));
Dst = LLVMBuildCleanupPad(Builder, ParentPad,
Args.data(), ArgCount, Name);
break;
}
case LLVMCatchSwitch: {
LLVMValueRef ParentPad = CloneValue(LLVMGetOperand(Src, 0));
LLVMBasicBlockRef UnwindBB = nullptr;
if (LLVMBasicBlockRef UDest = LLVMGetUnwindDest(Src)) {
UnwindBB = DeclareBB(UDest);
}
unsigned NumHandlers = LLVMGetNumHandlers(Src);
Dst = LLVMBuildCatchSwitch(Builder, ParentPad, UnwindBB, NumHandlers, Name);
if (NumHandlers > 0) {
LLVMBasicBlockRef *Handlers = static_cast<LLVMBasicBlockRef*>(
safe_malloc(NumHandlers * sizeof(LLVMBasicBlockRef)));
LLVMGetHandlers(Src, Handlers);
for (unsigned i = 0; i < NumHandlers; i++)
LLVMAddHandler(Dst, DeclareBB(Handlers[i]));
}
break;
}
case LLVMExtractValue: {
LLVMValueRef Agg = CloneValue(LLVMGetOperand(Src, 0));
if (LLVMGetNumIndices(Src) != 1)