Skip to content

Commit 86a71bf

Browse files
committed
Sync from rust 17c1167
2 parents b2796ec + 5a7ce46 commit 86a71bf

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ target-lexicon = "0.12.0"
2525
gimli = { version = "0.27.2", default-features = false, features = ["write"]}
2626
object = { version = "0.30.3", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }
2727

28-
indexmap = "1.9.1"
28+
indexmap = "1.9.3"
2929
libloading = { version = "0.7.3", optional = true }
3030
once_cell = "1.10.0"
3131
smallvec = "1.8.1"

src/constant.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,22 @@ pub(crate) fn codegen_tls_ref<'tcx>(
5454
def_id: DefId,
5555
layout: TyAndLayout<'tcx>,
5656
) -> CValue<'tcx> {
57-
let data_id = data_id_for_static(fx.tcx, fx.module, def_id, false);
58-
let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func);
59-
if fx.clif_comments.enabled() {
60-
fx.add_comment(local_data_id, format!("tls {:?}", def_id));
61-
}
62-
let tls_ptr = fx.bcx.ins().tls_value(fx.pointer_type, local_data_id);
57+
let tls_ptr = if !def_id.is_local() && fx.tcx.needs_thread_local_shim(def_id) {
58+
let instance = ty::Instance {
59+
def: ty::InstanceDef::ThreadLocalShim(def_id),
60+
substs: ty::InternalSubsts::empty(),
61+
};
62+
let func_ref = fx.get_function_ref(instance);
63+
let call = fx.bcx.ins().call(func_ref, &[]);
64+
fx.bcx.func.dfg.first_result(call)
65+
} else {
66+
let data_id = data_id_for_static(fx.tcx, fx.module, def_id, false);
67+
let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func);
68+
if fx.clif_comments.enabled() {
69+
fx.add_comment(local_data_id, format!("tls {:?}", def_id));
70+
}
71+
fx.bcx.ins().tls_value(fx.pointer_type, local_data_id)
72+
};
6373
CValue::by_val(tls_ptr, layout)
6474
}
6575

0 commit comments

Comments
 (0)