Skip to content

Commit cc77ae0

Browse files
committed
Use existing llvm methods, instead of rust wrappers for:
LLVMRustBuildCleanupPad -> LLVMBuildCleanupPad LLVMRustBuildCleanupRet -> LLVMBuildCleanupRet LLVMRustBuildCatchPad -> LLVMBuildCatchPad LLVMRustBuildCatchRet -> LLVMBuildCatchRet LLVMRustBuildCatchSwitch -> LLVMBuildCatchSwitch
1 parent 076116b commit cc77ae0

File tree

3 files changed

+17
-67
lines changed

3 files changed

+17
-67
lines changed

compiler/rustc_codegen_llvm/src/builder.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -1001,11 +1001,11 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
10011001
fn cleanup_pad(&mut self, parent: Option<&'ll Value>, args: &[&'ll Value]) -> Funclet<'ll> {
10021002
let name = cstr!("cleanuppad");
10031003
let ret = unsafe {
1004-
llvm::LLVMRustBuildCleanupPad(
1004+
llvm::LLVMBuildCleanupPad(
10051005
self.llbuilder,
10061006
parent,
1007-
args.len() as c_uint,
10081007
args.as_ptr(),
1008+
args.len() as c_uint,
10091009
name.as_ptr(),
10101010
)
10111011
};
@@ -1014,19 +1014,19 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
10141014

10151015
fn cleanup_ret(&mut self, funclet: &Funclet<'ll>, unwind: Option<&'ll BasicBlock>) {
10161016
unsafe {
1017-
llvm::LLVMRustBuildCleanupRet(self.llbuilder, funclet.cleanuppad(), unwind)
1017+
llvm::LLVMBuildCleanupRet(self.llbuilder, funclet.cleanuppad(), unwind)
10181018
.expect("LLVM does not have support for cleanupret");
10191019
}
10201020
}
10211021

10221022
fn catch_pad(&mut self, parent: &'ll Value, args: &[&'ll Value]) -> Funclet<'ll> {
10231023
let name = cstr!("catchpad");
10241024
let ret = unsafe {
1025-
llvm::LLVMRustBuildCatchPad(
1025+
llvm::LLVMBuildCatchPad(
10261026
self.llbuilder,
10271027
parent,
1028-
args.len() as c_uint,
10291028
args.as_ptr(),
1029+
args.len() as c_uint,
10301030
name.as_ptr(),
10311031
)
10321032
};
@@ -1041,7 +1041,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
10411041
) -> &'ll Value {
10421042
let name = cstr!("catchswitch");
10431043
let ret = unsafe {
1044-
llvm::LLVMRustBuildCatchSwitch(
1044+
llvm::LLVMBuildCatchSwitch(
10451045
self.llbuilder,
10461046
parent,
10471047
unwind,
@@ -1376,8 +1376,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
13761376
}
13771377

13781378
pub fn catch_ret(&mut self, funclet: &Funclet<'ll>, unwind: &'ll BasicBlock) -> &'ll Value {
1379-
let ret =
1380-
unsafe { llvm::LLVMRustBuildCatchRet(self.llbuilder, funclet.cleanuppad(), unwind) };
1379+
let ret = unsafe { llvm::LLVMBuildCatchRet(self.llbuilder, funclet.cleanuppad(), unwind) };
13811380
ret.expect("LLVM does not have support for catchret")
13821381
}
13831382

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -1298,34 +1298,34 @@ extern "C" {
12981298
pub fn LLVMBuildResume<'a>(B: &Builder<'a>, Exn: &'a Value) -> &'a Value;
12991299
pub fn LLVMBuildUnreachable<'a>(B: &Builder<'a>) -> &'a Value;
13001300

1301-
pub fn LLVMRustBuildCleanupPad<'a>(
1301+
pub fn LLVMBuildCleanupPad<'a>(
13021302
B: &Builder<'a>,
13031303
ParentPad: Option<&'a Value>,
1304-
ArgCnt: c_uint,
13051304
Args: *const &'a Value,
1305+
NumArgs: c_uint,
13061306
Name: *const c_char,
13071307
) -> Option<&'a Value>;
1308-
pub fn LLVMRustBuildCleanupRet<'a>(
1308+
pub fn LLVMBuildCleanupRet<'a>(
13091309
B: &Builder<'a>,
13101310
CleanupPad: &'a Value,
1311-
UnwindBB: Option<&'a BasicBlock>,
1311+
BB: Option<&'a BasicBlock>,
13121312
) -> Option<&'a Value>;
1313-
pub fn LLVMRustBuildCatchPad<'a>(
1313+
pub fn LLVMBuildCatchPad<'a>(
13141314
B: &Builder<'a>,
13151315
ParentPad: &'a Value,
1316-
ArgCnt: c_uint,
13171316
Args: *const &'a Value,
1317+
NumArgs: c_uint,
13181318
Name: *const c_char,
13191319
) -> Option<&'a Value>;
1320-
pub fn LLVMRustBuildCatchRet<'a>(
1320+
pub fn LLVMBuildCatchRet<'a>(
13211321
B: &Builder<'a>,
1322-
Pad: &'a Value,
1322+
CatchPad: &'a Value,
13231323
BB: &'a BasicBlock,
13241324
) -> Option<&'a Value>;
1325-
pub fn LLVMRustBuildCatchSwitch<'a>(
1325+
pub fn LLVMBuildCatchSwitch<'a>(
13261326
Builder: &Builder<'a>,
13271327
ParentPad: Option<&'a Value>,
1328-
BB: Option<&'a BasicBlock>,
1328+
UnwindBB: Option<&'a BasicBlock>,
13291329
NumHandlers: c_uint,
13301330
Name: *const c_char,
13311331
) -> Option<&'a Value>;

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

