Skip to content

Commit 3f0036a

Browse files
borsnotriddle
authored andcommitted
Auto merge of #139385 - joboet:threadlocal_address, r=nikic
rustc_codegen_llvm: use `threadlocal.address` intrinsic to access TLS Fixes #136044 r? `@nikic`
2 parents aa5832b + e4d9b06 commit 3f0036a

File tree

9 files changed

+228
-173
lines changed

9 files changed

+228
-173
lines changed

compiler/rustc_codegen_llvm/src/builder.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,9 +1452,15 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
14521452
impl<'ll> StaticBuilderMethods for Builder<'_, 'll, '_> {
14531453
fn get_static(&mut self, def_id: DefId) -> &'ll Value {
14541454
// Forward to the `get_static` method of `CodegenCx`
1455-
let s = self.cx().get_static(def_id);
1456-
// Cast to default address space if globals are in a different addrspace
1457-
self.cx().const_pointercast(s, self.type_ptr())
1455+
let global = self.cx().get_static(def_id);
1456+
if self.cx().tcx.is_thread_local_static(def_id) {
1457+
let pointer = self.call_intrinsic("llvm.threadlocal.address", &[global]);
1458+
// Cast to default address space if globals are in a different addrspace
1459+
self.pointercast(pointer, self.type_ptr())
1460+
} else {
1461+
// Cast to default address space if globals are in a different addrspace
1462+
self.cx().const_pointercast(global, self.type_ptr())
1463+
}
14581464
}
14591465
}
14601466

compiler/rustc_codegen_llvm/src/context.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,7 @@ impl<'ll> CodegenCx<'ll, '_> {
12431243
}
12441244

12451245
ifn!("llvm.ptrmask", fn(ptr, t_isize) -> ptr);
1246+
ifn!("llvm.threadlocal.address", fn(ptr) -> ptr);
12461247

12471248
None
12481249
}

src/librustdoc/html/static/css/rustdoc.css

Lines changed: 54 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ h1, h2, h3, h4 {
244244
more aggressively when we want them to. */
245245
overflow-wrap: anywhere;
246246
}
247+
.search-results-main-heading nav.sub {
248+
grid-area: main-heading-h1;
249+
}
247250
.main-heading {
248251
position: relative;
249252
display: grid;
@@ -263,6 +266,16 @@ h1, h2, h3, h4 {
263266
position: relative;
264267
z-index: 1;
265268
}
269+
.search-switcher {
270+
grid-area: main-heading-breadcrumbs;
271+
line-height: 1.25;
272+
display: flex;
273+
flex-wrap: wrap;
274+
color: var(--main-color);
275+
align-items: baseline;
276+
white-space: nowrap;
277+
margin-top: -1px;
278+
}
266279
.rustdoc-breadcrumbs a {
267280
padding: 5px 0 7px;
268281
}
@@ -315,6 +328,7 @@ rustdoc-toolbar,
315328
summary.hideme,
316329
.scraped-example-list,
317330
.rustdoc-breadcrumbs,
331+
.search-switcher,
318332
/* This selector is for the items listed in the "all items" page. */
319333
ul.all-items {
320334
font-family: "Fira Sans", Arial, NanumBarunGothic, sans-serif;
@@ -1136,16 +1150,15 @@ div.where {
11361150
nav.sub {
11371151
flex-grow: 1;
11381152
flex-flow: row nowrap;
1139-
margin: 4px 0 0 0;
11401153
display: flex;
1141-
align-items: center;
1154+
align-items: start;
1155+
margin-top: 4px;
11421156
}
11431157
.search-form {
11441158
position: relative;
11451159
display: flex;
11461160
height: 34px;
11471161
flex-grow: 1;
1148-
margin-bottom: 4px;
11491162
}
11501163
.src nav.sub {
11511164
margin: 0 0 -10px 0;
@@ -1246,21 +1259,6 @@ table,
12461259
margin-left: 0;
12471260
}
12481261

1249-
.search-results-title {
1250-
margin-top: 0;
1251-
white-space: nowrap;
1252-
/* flex layout allows shrinking the <select> appropriately if it becomes too large */
1253-
display: flex;
1254-
/* make things look like in a line, despite the fact that we're using a layout
1255-
with boxes (i.e. from the flex layout) */
1256-
align-items: baseline;
1257-
}
1258-
.search-results-title + .sub-heading {
1259-
color: var(--main-color);
1260-
display: flex;
1261-
align-items: baseline;
1262-
white-space: nowrap;
1263-
}
12641262
#crate-search-div {
12651263
/* ensures that 100% in properties of #crate-search-div:after
12661264
are relative to the size of this div */
@@ -2008,7 +2006,7 @@ a.tooltip:hover::after {
20082006
border-bottom: 1px solid var(--border-color);
20092007
}
20102008

2011-
#settings-menu, #help-button, button#toggle-all-docs {
2009+
#search-button, #settings-menu, #help-button, button#toggle-all-docs {
20122010
margin-left: var(--button-left-margin);
20132011
display: flex;
20142012
line-height: 1.25;
@@ -2038,7 +2036,11 @@ a.tooltip:hover::after {
20382036
.hide-sidebar .src #sidebar-button {
20392037
position: static;
20402038
}
2041-
#settings-menu > a, #help-button > a, #sidebar-button > a, button#toggle-all-docs {
2039+
#search-button > a,
2040+
#settings-menu > a,
2041+
#help-button > a,
2042+
#sidebar-button > a,
2043+
button#toggle-all-docs {
20422044
display: flex;
20432045
align-items: center;
20442046
justify-content: center;
@@ -2049,11 +2051,11 @@ a.tooltip:hover::after {
20492051
border-radius: var(--button-border-radius);
20502052
color: var(--main-color);
20512053
}
2052-
#settings-menu > a, #help-button > a, button#toggle-all-docs {
2054+
#search-button > a, #settings-menu > a, #help-button > a, button#toggle-all-docs {
20532055
width: 80px;
20542056
border-radius: var(--toolbar-button-border-radius);
20552057
}
2056-
#settings-menu > a, #help-button > a {
2058+
#search-button > a, #settings-menu > a, #help-button > a {
20572059
min-width: 0;
20582060
}
20592061
#sidebar-button > a {
@@ -2064,13 +2066,27 @@ a.tooltip:hover::after {
20642066
background-color: var(--main-background-color);
20652067
}
20662068

2069+
#search-button > a:hover, #search-button > a:focus-visible,
20672070
#settings-menu > a:hover, #settings-menu > a:focus-visible,
20682071
#help-button > a:hover, #help-button > a:focus-visible,
20692072
button#toggle-all-docs:hover, button#toggle-all-docs:focus-visible {
20702073
border-color: var(--settings-button-border-focus);
20712074
text-decoration: none;
20722075
}
20732076

