Skip to content

Commit 2e3a6af

Browse files
committed
rustc_codegen_llvm: use safe references for ThinLTOBuffer.
1 parent ab4f93c commit 2e3a6af

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/librustc_codegen_llvm/back/lto.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ impl Drop for ThinData {
579579
}
580580
}
581581

582-
pub struct ThinBuffer(*mut llvm::ThinLTOBuffer);
582+
pub struct ThinBuffer(&'static mut llvm::ThinLTOBuffer);
583583

584584
unsafe impl Send for ThinBuffer {}
585585
unsafe impl Sync for ThinBuffer {}
@@ -604,7 +604,7 @@ impl ThinBuffer {
604604
impl Drop for ThinBuffer {
605605
fn drop(&mut self) {
606606
unsafe {
607-
llvm::LLVMRustThinLTOBufferFree(self.0);
607+
llvm::LLVMRustThinLTOBufferFree(&mut *(self.0 as *mut _));
608608
}
609609
}
610610
}

src/librustc_codegen_llvm/llvm/ffi.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,10 +1571,10 @@ extern "C" {
15711571

15721572
pub fn LLVMRustThinLTOAvailable() -> bool;
15731573
pub fn LLVMRustPGOAvailable() -> bool;
1574-
pub fn LLVMRustThinLTOBufferCreate(M: &Module) -> *mut ThinLTOBuffer;
1575-
pub fn LLVMRustThinLTOBufferFree(M: *mut ThinLTOBuffer);
1576-
pub fn LLVMRustThinLTOBufferPtr(M: *const ThinLTOBuffer) -> *const c_char;
1577-
pub fn LLVMRustThinLTOBufferLen(M: *const ThinLTOBuffer) -> size_t;
1574+
pub fn LLVMRustThinLTOBufferCreate(M: &Module) -> &'static mut ThinLTOBuffer;
1575+
pub fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer);
1576+
pub fn LLVMRustThinLTOBufferPtr(M: &ThinLTOBuffer) -> *const c_char;
1577+
pub fn LLVMRustThinLTOBufferLen(M: &ThinLTOBuffer) -> size_t;
15781578
pub fn LLVMRustCreateThinLTOData(
15791579
Modules: *const ThinLTOModule,
15801580
NumModules: c_uint,

0 commit comments

Comments
 (0)