[llvm] r294950 - [CodeGen] fix alignment of JUMPTABLE_INSTS on v8M.base
Sanne Wouda via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 13 06:07:46 PST 2017
Author: sanwou01
Date: Mon Feb 13 08:07:45 2017
New Revision: 294950
URL: http://llvm.org/viewvc/llvm-project?rev=294950&view=rev
Log:
[CodeGen] fix alignment of JUMPTABLE_INSTS on v8M.base
Summary:
The attached test case fails with "fatal error: error in backend:
misaligned pc-relative fixup value" as the jump table is misaligned.
The EmitAlignment existed already for ARM and Thumb-1 code, but was
missing for Thumb-2.
The test checks that the fatal error disappears when generating an obj
file, as well as checking the align directive is there when producing an
asm file.
Reviewers: rengolin, grosbach, t.p.northover, jmolloy, SjoerdMeijer, samparker
Reviewed By: samparker
Subscribers: samparker, aemerson, llvm-commits
Differential Revision: https://reviews.llvm.org/D29650
Added:
llvm/trunk/test/CodeGen/ARM/v8m.base-jumptable_alignment.ll
Modified:
llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp
Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp?rev=294950&r1=294949&r2=294950&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp Mon Feb 13 08:07:45 2017
@@ -1142,6 +1142,11 @@ void ARMAsmPrinter::EmitJumpTableInsts(c
const MachineOperand &MO1 = MI->getOperand(1);
unsigned JTI = MO1.getIndex();
+ // Make sure the Thumb jump table is 4-byte aligned. This will be a nop for
+ // ARM mode tables.
+ EmitAlignment(2);
+
+ // Emit a label for the jump table.
MCSymbol *JTISymbol = GetARMJTIPICJumpTableLabel(JTI);
OutStreamer->EmitLabel(JTISymbol);
Added: llvm/trunk/test/CodeGen/ARM/v8m.base-jumptable_alignment.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/v8m.base-jumptable_alignment.ll?rev=294950&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/v8m.base-jumptable_alignment.ll (added)
+++ llvm/trunk/test/CodeGen/ARM/v8m.base-jumptable_alignment.ll Mon Feb 13 08:07:45 2017
@@ -0,0 +1,51 @@
+; RUN: llc -filetype=obj -o /dev/null < %s
+; RUN: llc -filetype=asm < %s | FileCheck %s
+
+; ModuleID = 'bugpoint-reduced-simplified.bc'
+source_filename = "bugpoint-output-39ed676.bc"
+target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
+target triple = "thumbv8m.base-arm-none-eabi"
+
+ at crc32_tab = external unnamed_addr global [256 x i32], align 4
+ at g_566 = external global i32**, align 4
+
+define void @main() {
+entry:
+ %0 = load volatile i32**, i32*** @g_566, align 4
+ br label %func_16.exit.i.i.i
+
+lbl_1394.i.i.i.loopexit: ; preds = %for.cond14.preheader.us.i.i.i
+ unreachable
+
+func_16.exit.i.i.i: ; preds = %entry
+ br i1 undef, label %for.cond7.preheader.i.lr.ph.i.i, label %for.end476.i.i.i.loopexit
+
+for.cond7.preheader.i.lr.ph.i.i: ; preds = %func_16.exit.i.i.i
+ br i1 undef, label %for.end476.i.i.i.loopexit, label %for.cond7.preheader.i.i.preheader.i
+
+for.cond7.preheader.i.i.preheader.i: ; preds = %for.cond7.preheader.i.lr.ph.i.i
+ br label %for.cond14.preheader.us.i.i.i
+
+for.cond7.preheader.i.us.i.i: ; preds = %for.cond7.preheader.i.lr.ph.i.i
+ unreachable
+
+for.cond14.preheader.us.i.i.i: ; preds = %for.inc459.us.i.i.i, %for.cond7.preheader.i.i.preheader.i
+; CHECK: @ BB#4
+; CHECK-NEXT: .p2align 2
+ switch i4 undef, label %func_1.exit.loopexit [
+ i4 0, label %for.inc459.us.i.i.i
+ i4 -5, label %for.inc459.us.i.i.i
+ i4 2, label %lbl_1394.i.i.i.loopexit
+ i4 3, label %for.end476.i.i.i.loopexit
+ ]
+
+for.inc459.us.i.i.i: ; preds = %for.cond14.preheader.us.i.i.i, %for.cond14.preheader.us.i.i.i
+ br label %for.cond14.preheader.us.i.i.i
+
+for.end476.i.i.i.loopexit: ; preds = %for.cond14.preheader.us.i.i.i
+ unreachable
+
+func_1.exit.loopexit: ; preds = %for.cond14.preheader.us.i.i.i
+ %arrayidx.i63.i.i5252 = getelementptr inbounds [256 x i32], [256 x i32]* @crc32_tab, i32 0, i32 undef
+ unreachable
+}
More information about the llvm-commits
mailing list