File tree Expand file tree Collapse file tree 3 files changed +4
-0
lines changed
compiler/rustc_codegen_llvm/src Expand file tree Collapse file tree 3 files changed +4
-0
lines changed Original file line number Diff line number Diff 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 ( ) ,
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 ,
You can’t perform that action at this time.
0 commit comments