Bill Schmidt
c38c1d135c
Index: test/CodeGen/PowerPC/reloc-align.ll
===================================================================
--- test/CodeGen/PowerPC/reloc-align.ll (revision 0)
+++ test/CodeGen/PowerPC/reloc-align.ll (revision 0)
@@ -0,0 +1,34 @@
+; RUN: llc -mcpu=pwr7 -O1 < %s | FileCheck %s
+
+; This test verifies that the peephole optimization of address accesses
+; does not produce a load or store with a relocation that can't be
+; satisfied for a given instruction encoding. Reduced from a test supplied
+; by Hal Finkel.
+
+target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v128:128:128-n32:64"
+target triple = "powerpc64-unknown-linux-gnu"
+
+%struct.S1 = type { [8 x i8] }
+
+@main.l_1554 = internal global { i8, i8, i8, i8, i8, i8, i8, i8 } { i8 -1, i8 -6, i8 57, i8 62, i8 -48, i8 0, i8 58, i8 80 }, align 1
+
+; Function Attrs: nounwind readonly
+define signext i32 @main() #0 {
+entry:
+ %call = tail call fastcc signext i32 @func_90(%struct.S1* byval bitcast ({ i8, i8, i8, i8, i8, i8, i8, i8 }* @main.l_1554 to %struct.S1*))
+; CHECK-NOT: ld {{[0-9]+}}, main.l_1554@toc@l
+ ret i32 %call
+}
+
+; Function Attrs: nounwind readonly
+define internal fastcc signext i32 @func_90(%struct.S1* byval nocapture %p_91) #0 {
+entry:
+ %0 = bitcast %struct.S1* %p_91 to i64*
+ %bf.load = load i64* %0, align 1
+ %bf.shl = shl i64 %bf.load, 26
+ %bf.ashr = ashr i64 %bf.shl, 54
+ %bf.cast = trunc i64 %bf.ashr to i32
+ ret i32 %bf.cast
+}
+
+attributes #0 = { nounwind readonly "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
Index: lib/Target/PowerPC/PPCAsmPrinter.cpp
===================================================================
--- lib/Target/PowerPC/PPCAsmPrinter.cpp (revision 185327)
+++ lib/Target/PowerPC/PPCAsmPrinter.cpp (working copy)
@@ -679,7 +679,26 @@ void PPCAsmPrinter::EmitInstruction(const MachineI
OutStreamer.EmitRawText(StringRef("\tmsync"));
return;
}
+ break;
+ case PPC::LD:
+ case PPC::STD:
+ case PPC::LWA: {
+ // Verify alignment is legal, so we don't create relocations
+ // that can't be supported.
+ // FIXME: This test is currently disabled for Darwin. The test
+ // suite shows a handful of test cases that fail this check for
+ // Darwin. Those need to be investigated before this sanity test
+ // can be enabled for those subtargets.
+ if (!Subtarget.isDarwin()) {
+ unsigned OpNum = (MI->getOpcode() == PPC::STD) ? 2 : 1;
+ const MachineOperand &MO = MI->getOperand(OpNum);
+ if (MO.isGlobal() && MO.getGlobal()->getAlignment() < 4)
+ llvm_unreachable("Global must be word-aligned for LD, STD, LWA!");
+ }
+ // Now process the instruction normally.
+ break;
}
+ }
LowerPPCMachineInstrToMCInst(MI, TmpInst, *this);
OutStreamer.EmitInstruction(TmpInst);
Index: lib/Target/PowerPC/PPCISelDAGToDAG.cpp
===================================================================
--- lib/Target/PowerPC/PPCISelDAGToDAG.cpp (revision 185327)
+++ lib/Target/PowerPC/PPCISelDAGToDAG.cpp (working copy)
@@ -1530,6 +1530,14 @@ void PPCDAGToDAGISel::PostprocessISelDAG() {
if (GlobalAddressSDNode *GA = dyn_cast<GlobalAddressSDNode>(ImmOpnd)) {
SDLoc dl(GA);
const GlobalValue *GV = GA->getGlobal();
+ // We can't perform this optimization for data whose alignment
+ // is insufficient for the instruction encoding.
+ if (GV->getAlignment() < 4 &&
+ (StorageOpcode == PPC::LD || StorageOpcode == PPC::STD ||
+ StorageOpcode == PPC::LWA)) {
+ DEBUG(dbgs() << "Rejected this candidate for alignment.\n\n");
+ continue;
+ }
ImmOpnd = CurDAG->getTargetGlobalAddress(GV, dl, MVT::i64, 0, Flags);
} else if (ConstantPoolSDNode *CP =
dyn_cast<ConstantPoolSDNode>(ImmOpnd)) {
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185380 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-01 20:52:27 +00:00
..
2012-07-02 12:47:22 +00:00
2012-07-02 19:09:46 +00:00
2012-07-02 12:47:22 +00:00
2011-06-17 06:36:20 +00:00
2011-12-12 11:59:10 +00:00
2012-07-02 12:47:22 +00:00
2012-06-08 23:15:12 +00:00
2012-06-09 03:14:50 +00:00
2012-07-02 12:47:22 +00:00
2013-03-15 13:21:21 +00:00
2013-04-30 20:04:37 +00:00
2012-06-08 23:15:12 +00:00
2012-06-08 23:15:12 +00:00
2013-05-16 14:30:09 +00:00
2012-06-08 23:15:12 +00:00
2011-12-05 17:55:17 +00:00
2011-12-05 17:55:17 +00:00
2011-12-05 17:55:17 +00:00
2011-06-17 03:14:27 +00:00
2011-11-27 06:54:59 +00:00
2013-02-04 15:19:18 +00:00
2011-06-17 03:14:27 +00:00
2011-10-28 23:11:03 +00:00
2011-05-02 15:58:16 +00:00
2011-09-14 00:29:50 +00:00
2013-03-12 15:18:14 +00:00
2011-07-20 05:58:47 +00:00
2013-03-28 03:38:16 +00:00
2012-09-06 18:15:23 +00:00
2013-03-12 15:18:14 +00:00
2010-10-11 20:43:09 +00:00
2013-03-12 15:18:14 +00:00
2013-04-30 17:52:57 +00:00
2013-04-30 17:52:57 +00:00
2011-12-09 01:16:26 +00:00
2012-11-14 23:23:27 +00:00
2012-11-13 18:40:58 +00:00
2012-10-12 16:01:08 +00:00
2012-11-18 06:21:03 +00:00
2013-05-16 17:58:02 +00:00
2013-07-01 19:42:46 +00:00
2012-06-22 22:31:00 +00:00
2013-01-30 23:43:27 +00:00
2013-01-30 21:17:42 +00:00
2013-05-13 19:34:37 +00:00
2013-03-27 06:52:27 +00:00
2011-06-17 03:14:27 +00:00
2011-06-17 03:14:27 +00:00
2012-07-02 12:47:22 +00:00
2013-06-13 20:23:34 +00:00
2012-11-05 18:18:42 +00:00
2013-03-21 23:23:34 +00:00
2013-03-27 13:20:52 +00:00
2012-12-25 17:22:53 +00:00
2011-09-26 21:30:17 +00:00
2011-09-26 21:30:17 +00:00
2012-11-24 13:18:25 +00:00
2013-04-10 22:05:25 +00:00
2012-07-02 12:47:22 +00:00
2012-07-02 12:47:22 +00:00
2012-08-28 02:10:33 +00:00
2012-07-02 12:47:22 +00:00
2013-03-28 20:35:18 +00:00
2012-11-30 13:28:31 +00:00
2012-07-02 12:47:22 +00:00
2011-10-17 04:03:59 +00:00
2012-11-05 19:39:45 +00:00
2012-07-02 12:47:22 +00:00
2013-01-17 17:45:19 +00:00
2012-07-02 12:47:22 +00:00
2012-08-28 02:10:27 +00:00
2011-08-30 17:04:16 +00:00
2013-03-28 03:38:16 +00:00
2013-05-16 03:48:50 +00:00
2013-03-18 17:40:27 +00:00
2013-05-18 09:20:39 +00:00
2013-05-16 20:28:05 +00:00
2013-06-07 22:16:19 +00:00
2013-07-01 19:34:59 +00:00
2013-05-15 21:37:41 +00:00
2013-05-15 21:37:41 +00:00
2013-05-15 21:37:41 +00:00
2012-06-08 19:19:53 +00:00
2013-04-30 17:52:57 +00:00
2013-04-30 17:52:57 +00:00
2013-05-15 21:37:41 +00:00
2013-04-01 16:31:56 +00:00
2012-07-02 12:47:22 +00:00
2013-03-21 20:28:52 +00:00
2013-03-18 22:08:16 +00:00
2012-12-25 18:51:18 +00:00
2013-04-10 22:05:25 +00:00
2013-04-30 17:52:57 +00:00
2013-06-13 20:23:34 +00:00
2012-08-03 23:29:17 +00:00
2013-01-11 10:36:13 +00:00
2013-04-01 18:42:58 +00:00
2013-06-13 20:23:34 +00:00
2013-04-11 12:32:23 +00:00
2012-08-03 23:29:17 +00:00
2013-04-06 19:30:30 +00:00
2013-03-15 05:06:04 +00:00
2013-03-21 19:03:19 +00:00
2011-12-05 17:55:17 +00:00
2011-12-30 00:34:00 +00:00
2012-07-02 12:47:22 +00:00
2012-07-02 12:47:22 +00:00
2013-04-07 22:11:09 +00:00
2012-08-28 16:12:39 +00:00
2012-08-28 16:12:39 +00:00
2012-07-02 12:47:22 +00:00
2013-04-01 17:52:07 +00:00
2013-04-01 17:52:07 +00:00
2013-04-01 17:52:07 +00:00
2013-03-12 16:27:52 +00:00
2013-04-05 23:29:01 +00:00
2012-12-20 17:47:27 +00:00
2011-12-02 04:58:12 +00:00
2012-09-04 18:38:28 +00:00
2012-10-29 18:35:49 +00:00
2012-06-22 23:10:08 +00:00
2012-07-02 12:47:22 +00:00
2013-06-13 20:23:34 +00:00
2013-03-12 15:18:14 +00:00
2013-04-30 17:52:57 +00:00
2013-03-18 20:31:44 +00:00
2013-01-14 22:04:38 +00:00
2012-07-02 19:09:46 +00:00
2013-04-30 17:52:57 +00:00
2012-07-02 18:37:59 +00:00
2013-02-21 17:12:27 +00:00
2013-02-21 17:12:27 +00:00
2013-02-21 17:12:27 +00:00
2013-06-13 20:23:34 +00:00
2013-02-21 17:12:27 +00:00
2013-02-21 17:12:27 +00:00
2013-02-21 17:12:27 +00:00
2013-02-21 17:12:27 +00:00
2013-02-21 17:12:27 +00:00
2013-02-21 00:38:25 +00:00
2013-02-21 00:38:25 +00:00
2013-02-21 00:38:25 +00:00
2012-11-27 23:36:26 +00:00
2013-05-30 03:05:14 +00:00
2013-06-13 20:23:34 +00:00
2012-11-14 23:23:27 +00:00
2013-01-09 03:36:49 +00:00
2012-11-09 19:18:49 +00:00
2011-06-17 03:14:27 +00:00
2011-05-01 15:44:13 +00:00
2010-11-02 23:01:44 +00:00
2010-11-02 23:01:44 +00:00
2013-05-15 21:37:41 +00:00
2012-07-02 12:47:22 +00:00
2012-10-10 20:54:15 +00:00
2013-05-08 12:16:14 +00:00
2013-04-01 15:58:15 +00:00
2011-06-20 15:28:39 +00:00
2012-11-05 19:39:45 +00:00
2013-06-13 20:23:34 +00:00
2012-09-18 19:51:44 +00:00
2011-06-17 15:21:10 +00:00
2012-08-06 21:21:44 +00:00
2012-09-18 16:55:29 +00:00
2012-04-01 20:08:17 +00:00
2012-11-14 23:23:27 +00:00
2012-03-24 03:53:55 +00:00
2012-08-28 02:10:15 +00:00
2012-06-22 22:31:00 +00:00
2011-10-17 16:01:41 +00:00
2011-05-02 15:58:16 +00:00
2012-04-16 03:33:22 +00:00
2012-10-29 17:49:34 +00:00
2012-08-29 20:22:24 +00:00
2012-09-24 20:47:19 +00:00
2013-01-28 18:36:58 +00:00
2013-04-12 04:06:46 +00:00
2013-04-02 18:37:08 +00:00
2013-04-03 13:05:44 +00:00
2013-02-01 22:59:51 +00:00
2013-01-17 19:46:51 +00:00
2013-03-19 08:09:38 +00:00
2013-05-16 16:15:18 +00:00
2013-07-01 20:52:27 +00:00
2012-08-28 02:10:33 +00:00
2012-07-02 12:47:22 +00:00
2010-11-14 22:22:14 +00:00
2013-03-12 16:27:52 +00:00
2013-06-28 20:00:07 +00:00
2012-07-02 19:09:46 +00:00
2013-04-08 16:24:03 +00:00
2013-04-30 17:52:57 +00:00
2012-12-30 19:03:32 +00:00
2011-03-04 20:03:14 +00:00
2012-07-02 12:47:22 +00:00
2013-03-27 00:02:20 +00:00
2012-07-02 12:47:22 +00:00
2013-06-28 20:18:14 +00:00
2013-02-08 21:35:47 +00:00
2013-04-01 18:18:44 +00:00
2010-11-14 22:22:14 +00:00
2013-03-19 19:52:04 +00:00
2013-06-13 20:23:34 +00:00
2013-06-13 20:23:34 +00:00
2013-04-27 00:43:16 +00:00
2013-04-30 17:52:57 +00:00
2013-04-30 17:52:57 +00:00
2012-06-19 02:34:32 +00:00
2013-02-26 21:28:57 +00:00
2013-02-21 00:38:25 +00:00
2013-05-30 03:05:14 +00:00
2013-03-27 02:40:14 +00:00
2013-05-30 03:05:14 +00:00
2012-12-14 17:02:38 +00:00
2013-03-27 02:40:14 +00:00
2013-05-30 03:05:14 +00:00
2013-03-27 02:40:14 +00:00
2013-03-27 02:40:14 +00:00
2012-07-02 12:47:22 +00:00
2013-03-19 15:23:39 +00:00
2013-05-26 18:08:30 +00:00
2013-03-15 15:27:13 +00:00
2010-11-14 22:22:14 +00:00
2013-06-28 22:29:56 +00:00
2013-02-20 20:41:42 +00:00
2012-10-29 21:18:16 +00:00
2013-03-12 15:18:14 +00:00
2012-06-10 19:32:29 +00:00
2013-03-09 18:25:40 +00:00
2013-02-20 22:43:03 +00:00
2012-10-08 17:27:24 +00:00
2013-01-12 19:06:44 +00:00
2012-11-30 19:15:10 +00:00
2013-03-29 08:57:48 +00:00
2012-12-19 15:49:14 +00:00
2012-10-30 18:29:42 +00:00
2011-07-11 16:21:52 +00:00
2013-03-27 00:02:20 +00:00
2013-06-13 20:23:34 +00:00