Skip to content

Commit 153a920

Browse files
committed
added comments
1 parent ead21f6 commit 153a920

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

compiler/rustc_codegen_llvm/src/back/target_machine_wrapper.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ impl TargetMachineWrapper {
4545
"The last character must be a null terminator."
4646
);
4747

48+
// SAFETY: llvm::LLVMRustCreateTargetMachine copies pointed to data
4849
let tm_ptr = unsafe {
4950
llvm::LLVMRustCreateTargetMachine(
5051
triple.as_ptr(),

compiler/rustc_codegen_llvm/src/context.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ pub unsafe fn create_module<'ll>(
160160

161161
// Ensure the data-layout values hardcoded remain the defaults.
162162
if sess.target.is_builtin {
163+
// tm is disposed by its drop impl
163164
let tm = crate::back::write::create_informational_target_machine(tcx.sess);
164165
llvm::LLVMRustSetDataLayoutFromTargetMachine(llmod, &tm);
165166

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,6 +2112,8 @@ extern "C" {
21122112
);
21132113

21142114
pub fn LLVMRustGetHostCPUName(len: *mut usize) -> *const c_char;
2115+
2116+
// This function makes copies of pointed to data, so the data's lifetime may end after this function returns
21152117
pub fn LLVMRustCreateTargetMachine(
21162118
Triple: *const c_char,
21172119
CPU: *const c_char,

0 commit comments

Comments
 (0)