ARM: Align functions containing Thumb-2 jump tables to 4 bytes.
[oota-llvm.git] / lib / Target / ARM / ARMConstantIslandPass.cpp
index e6d4b14a2628ef83237647637d5565fb53e8e4f1..0a47400c490d97cad8bdc7b5aa49b97fd1c84472 100644 (file)
@@ -423,6 +423,10 @@ bool ARMConstantIslands::runOnMachineFunction(MachineFunction &mf) {
   CPEMIs.clear();
   DEBUG(dumpBBs());
 
+  // Functions with jump tables need an alignment of 4 because they use the ADR
+  // instruction, which aligns the PC to 4 bytes before adding an offset.
+  if (!T2JumpTables.empty())
+    MF->ensureAlignment(2);
 
   /// Remove dead constant pool entries.
   MadeChange |= removeUnusedCPEntries();