[llvm] r219734 - ARM: remove ARM/Thumb distinction for preferred alignment.

Oliver Stannard oliver.stannard at arm.com
Fri Oct 17 04:58:25 PDT 2014


Hi Tim,

This commit (or one of the related ones) has introduced a regression for
Thumb1. The following code should print "0":

#include <stdio.h>

short a;
short *b = &a;
int c;
int *d = &c;
int main() {
  char e = 0, f = 3;
  a = e;
  *d = *b;
  printf("%d\n", c);
}

However, it now prints "3" when compiled for v6M at -O0.

Oliver

> -----Original Message-----
> From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits-
> bounces at cs.uiuc.edu] On Behalf Of Tim Northover
> Sent: 14 October 2014 23:12
> To: llvm-commits at cs.uiuc.edu
> Subject: [llvm] r219734 - ARM: remove ARM/Thumb distinction for
> preferred alignment.
> 
> Author: tnorthover
> Date: Tue Oct 14 17:12:17 2014
> New Revision: 219734
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=219734&view=rev
> Log:
> ARM: remove ARM/Thumb distinction for preferred alignment.
> 
> Thumb1 has legitimate reasons for preferring 32-bit alignment of types
> i1/i8/i16, since the 16-bit encoding of "add rD, sp, #imm" requires
> #imm to be
> a multiple of 4. However, this is a trade-off betweem code size and RAM
> usage;
> the DataLayout string is not the best place to represent it even if
> desired.
> 
> So this patch removes the extra Thumb requirements, hopefully making
> ARM and
> Thumb completely compatible in this respect.
> 
> Added:
>     llvm/trunk/test/CodeGen/ARM/preferred-align.ll
> Removed:
>     llvm/trunk/test/CodeGen/ARM/aggregate-align.ll
> Modified:
>     llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp
>     llvm/trunk/test/CodeGen/ARM/2011-04-12-AlignBug.ll
> 
> Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp
> URL: http://llvm.org/viewvc/llvm-
> project/llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp?rev=219734&r1=219733
> &r2=219734&view=diff
> =======================================================================
> =======
> --- llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp (original)
> +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp Tue Oct 14 17:12:17 2014
> @@ -102,11 +102,6 @@ static std::string computeDataLayout(ARM
>    // Pointers are 32 bits and aligned to 32 bits.
>    Ret += "-p:32:32";
> 
> -  // On thumb, i16,i18 and i1 have natural aligment requirements, but
> we try to
> -  // align to 32.
> -  if (ST.isThumb())
> -    Ret += "-i1:8:32-i8:8:32-i16:16:32";
> -
>    // ABIs other than APCS have 64 bit integers with natural alignment.
>    if (!ST.isAPCS_ABI())
>      Ret += "-i64:64";
> 
> Modified: llvm/trunk/test/CodeGen/ARM/2011-04-12-AlignBug.ll
> URL: http://llvm.org/viewvc/llvm-
> project/llvm/trunk/test/CodeGen/ARM/2011-04-12-
> AlignBug.ll?rev=219734&r1=219733&r2=219734&view=diff
> =======================================================================
> =======
> --- llvm/trunk/test/CodeGen/ARM/2011-04-12-AlignBug.ll (original)
> +++ llvm/trunk/test/CodeGen/ARM/2011-04-12-AlignBug.ll Tue Oct 14
> 17:12:17 2014
> @@ -1,11 +1,10 @@
>  ; RUN: llc < %s | FileCheck %s
> -target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-
> i64:32:32-f32:32:32-f64:32:32-v64:32:64-v128:32:128-a0:0:32-n32"
>  target triple = "thumbv7-apple-darwin10.0.0"
> 
>  ; CHECK: align 3
>  @.v = private unnamed_addr constant <4 x i32> <i32 1, i32 2, i32 3,
> i32 4>, align 8
> -; CHECK: align 2
> - at .strA = private unnamed_addr constant [4 x i8] c"bar\00"
> +; CHECK: align 4
> + at .strA = private unnamed_addr constant [4 x i64] zeroinitializer
>  ; CHECK-NOT: align
>  @.strB = private unnamed_addr constant [4 x i8] c"foo\00", align 1
>  @.strC = private unnamed_addr constant [4 x i8] c"baz\00", section
> "__TEXT,__cstring,cstring_literals", align 1
> 
> Removed: llvm/trunk/test/CodeGen/ARM/aggregate-align.ll
> URL: http://llvm.org/viewvc/llvm-
> project/llvm/trunk/test/CodeGen/ARM/aggregate-
> align.ll?rev=219733&view=auto
> =======================================================================
> =======
> --- llvm/trunk/test/CodeGen/ARM/aggregate-align.ll (original)
> +++ llvm/trunk/test/CodeGen/ARM/aggregate-align.ll (removed)
> @@ -1,6 +0,0 @@
> -; RUN: llc -mtriple=armv7-linux-gnueabi %s -o - | FileCheck %s
> -
> - at var = global {i8, i8} zeroinitializer
> -
> -; CHECK: .globl var
> -; CHECK-NEXT: .align 2
> 
> Added: llvm/trunk/test/CodeGen/ARM/preferred-align.ll
> URL: http://llvm.org/viewvc/llvm-
> project/llvm/trunk/test/CodeGen/ARM/preferred-
> align.ll?rev=219734&view=auto
> =======================================================================
> =======
> --- llvm/trunk/test/CodeGen/ARM/preferred-align.ll (added)
> +++ llvm/trunk/test/CodeGen/ARM/preferred-align.ll Tue Oct 14 17:12:17
> 2014
> @@ -0,0 +1,21 @@
> +; RUN: llc -mtriple=armv7-linux-gnueabi %s -o - | FileCheck %s
> +
> + at var_agg = global {i8, i8} zeroinitializer
> +
> +; CHECK: .globl var_agg
> +; CHECK-NEXT: .align 2
> +
> + at var1 = global i1 zeroinitializer
> +
> +; CHECK: .globl var1
> +; CHECK-NOT: .align
> +
> + at var8 = global i8 zeroinitializer
> +
> +; CHECK: .globl var8
> +; CHECK-NOT: .align
> +
> + at var16 = global i16 zeroinitializer
> +
> +; CHECK: .globl var16
> +; CHECK-NEXT: .align 1
> \ No newline at end of file
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits








More information about the llvm-commits mailing list