[llvm] r236927 - Fix MergeConsecutiveStore for non-byte-sized memory accesses.
James Y Knight
jyknight at google.com
Fri May 8 20:13:37 PDT 2015
Author: jyknight
Date: Fri May 8 22:13:37 2015
New Revision: 236927
URL: http://llvm.org/viewvc/llvm-project?rev=236927&view=rev
Log:
Fix MergeConsecutiveStore for non-byte-sized memory accesses.
The bug showed up as a compile-time assertion failure:
Assertion `NumBits >= MIN_INT_BITS && "bitwidth too small"' failed
when building msan tests on x86-64.
Prior to r236850, this bug was masked due to a bogus alignment check,
which also accidentally rejected non-byte-sized accesses. Afterwards,
an invalid ElementSizeBytes == 0 got further into the function, and
triggered the assertion failure.
It would probably be a good idea to allow it to handle merging stores
of unusual widths as well, but for now, to un-break it, I'm just
making the minimal fix.
Differential Revision: http://reviews.llvm.org/D9626
Added:
llvm/trunk/test/CodeGen/X86/merge-consecutive-stores-i1.ll
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=236927&r1=236926&r2=236927&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Fri May 8 22:13:37 2015
@@ -10673,6 +10673,10 @@ bool DAGCombiner::MergeConsecutiveStores
bool NoVectors = DAG.getMachineFunction().getFunction()->hasFnAttribute(
Attribute::NoImplicitFloat);
+ // This function cannot currently deal with non-byte-sized memory sizes.
+ if (ElementSizeBytes * 8 != MemVT.getSizeInBits())
+ return false;
+
// Don't merge vectors into wider inputs.
if (MemVT.isVector() || !MemVT.isSimple())
return false;
Added: llvm/trunk/test/CodeGen/X86/merge-consecutive-stores-i1.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/merge-consecutive-stores-i1.ll?rev=236927&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/merge-consecutive-stores-i1.ll (added)
+++ llvm/trunk/test/CodeGen/X86/merge-consecutive-stores-i1.ll Fri May 8 22:13:37 2015
@@ -0,0 +1,15 @@
+; RUN: llc -march=x86-64 < %s
+
+; Ensure that MergeConsecutiveStores doesn't crash when dealing with
+; i1 operands.
+
+%struct.X = type { i1, i1 }
+
+ at b = common global %struct.X zeroinitializer, align 4
+
+define void @foo() {
+entry:
+ store i1 0, i1* getelementptr inbounds (%struct.X, %struct.X* @b, i64 0, i32 0), align 4
+ store i1 0, i1* getelementptr inbounds (%struct.X, %struct.X* @b, i64 0, i32 1), align 1
+ ret void
+}
More information about the llvm-commits
mailing list