diff options
Diffstat (limited to 'src/librustc_codegen_llvm/consts.rs')
| -rw-r--r-- | src/librustc_codegen_llvm/consts.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/librustc_codegen_llvm/consts.rs b/src/librustc_codegen_llvm/consts.rs index 90887b760fb..c954415f19f 100644 --- a/src/librustc_codegen_llvm/consts.rs +++ b/src/librustc_codegen_llvm/consts.rs @@ -493,10 +493,14 @@ impl StaticMethods for CodegenCx<'ll, 'tcx> { } if attrs.flags.contains(CodegenFnAttrFlags::USED) { - // This static will be stored in the llvm.used variable which is an array of i8* - let cast = llvm::LLVMConstPointerCast(g, self.type_i8p()); - self.used_statics.borrow_mut().push(cast); + self.add_used_global(g); } } } + + /// Add a global value to a list to be stored in the `llvm.used` variable, an array of i8*. + fn add_used_global(&self, global: &'ll Value) { + let cast = unsafe { llvm::LLVMConstPointerCast(global, self.type_i8p()) }; + self.used_statics.borrow_mut().push(cast); + } } |
