Skip to content

Commit a182392

Browse files
committed
Handle p:32:32 in X86 data layout upgrade
This matches the autoupgrade in LLVM more closely.
1 parent 326fc7b commit a182392

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/librustc_codegen_llvm/context.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,12 @@ fn strip_x86_address_spaces(data_layout: String) -> String {
149149

150150
fn add_x86_address_spaces(mut data_layout: String) -> String {
151151
let address_spaces = "-p270:32:32-p271:32:32-p272:64:64";
152-
if !data_layout.contains(address_spaces) {
153-
data_layout.insert_str("e-m:X".len(), address_spaces);
152+
if !data_layout.contains(address_spaces) && data_layout.starts_with("e-m:") {
153+
let mut insert_pos = "e-m:?".len();
154+
if data_layout[insert_pos..].starts_with("-p:32:32") {
155+
insert_pos += "-p:32:32".len();
156+
}
157+
data_layout.insert_str(insert_pos, address_spaces);
154158
}
155159
data_layout
156160
}

0 commit comments

Comments
 (0)