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 {
45
45
"The last character must be a null terminator."
46
46
) ;
47
47
48
+ // SAFETY: llvm::LLVMRustCreateTargetMachine copies pointed to data
48
49
let tm_ptr = unsafe {
49
50
llvm:: LLVMRustCreateTargetMachine (
50
51
triple. as_ptr ( ) ,
Original file line number Diff line number Diff line change @@ -160,6 +160,7 @@ pub unsafe fn create_module<'ll>(
160
160
161
161
// Ensure the data-layout values hardcoded remain the defaults.
162
162
if sess. target . is_builtin {
163
+ // tm is disposed by its drop impl
163
164
let tm = crate :: back:: write:: create_informational_target_machine ( tcx. sess ) ;
164
165
llvm:: LLVMRustSetDataLayoutFromTargetMachine ( llmod, & tm) ;
165
166
Original file line number Diff line number Diff line change @@ -2112,6 +2112,8 @@ extern "C" {
2112
2112
) ;
2113
2113
2114
2114
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
2115
2117
pub fn LLVMRustCreateTargetMachine (
2116
2118
Triple : * const c_char ,
2117
2119
CPU : * const c_char ,
You can’t perform that action at this time.
0 commit comments