[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#916818: rustc: Compiler regression results in generated code with unaligned access



Control: tags -1 patch

Hello!

The attached patch reverts the problematic upstream commit and fixes
the problem for me.

Would it be possible to include it in the rustc source package and apply
it per platform, i.e. something like this in debian/rules:

ifeq ($(DEB_HOST_ARCH), sparc64)
	patch -p1 < patches/sparc64-fix-bus-error.patch
endif

Thanks,
Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
Description: Revert "Rely only on base alignment and offset for computing field alignment #54547"
Author: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Bug: https://github.com/rust-lang/rust/issues/56927
Last-Update: 2018-12-19

--- 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,10 @@ 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);
+        let effective_field_align = self.align
+            .min(self.layout.align)
+            .min(field.align)
+            .restrict_for_offset(offset);
 
         let simple = || {
             // Unions and newtypes only use an offset of 0.
--- rustc-1.31.0+dfsg1.orig/src/test/codegen/align-struct.rs
+++ rustc-1.31.0+dfsg1/src/test/codegen/align-struct.rs
@@ -48,16 +48,6 @@ pub fn align64(i : i32) -> Align64 {
     a64
 }
 
-// For issue 54028: make sure that we are specifying the correct alignment for fields of aligned
-// structs
-// CHECK-LABEL: @align64_load
-#[no_mangle]
-pub fn align64_load(a: Align64) -> i32 {
-// CHECK: [[FIELD:%.*]] = bitcast %Align64* %{{.*}} to i32*
-// CHECK: {{%.*}} = load i32, i32* [[FIELD]], align 64
-    a.0
-}
-
 // CHECK-LABEL: @nested64
 #[no_mangle]
 pub fn nested64(a: Align64, b: i32, c: i32, d: i8) -> Nested64 {

Reply to: