]> git.lizzy.rs Git - rust.git/commitdiff
document the implementation a bit more
authorJorge Aparicio <japaricious@gmail.com>
Thu, 6 Apr 2017 02:11:22 +0000 (21:11 -0500)
committerJorge Aparicio <japaricious@gmail.com>
Thu, 6 Apr 2017 02:11:22 +0000 (21:11 -0500)
src/librustc_trans/base.rs
src/librustc_trans/consts.rs
src/librustc_trans/context.rs
src/libsyntax/feature_gate.rs

index 378e1d7fc63f05b829b7a85181e77cfe859532ce..d204703b775983ec2b74f60407e796373cf357d7 100644 (file)
@@ -1187,7 +1187,8 @@ fn trans_def_task<'a, 'tcx>(ccx: CrateContext<'a, 'tcx>,
                 }
             }
 
-            // Create llvm.used variable
+            // Create the llvm.used variable
+            // This variable has type [N x i8*] and is stored in the llvm.metadata section
             if !ccx.used_statics().borrow().is_empty() {
                 let name = CString::new("llvm.used").unwrap();
                 let section = CString::new("llvm.metadata").unwrap();
index ae8c2433fed7560394bfecd99f95481934ac1d67..daf1a1ba95f9a175991e2877cf2c9e4d2b0d889e 100644 (file)
@@ -277,6 +277,7 @@ pub fn trans_static<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
         base::set_link_section(ccx, g, attrs);
 
         if attr::contains_name(attrs, "used") {
+            // This static will be stored in the llvm.used variable which is an array of i8*
             let cast = llvm::LLVMConstPointerCast(g, Type::i8p(ccx).to_ref());
             ccx.used_statics().borrow_mut().push(cast);
         }
index 2eca0a18e2b380520bcf30ae5097e240e1f2aba3..afb94f546abe894aeb9e001a8545e2bc51915803 100644 (file)
@@ -132,6 +132,8 @@ pub struct LocalCrateContext<'tcx> {
     /// to constants.)
     statics_to_rauw: RefCell<Vec<(ValueRef, ValueRef)>>,
 
+    /// Statics that will be placed in the llvm.used variable
+    /// See http://llvm.org/docs/LangRef.html#the-llvm-used-global-variable for details
     used_statics: RefCell<Vec<ValueRef>>,
 
     lltypes: RefCell<FxHashMap<Ty<'tcx>, Type>>,
index 66a813025c4376bebeda76bcef2a594bf3cc4a21..5f7190012038621f0e3652723fd3927292cf3678 100644 (file)
@@ -344,8 +344,8 @@ pub fn new() -> Features {
     // See rust-lang/rfcs#1414. Allows code like `let x: &'static u32 = &42` to work.
     (active, rvalue_static_promotion, "1.15.1", Some(38865)),
 
-    // Used to preserve symbols
-    (active, used, "1.18.0", None),
+    // Used to preserve symbols (see llvm.used)
+    (active, used, "1.18.0", Some(40289)),
 );
 
 declare_features! (