diff options
| author | Amanieu d'Antras <amanieu@gmail.com> | 2022-03-01 00:53:25 +0000 |
|---|---|---|
| committer | Amanieu d'Antras <amanieu@gmail.com> | 2022-04-15 14:36:30 +0100 |
| commit | 547405e80120117f3299d7271c839455bb670ad6 (patch) | |
| tree | 3437956c69eb10d3adb841ab126d374d305327fb /compiler/rustc_codegen_llvm/src/base.rs | |
| parent | dc345d8bffdd95c65ba537c32a6900b8c19c049d (diff) | |
| download | rust-547405e80120117f3299d7271c839455bb670ad6.tar.gz rust-547405e80120117f3299d7271c839455bb670ad6.zip | |
Add codegen for global_asm! sym operands
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/base.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/base.rs | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/compiler/rustc_codegen_llvm/src/base.rs b/compiler/rustc_codegen_llvm/src/base.rs index dd3ada44389..c163c7d8692 100644 --- a/compiler/rustc_codegen_llvm/src/base.rs +++ b/compiler/rustc_codegen_llvm/src/base.rs @@ -99,15 +99,6 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol) -> (ModuleCodegen attributes::apply_to_llfn(entry, llvm::AttributePlace::Function, &attrs); } - // Run replace-all-uses-with for statics that need it - for &(old_g, new_g) in cx.statics_to_rauw().borrow().iter() { - unsafe { - let bitcast = llvm::LLVMConstPointerCast(new_g, cx.val_ty(old_g)); - llvm::LLVMReplaceAllUsesWith(old_g, bitcast); - llvm::LLVMDeleteGlobal(old_g); - } - } - // Finalize code coverage by injecting the coverage map. Note, the coverage map will // also be added to the `llvm.compiler.used` variable, created next. if cx.sess().instrument_coverage() { @@ -122,6 +113,16 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol) -> (ModuleCodegen cx.create_compiler_used_variable() } + // Run replace-all-uses-with for statics that need it. This must + // happen after the llvm.used variables are created. + for &(old_g, new_g) in cx.statics_to_rauw().borrow().iter() { + unsafe { + let bitcast = llvm::LLVMConstPointerCast(new_g, cx.val_ty(old_g)); + llvm::LLVMReplaceAllUsesWith(old_g, bitcast); + llvm::LLVMDeleteGlobal(old_g); + } + } + // Finalize debuginfo if cx.sess().opts.debuginfo != DebugInfo::None { cx.debuginfo_finalize(); |