2077+
#search-button > a::before {
2078+
/* Magnifying glass */
2079+
content: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" \
2080+
width="18" height="18" viewBox="0 0 16 16">\
2081+
<circle r="5" cy="7" cx="6" style="fill:none;stroke:currentColor;stroke-width:3"></circle>\
2082+
<path d="M 16,15 10,10" style="fill:none;stroke:currentColor;stroke-width:4"></path>\
2083+
<desc>Search</desc>\
2084+
</svg>');
2085+
width: 18px;
2086+
height: 18px;
2087+
filter: var(--settings-menu-filter);
2088+
}
2089+
20742090
#settings-menu > a::before {
20752091
/* Wheel <https://www.svgrepo.com/svg/384069/settings-cog-gear> */
20762092
content: url('data:image/svg+xml,<svg width="18" height="18" viewBox="0 0 12 12" \
@@ -2120,6 +2136,7 @@ button#toggle-all-docs.will-expand::before {
21202136
filter: var(--settings-menu-filter);
21212137
}
21222138

2139+
#search-button > a::before,
21232140
button#toggle-all-docs::before,
21242141
#help-button > a::before,
21252142
#settings-menu > a::before {
@@ -2128,6 +2145,7 @@ button#toggle-all-docs::before,
21282145
}
21292146

21302147
@media not (pointer: coarse) {
2148+
#search-button > a:hover::before,
21312149
button#toggle-all-docs:hover::before,
21322150
#help-button > a:hover::before,
21332151
#settings-menu > a:hover::before {
@@ -2455,6 +2473,20 @@ However, it's not needed with smaller screen width because the doc/code block is
24552473
.side-by-side > div {
24562474
width: auto;
24572475
}
2476+
2477+
/* Text label takes up too much space at this size. */
2478+
rustdoc-toolbar span.label {
2479+
display: none;
2480+
}
2481+
#search-button > a, #settings-menu > a, #help-button > a, button#toggle-all-docs {
2482+
width: 33px;
2483+
}
2484+
#settings.popover {
2485+
--popover-arrow-offset: 86px;
2486+
}
2487+
#help.popover {
2488+
--popover-arrow-offset: 48px;
2489+
}
24582490
}
24592491

24602492
/*
@@ -2485,20 +2517,6 @@ in src-script.js and main.js
24852517
visibility: hidden;
24862518
}
24872519

2488-
/* Text label takes up too much space at this size. */
2489-
rustdoc-toolbar span.label {
2490-
display: none;
2491-
}
2492-
#settings-menu > a, #help-button > a, button#toggle-all-docs {
2493-
width: 33px;
2494-
}
2495-
#settings.popover {
2496-
--popover-arrow-offset: 86px;
2497-
}
2498-
#help.popover {
2499-
--popover-arrow-offset: 48px;
2500-
}
2501-
25022520
.rustdoc {
25032521
/* Sidebar should overlay main content, rather than pushing main content to the right.
25042522
Turn off `display: flex` on the body element. */

0 commit comments

Comments
 (0)