File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
src/librustc_codegen_llvm Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -143,6 +143,18 @@ fn strip_function_ptr_alignment(data_layout: String) -> String {
143
143
data_layout. replace ( "-Fi8-" , "-" )
144
144
}
145
145
146
+ fn strip_x86_address_spaces ( data_layout : String ) -> String {
147
+ data_layout. replace ( "-p270:32:32-p271:32:32-p272:64:64-" , "-" )
148
+ }
149
+
150
+ fn add_x86_address_spaces ( mut data_layout : String ) -> String {
151
+ 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) ;
154
+ }
155
+ data_layout
156
+ }
157
+
146
158
pub unsafe fn create_module (
147
159
tcx : TyCtxt < ' _ > ,
148
160
llcx : & ' ll llvm:: Context ,
@@ -156,6 +168,13 @@ pub unsafe fn create_module(
156
168
if llvm_util:: get_major_version ( ) < 9 {
157
169
target_data_layout = strip_function_ptr_alignment ( target_data_layout) ;
158
170
}
171
+ if sess. target . target . arch == "x86" || sess. target . target . arch == "x86_64" {
172
+ if llvm_util:: get_major_version ( ) < 10 {
173
+ target_data_layout = strip_x86_address_spaces ( target_data_layout) ;
174
+ } else {
175
+ target_data_layout = add_x86_address_spaces ( target_data_layout) ;
176
+ }
177
+ }
159
178
160
179
// Ensure the data-layout values hardcoded remain the defaults.
161
180
if sess. target . target . options . is_builtin {
You can’t perform that action at this time.
0 commit comments