use type_::Type;
use type_of;
use rustc::ty;
-use context::get_tls_model;
use rustc::hir;
for attr in attrs {
if attr.check_name("thread_local") {
- llvm::set_thread_local_mode(g, get_tls_model(ccx.sess()));
+ llvm::set_thread_local_mode(g, ccx.tls_model());
}
}
// symbol and another one doesn't.
for attr in ccx.tcx().get_attrs(def_id).iter() {
if attr.check_name("thread_local") {
- llvm::set_thread_local_mode(g, get_tls_model(ccx.sess()));
+ llvm::set_thread_local_mode(g, ccx.tls_model());
}
}
if ccx.use_dll_storage_attrs() && !ccx.tcx().is_foreign_item(def_id) {
debuginfo::create_global_var_metadata(ccx, id, g);
if attr::contains_name(attrs, "thread_local") {
- llvm::set_thread_local_mode(g, get_tls_model(ccx.sess()));
+ llvm::set_thread_local_mode(g, ccx.tls_model());
}
base::set_link_section(ccx, g, attrs);
tcx: TyCtxt<'a, 'tcx, 'tcx>,
check_overflow: bool,
use_dll_storage_attrs: bool,
+ tls_model: llvm::ThreadLocalMode,
}
/// The local portion of a `CrateContext`. There is one `LocalCrateContext`
}
}
-pub fn get_tls_model(sess: &Session) -> llvm::ThreadLocalMode {
+fn get_tls_model(sess: &Session) -> llvm::ThreadLocalMode {
let tls_model_arg = match sess.opts.cg.tls_model {
Some(ref s) => &s[..],
None => &sess.target.target.options.tls_model[..],
let check_overflow = tcx.sess.overflow_checks();
+ let tls_model = get_tls_model(&tcx.sess);
+
SharedCrateContext {
tcx,
check_overflow,
use_dll_storage_attrs,
+ tls_model,
}
}
self.shared.use_dll_storage_attrs()
}
+ pub fn tls_model(&self) -> llvm::ThreadLocalMode {
+ self.shared.tls_model
+ }
+
/// Generate a new symbol name with the given prefix. This symbol name must
/// only be used for definitions with `internal` or `private` linkage.
pub fn generate_local_symbol_name(&self, prefix: &str) -> String {