Skip to content

Commit 1363cda

Browse files
committed
Remove unnecessary LLVMRustPersonalityFn binding
LLVM Core C bindings provide this function for all the versions back to what we support (3.7), and helps to avoid this unnecessary builder->function transition every time. Also a negative diff.
1 parent 07fe04c commit 1363cda

File tree

4 files changed

+5
-11
lines changed

4 files changed

+5
-11
lines changed

src/librustc_llvm/ffi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ extern "C" {
804804
Name: *const c_char)
805805
-> ValueRef;
806806
pub fn LLVMRustAddHandler(CatchSwitch: ValueRef, Handler: BasicBlockRef);
807-
pub fn LLVMRustSetPersonalityFn(B: BuilderRef, Pers: ValueRef);
807+
pub fn LLVMSetPersonalityFn(Func: ValueRef, Pers: ValueRef);
808808

809809
// Add a case to the switch instruction
810810
pub fn LLVMAddCase(Switch: ValueRef, OnVal: ValueRef, Dest: BasicBlockRef);

src/librustc_trans/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
11071107

11081108
pub fn set_personality_fn(&self, personality: ValueRef) {
11091109
unsafe {
1110-
llvm::LLVMRustSetPersonalityFn(self.llbuilder, personality);
1110+
llvm::LLVMSetPersonalityFn(self.llfn(), personality);
11111111
}
11121112
}
11131113

src/librustc_trans/mir/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,9 @@ pub fn trans_mir<'a, 'tcx: 'a>(
319319
mircx.cleanup_kinds.iter_enumerated().map(|(bb, cleanup_kind)| {
320320
if let CleanupKind::Funclet = *cleanup_kind {
321321
let bcx = mircx.get_builder(bb);
322-
bcx.set_personality_fn(mircx.ccx.eh_personality());
322+
unsafe {
323+
llvm::LLVMSetPersonalityFn(mircx.llfn, mircx.ccx.eh_personality());
324+
}
323325
if base::wants_msvc_seh(ccx.sess()) {
324326
return Some(Funclet::new(bcx.cleanup_pad(None, &[])));
325327
}

src/rustllvm/RustWrapper.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -1082,14 +1082,6 @@ extern "C" void LLVMRustAddHandler(LLVMValueRef CatchSwitchRef,
10821082
#endif
10831083
}
10841084

1085-
extern "C" void LLVMRustSetPersonalityFn(LLVMBuilderRef B,
1086-
LLVMValueRef Personality) {
1087-
#if LLVM_VERSION_GE(3, 8)
1088-
unwrap(B)->GetInsertBlock()->getParent()->setPersonalityFn(
1089-
cast<Function>(unwrap(Personality)));
1090-
#endif
1091-
}
1092-
10931085
#if LLVM_VERSION_GE(3, 8)
10941086
extern "C" OperandBundleDef *LLVMRustBuildOperandBundleDef(const char *Name,
10951087
LLVMValueRef *Inputs,

0 commit comments

Comments
 (0)