On 12/21/18 10:19 AM, John Paul Adrian Glaubitz wrote:
> Attaching a better patch which can be applied unconditionally.

Attaching a cleaned up patch after James' comments.

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaub...@debian.org
`. `'   Freie Universitaet Berlin - glaub...@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
Description: Fix alignment regression on sparc64
Author: John Paul Adrian Glaubitz <glaub...@physik.fu-berlin.de>
Bug: https://github.com/rust-lang/rust/issues/56927
Last-Update: 2018-12-20

Index: rustc-1.31.0+dfsg1/src/librustc_codegen_llvm/mir/place.rs
===================================================================
--- rustc-1.31.0+dfsg1.orig/src/librustc_codegen_llvm/mir/place.rs
+++ rustc-1.31.0+dfsg1/src/librustc_codegen_llvm/mir/place.rs
@@ -177,7 +177,14 @@ impl PlaceRef<'ll, 'tcx> {
         let cx = bx.cx;
         let field = self.layout.field(cx, ix);
         let offset = self.layout.fields.offset(ix);
-        let effective_field_align = self.align.restrict_for_offset(offset);
+
+	#[cfg(target_arch = "sparc64")]
+	let effective_field_align = self.align
+	.min(self.layout.align)
+	.min(field.align)
+	.restrict_for_offset(offset);	   
+	#[cfg(not(target_arch = "sparc64"))]
+	let effective_field_align = self.align.restrict_for_offset(offset);
 
         let simple = || {
             // Unions and newtypes only use an offset of 0.
Index: rustc-1.31.0+dfsg1/src/test/codegen/align-struct.rs
===================================================================
--- rustc-1.31.0+dfsg1.orig/src/test/codegen/align-struct.rs
+++ rustc-1.31.0+dfsg1/src/test/codegen/align-struct.rs
@@ -52,6 +52,7 @@ pub fn align64(i : i32) -> Align64 {
 // structs
 // CHECK-LABEL: @align64_load
 #[no_mangle]
+#[cfg_attr(not(target_arch = "sparc64"))]
 pub fn align64_load(a: Align64) -> i32 {
 // CHECK: [[FIELD:%.*]] = bitcast %Align64* %{{.*}} to i32*
 // CHECK: {{%.*}} = load i32, i32* [[FIELD]], align 64

Reply via email to