-49
Original file line numberDiff line numberDiff line change
@@ -1394,55 +1394,6 @@ extern "C" bool LLVMRustUnpackSMDiagnostic(LLVMSMDiagnosticRef DRef,
13941394
return true;
13951395
}
13961396

1397-
extern "C" LLVMValueRef LLVMRustBuildCleanupPad(LLVMBuilderRef B,
1398-
LLVMValueRef ParentPad,
1399-
unsigned ArgCount,
1400-
LLVMValueRef *LLArgs,
1401-
const char *Name) {
1402-
Value **Args = unwrap(LLArgs);
1403-
if (ParentPad == nullptr) {
1404-
Type *Ty = Type::getTokenTy(unwrap(B)->getContext());
1405-
ParentPad = wrap(Constant::getNullValue(Ty));
1406-
}
1407-
return wrap(unwrap(B)->CreateCleanupPad(
1408-
unwrap(ParentPad), ArrayRef<Value *>(Args, ArgCount), Name));
1409-
}
1410-
1411-
extern "C" LLVMValueRef LLVMRustBuildCleanupRet(LLVMBuilderRef B,
1412-
LLVMValueRef CleanupPad,
1413-
LLVMBasicBlockRef UnwindBB) {
1414-
CleanupPadInst *Inst = cast<CleanupPadInst>(unwrap(CleanupPad));
1415-
return wrap(unwrap(B)->CreateCleanupRet(Inst, unwrap(UnwindBB)));
1416-
}
1417-
1418-
extern "C" LLVMValueRef
1419-
LLVMRustBuildCatchPad(LLVMBuilderRef B, LLVMValueRef ParentPad,
1420-
unsigned ArgCount, LLVMValueRef *LLArgs, const char *Name) {
1421-
Value **Args = unwrap(LLArgs);
1422-
return wrap(unwrap(B)->CreateCatchPad(
1423-
unwrap(ParentPad), ArrayRef<Value *>(Args, ArgCount), Name));
1424-
}
1425-
1426-
extern "C" LLVMValueRef LLVMRustBuildCatchRet(LLVMBuilderRef B,
1427-
LLVMValueRef Pad,
1428-
LLVMBasicBlockRef BB) {
1429-
return wrap(unwrap(B)->CreateCatchRet(cast<CatchPadInst>(unwrap(Pad)),
1430-
unwrap(BB)));
1431-
}
1432-
1433-
extern "C" LLVMValueRef LLVMRustBuildCatchSwitch(LLVMBuilderRef B,
1434-
LLVMValueRef ParentPad,
1435-
LLVMBasicBlockRef BB,
1436-
unsigned NumHandlers,
1437-
const char *Name) {
1438-
if (ParentPad == nullptr) {
1439-
Type *Ty = Type::getTokenTy(unwrap(B)->getContext());
1440-
ParentPad = wrap(Constant::getNullValue(Ty));
1441-
}
1442-
return wrap(unwrap(B)->CreateCatchSwitch(unwrap(ParentPad), unwrap(BB),
1443-
NumHandlers, Name));
1444-
}
1445-
14461397
extern "C" void LLVMRustAddHandler(LLVMValueRef CatchSwitchRef,
14471398
LLVMBasicBlockRef Handler) {
14481399
Value *CatchSwitch = unwrap(CatchSwitchRef);

0 commit comments

Comments
 (0)