diff options
author | JF Bastien <jfb@google.com> | 2016-04-12 00:03:26 +0000 |
---|---|---|
committer | JF Bastien <jfb@google.com> | 2016-04-12 00:03:26 +0000 |
commit | 4f43cfd2c2b8cfe63c1bb5d6dfbdf8ac6f9c4e76 (patch) | |
tree | 7a35c3aaf52027c74e784bd9b8e2f541831267a2 | |
parent | d52f4128d651348a653e7625e13dc45bafd5e513 (diff) | |
download | bcm5719-llvm-4f43cfd2c2b8cfe63c1bb5d6dfbdf8ac6f9c4e76.tar.gz bcm5719-llvm-4f43cfd2c2b8cfe63c1bb5d6dfbdf8ac6f9c4e76.zip |
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.
llvm-svn: 266022
-rw-r--r-- | llvm/lib/Transforms/IPO/MergeFunctions.cpp | 15 | ||||
-rw-r--r-- | llvm/test/Transforms/MergeFunc/alloca.ll | 42 |
2 files changed, 41 insertions, 16 deletions
diff --git a/llvm/lib/Transforms/IPO/MergeFunctions.cpp b/llvm/lib/Transforms/IPO/MergeFunctions.cpp index d68c05010d7..63e610cc258 100644 --- a/llvm/lib/Transforms/IPO/MergeFunctions.cpp +++ b/llvm/lib/Transforms/IPO/MergeFunctions.cpp @@ -921,15 +921,6 @@ int FunctionComparator::cmpOperations(const Instruction *L, 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(const Instruction *L, } // 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; diff --git a/llvm/test/Transforms/MergeFunc/alloca.ll b/llvm/test/Transforms/MergeFunc/alloca.ll index d9f66d0911d..165fc68365b 100644 --- a/llvm/test/Transforms/MergeFunc/alloca.ll +++ b/llvm/test/Transforms/MergeFunc/alloca.ll @@ -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 +} |