summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2011-12-06 01:43:02 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2011-12-06 01:43:02 +0000
commit3e572ac2fbdf6aa538500be07b9b050ac008669e (patch)
tree4f35a5d28d4599ad1a9df65847914feccfcb6c95
parent8c741b8064f1116d8d8dc435b60b75abdf5c4d57 (diff)
downloadllvm-3e572ac2fbdf6aa538500be07b9b050ac008669e.tar.gz
llvm-3e572ac2fbdf6aa538500be07b9b050ac008669e.tar.bz2
llvm-3e572ac2fbdf6aa538500be07b9b050ac008669e.tar.xz
Align ARM constant pool islands via their basic block.
Previously, all ARM::CONSTPOOL_ENTRY instructions had a hardwired alignment of 4 bytes emitted by ARMAsmPrinter. Now the same alignment is set on the basic block. This is in preparation of supporting ARM constant pool islands with different alignments. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145890 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/ARM/ARMAsmPrinter.cpp3
-rw-r--r--lib/Target/ARM/ARMConstantIslandPass.cpp6
-rw-r--r--test/CodeGen/ARM/globals.ll1
3 files changed, 7 insertions, 3 deletions
diff --git a/lib/Target/ARM/ARMAsmPrinter.cpp b/lib/Target/ARM/ARMAsmPrinter.cpp
index eca6039abf..6d37416d0c 100644
--- a/lib/Target/ARM/ARMAsmPrinter.cpp
+++ b/lib/Target/ARM/ARMAsmPrinter.cpp
@@ -1481,11 +1481,10 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
/// in the function. The first operand is the ID# for this instruction, the
/// second is the index into the MachineConstantPool that this is, the third
/// is the size in bytes of this constant pool entry.
+ /// The required alignment is specified on the basic block holding this MI.
unsigned LabelId = (unsigned)MI->getOperand(0).getImm();
unsigned CPIdx = (unsigned)MI->getOperand(1).getIndex();
- EmitAlignment(2);
-
// Mark the constant pool entry as data if we're not already in a data
// region.
OutStreamer.EmitDataRegion();
diff --git a/lib/Target/ARM/ARMConstantIslandPass.cpp b/lib/Target/ARM/ARMConstantIslandPass.cpp
index fedbbad56f..017e908206 100644
--- a/lib/Target/ARM/ARMConstantIslandPass.cpp
+++ b/lib/Target/ARM/ARMConstantIslandPass.cpp
@@ -398,6 +398,9 @@ void ARMConstantIslands::DoInitialPlacement(MachineFunction &MF,
MachineBasicBlock *BB = MF.CreateMachineBasicBlock();
MF.push_back(BB);
+ // Mark the basic block as 4-byte aligned as required by the const-pool.
+ BB->setAlignment(2);
+
// Add all of the constants from the constant pool to the end block, use an
// identity mapping of CPI's to CPE's.
const std::vector<MachineConstantPoolEntry> &CPs =
@@ -1311,6 +1314,9 @@ bool ARMConstantIslands::HandleConstantPoolUser(MachineFunction &MF,
CPEntries[CPI].push_back(CPEntry(U.CPEMI, ID, 1));
++NumCPEs;
+ // Mark the basic block as 4-byte aligned as required by the const-pool entry.
+ NewIsland->setAlignment(2);
+
BBOffsets[NewIsland->getNumber()] = BBOffsets[NewMBB->getNumber()];
// Compensate for .align 2 in thumb mode.
if (isThumb && (BBOffsets[NewIsland->getNumber()]%4 != 0 || HasInlineAsm))
diff --git a/test/CodeGen/ARM/globals.ll b/test/CodeGen/ARM/globals.ll
index 5e7e3f2a92..eb71149d83 100644
--- a/test/CodeGen/ARM/globals.ll
+++ b/test/CodeGen/ARM/globals.ll
@@ -70,6 +70,5 @@ define i32 @test1() {
; LinuxPIC: .align 2
; LinuxPIC: .LCPI0_0:
; LinuxPIC: .long _GLOBAL_OFFSET_TABLE_-(.LPC0_0+8)
-; LinuxPIC: .align 2
; LinuxPIC: .LCPI0_1:
; LinuxPIC: .long G(GOT)