[llvm] r235636 - ARM: Only enforce 4-byte alignment on Thumb-2 functions with constant pools.

Peter Collingbourne peter at pcc.me.uk
Thu Apr 23 13:31:22 PDT 2015


Author: pcc
Date: Thu Apr 23 15:31:22 2015
New Revision: 235636

URL: http://llvm.org/viewvc/llvm-project?rev=235636&view=rev
Log:
ARM: Only enforce 4-byte alignment on Thumb-2 functions with constant pools.

This appears to have been introduced back in r76698 as part of an unrelated
change. I can find no official ARM documentation stating that Thumb-2 functions
require 4-byte alignment; in fact, ARM documentation appears to contradict
this (see, e.g., ARM Architecture Reference Manual Thumb-2 Supplement,
section 2.6.1: "Thumb-2 enforces 16-bit alignment on all instructions.").

Also remove code that sets alignment for ARM functions, which is redundant
with code in the MachineFunction constructor, and remove the hidden
-arm-align-constant-islands flag, which has been enabled by default since
r146739 (Dec 2011) and has probably received sufficient testing by now.

Differential Revision: http://reviews.llvm.org/D9138

Added:
    llvm/trunk/test/CodeGen/ARM/thumb-alignment.ll
Modified:
    llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp
    llvm/trunk/test/MC/ARM/elf-thumbfunc-reloc.ll

Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=235636&r1=235635&r2=235636&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Thu Apr 23 15:31:22 2015
@@ -53,11 +53,6 @@ static cl::opt<bool>
 AdjustJumpTableBlocks("arm-adjust-jump-tables", cl::Hidden, cl::init(true),
           cl::desc("Adjust basic block layout to better use TB[BH]"));
 
-// FIXME: This option should be removed once it has received sufficient testing.
-static cl::opt<bool>
-AlignConstantIslands("arm-align-constant-islands", cl::Hidden, cl::init(true),
-          cl::desc("Align constant islands in code"));
-
 /// UnknownPadding - Return the worst case padding that could result from
 /// unknown offset bits.  This does not include alignment padding caused by
 /// known offset bits.
@@ -412,13 +407,6 @@ bool ARMConstantIslands::runOnMachineFun
     MF->RenumberBlocks();
   }
 
-  // Thumb1 functions containing constant pools get 4-byte alignment.
-  // This is so we can keep exact track of where the alignment padding goes.
-
-  // ARM and Thumb2 functions need to be 4-byte aligned.
-  if (!isThumb1)
-    MF->ensureAlignment(2);  // 2 = log2(4)
-
   // Perform the initial placement of the constant pool entries.  To start with,
   // we put them all at the end of the function.
   std::vector<MachineInstr*> CPEMIs;
@@ -513,8 +501,7 @@ ARMConstantIslands::doInitialPlacement(s
   unsigned MaxAlign = Log2_32(MCP->getConstantPoolAlignment());
 
   // Mark the basic block as required by the const-pool.
-  // If AlignConstantIslands isn't set, use 4-byte alignment for everything.
-  BB->setAlignment(AlignConstantIslands ? MaxAlign : 2);
+  BB->setAlignment(MaxAlign);
 
   // The function needs to be as aligned as the basic blocks. The linker may
   // move functions around based on their alignment.
@@ -604,10 +591,6 @@ ARMConstantIslands::CPEntry
 unsigned ARMConstantIslands::getCPELogAlign(const MachineInstr *CPEMI) {
   assert(CPEMI && CPEMI->getOpcode() == ARM::CONSTPOOL_ENTRY);
 
-  // Everything is 4-byte aligned unless AlignConstantIslands is set.
-  if (!AlignConstantIslands)
-    return 2;
-
   unsigned CPI = CPEMI->getOperand(1).getIndex();
   assert(CPI < MCP->getConstants().size() && "Invalid constant pool index.");
   unsigned Align = MCP->getConstants()[CPI].getAlignment();

Added: llvm/trunk/test/CodeGen/ARM/thumb-alignment.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/thumb-alignment.ll?rev=235636&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/thumb-alignment.ll (added)
+++ llvm/trunk/test/CodeGen/ARM/thumb-alignment.ll Thu Apr 23 15:31:22 2015
@@ -0,0 +1,15 @@
+; RUN: llc -relocation-model=pic -mtriple=thumbv7-unknown-linux -o - %s | FileCheck %s
+
+ at x = external global i32
+
+; CHECK: .globl	foo
+; CHECK-NEXT: .align	2
+define i32* @foo() {
+  ret i32* @x
+}
+
+; CHECK: .globl	bar
+; CHECK-NEXT: .align	1
+define i32* @bar() {
+  ret i32* zeroinitializer
+}

Modified: llvm/trunk/test/MC/ARM/elf-thumbfunc-reloc.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/elf-thumbfunc-reloc.ll?rev=235636&r1=235635&r2=235636&view=diff
==============================================================================
--- llvm/trunk/test/MC/ARM/elf-thumbfunc-reloc.ll (original)
+++ llvm/trunk/test/MC/ARM/elf-thumbfunc-reloc.ll Thu Apr 23 15:31:22 2015
@@ -24,13 +24,13 @@ entry:
 ; make sure that bl 0 <foo> (fff7feff) is correctly encoded
 ; CHECK: Sections [
 ; CHECK:   SectionData (
-; CHECK:     0000: 704700BF 2DE90048 FFF7FEFF BDE80088
+; CHECK:     0000: 70472DE9 0048FFF7 FEFFBDE8 0088
 ; CHECK:   )
 ; CHECK: ]
 
 ; CHECK:      Relocations [
 ; CHECK-NEXT:   Section {{.*}} .rel.text {
-; CHECK-NEXT:     0x8 R_ARM_THM_CALL foo 0x0
+; CHECK-NEXT:     0x6 R_ARM_THM_CALL foo 0x0
 ; CHECK-NEXT:   }
 ; CHECK-NEXT:   Section {{.*}} .rel.ARM.exidx {
 ; CHECK-NEXT:     0x0 R_ARM_PREL31 .text 0x0





More information about the llvm-commits mailing list