Skip to content

Commit a54bfcf

Browse files
committed
Use safe FFI for various functions in codegen_llvm
1 parent bb029a1 commit a54bfcf

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

compiler/rustc_codegen_llvm/src/builder.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@ impl<'a, 'll, CX: Borrow<SimpleCx<'ll>>> GenericBuilder<'a, 'll, CX> {
100100
}
101101

102102
fn ret_void(&mut self) {
103-
unsafe {
104-
llvm::LLVMBuildRetVoid(self.llbuilder);
105-
}
103+
llvm::LLVMBuildRetVoid(self.llbuilder);
106104
}
107105

108106
fn ret(&mut self, v: &'ll Value) {
@@ -293,9 +291,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
293291
}
294292

295293
fn ret_void(&mut self) {
296-
unsafe {
297-
llvm::LLVMBuildRetVoid(self.llbuilder);
298-
}
294+
llvm::LLVMBuildRetVoid(self.llbuilder);
299295
}
300296

301297
fn ret(&mut self, v: &'ll Value) {

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,7 @@ unsafe extern "C" {
12041204
pub(crate) fn LLVMGetCurrentDebugLocation2<'a>(Builder: &Builder<'a>) -> Option<&'a Metadata>;
12051205

12061206
// Terminators
1207-
pub(crate) fn LLVMBuildRetVoid<'a>(B: &Builder<'a>) -> &'a Value;
1207+
pub(crate) safe fn LLVMBuildRetVoid<'a>(B: &Builder<'a>) -> &'a Value;
12081208
pub(crate) fn LLVMBuildRet<'a>(B: &Builder<'a>, V: &'a Value) -> &'a Value;
12091209
pub(crate) fn LLVMBuildBr<'a>(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value;
12101210
pub(crate) fn LLVMBuildCondBr<'a>(

0 commit comments

Comments
 (0)