[llvm] r266022 - MergeFunctions: test alloca better
JF Bastien via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 11 17:03:28 PDT 2016
Author: jfb
Date: Mon Apr 11 19:03:26 2016
New Revision: 266022
URL: http://llvm.org/viewvc/llvm-project?rev=266022&view=rev
Log:
MergeFunctions: test alloca better
r237193 fix handling of alloca size / align in MergeFunctions, but only tested one and didn't follow FunctionComparator::cmpOperations's usual comparison pattern. It also didn't update Instruction.cpp:haveSameSpecialState which I'll do separately.
Modified:
llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp
llvm/trunk/test/Transforms/MergeFunc/alloca.ll
Modified: llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp?rev=266022&r1=266021&r2=266022&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp Mon Apr 11 19:03:26 2016
@@ -921,15 +921,6 @@ int FunctionComparator::cmpOperations(co
R->getRawSubclassOptionalData()))
return Res;
- if (const AllocaInst *AI = dyn_cast<AllocaInst>(L)) {
- if (int Res = cmpTypes(AI->getAllocatedType(),
- cast<AllocaInst>(R)->getAllocatedType()))
- return Res;
- if (int Res =
- cmpNumbers(AI->getAlignment(), cast<AllocaInst>(R)->getAlignment()))
- return Res;
- }
-
// We have two instructions of identical opcode and #operands. Check to see
// if all operands are the same type
for (unsigned i = 0, e = L->getNumOperands(); i != e; ++i) {
@@ -939,6 +930,12 @@ int FunctionComparator::cmpOperations(co
}
// Check special state that is a part of some instructions.
+ if (const AllocaInst *AI = dyn_cast<AllocaInst>(L)) {
+ if (int Res = cmpTypes(AI->getAllocatedType(),
+ cast<AllocaInst>(R)->getAllocatedType()))
+ return Res;
+ return cmpNumbers(AI->getAlignment(), cast<AllocaInst>(R)->getAlignment());
+ }
if (const LoadInst *LI = dyn_cast<LoadInst>(L)) {
if (int Res = cmpNumbers(LI->isVolatile(), cast<LoadInst>(R)->isVolatile()))
return Res;
Modified: llvm/trunk/test/Transforms/MergeFunc/alloca.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/MergeFunc/alloca.ll?rev=266022&r1=266021&r2=266022&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/MergeFunc/alloca.ll (original)
+++ llvm/trunk/test/Transforms/MergeFunc/alloca.ll Mon Apr 11 19:03:26 2016
@@ -1,14 +1,18 @@
; RUN: opt -mergefunc -S < %s | FileCheck %s
-;; Make sure that two different sized allocas are not treated as equal.
+;; Make sure that two different allocas are not treated as equal.
target datalayout = "e-m:w-p:32:32-i64:64-f80:32-n8:16:32-S32"
%kv1 = type { i32, i32 }
%kv2 = type { i8 }
+%kv3 = type { i64, i64 }
+; Size difference.
-define void @a(i8 *%f) {
+; CHECK-LABEL: define void @size1
+; CHECK-NOT: call void @
+define void @size1(i8 *%f) {
%v = alloca %kv1, align 8
%f_2 = bitcast i8* %f to void (%kv1 *)*
call void %f_2(%kv1 * %v)
@@ -18,11 +22,9 @@ define void @a(i8 *%f) {
ret void
}
-; CHECK-LABEL: define void @b
-; CHECK-NOT: call @a
-; CHECK: ret
-
-define void @b(i8 *%f) {
+; CHECK-LABEL: define void @size2
+; CHECK-NOT: call void @
+define void @size2(i8 *%f) {
%v = alloca %kv2, align 8
%f_2 = bitcast i8* %f to void (%kv2 *)*
call void %f_2(%kv2 * %v)
@@ -31,3 +33,29 @@ define void @b(i8 *%f) {
call void %f_2(%kv2 * %v)
ret void
}
+
+; Alignment difference.
+
+; CHECK-LABEL: define void @align1
+; CHECK-NOT: call void @
+define void @align1(i8 *%f) {
+ %v = alloca %kv3, align 8
+ %f_2 = bitcast i8* %f to void (%kv3 *)*
+ call void %f_2(%kv3 * %v)
+ call void %f_2(%kv3 * %v)
+ call void %f_2(%kv3 * %v)
+ call void %f_2(%kv3 * %v)
+ ret void
+}
+
+; CHECK-LABEL: define void @align2
+; CHECK-NOT: call void @
+define void @align2(i8 *%f) {
+ %v = alloca %kv3, align 16
+ %f_2 = bitcast i8* %f to void (%kv3 *)*
+ call void %f_2(%kv3 * %v)
+ call void %f_2(%kv3 * %v)
+ call void %f_2(%kv3 * %v)
+ call void %f_2(%kv3 * %v)
+ ret void
+}
More information about the llvm-commits
mailing list