summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2015-08-10 23:07:26 +0000
committerSanjay Patel <spatel@rotateright.com>2015-08-10 23:07:26 +0000
commitd967a878fab52807fe38d47bbe711ebf26d6f49f (patch)
tree398a8f4f6119cd0a4e8617574b438d02a507bae5
parent0bc068728ec4cc87361c2425225611731b364803 (diff)
downloadbcm5719-llvm-d967a878fab52807fe38d47bbe711ebf26d6f49f.tar.gz
bcm5719-llvm-d967a878fab52807fe38d47bbe711ebf26d6f49f.zip
fix minsize detection: minsize attribute implies optimizing for size
llvm-svn: 244528
-rw-r--r--llvm/lib/CodeGen/BranchFolding.cpp4
-rw-r--r--llvm/test/CodeGen/X86/tail-opts.ll38
2 files changed, 39 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp
index f2d1bf0a51f..260ab537053 100644
--- a/llvm/lib/CodeGen/BranchFolding.cpp
+++ b/llvm/lib/CodeGen/BranchFolding.cpp
@@ -605,9 +605,7 @@ static bool ProfitableToMerge(MachineBasicBlock *MBB1,
// branch instruction, which is likely to be smaller than the 2
// instructions that would be deleted in the merge.
MachineFunction *MF = MBB1->getParent();
- if (EffectiveTailLen >= 2 &&
- // FIXME: Use Function::optForSize().
- MF->getFunction()->hasFnAttribute(Attribute::OptimizeForSize) &&
+ if (EffectiveTailLen >= 2 && MF->getFunction()->optForSize() &&
(I1 == MBB1->begin() || I2 == MBB2->begin()))
return true;
diff --git a/llvm/test/CodeGen/X86/tail-opts.ll b/llvm/test/CodeGen/X86/tail-opts.ll
index f590176d981..c522ba60d6b 100644
--- a/llvm/test/CodeGen/X86/tail-opts.ll
+++ b/llvm/test/CodeGen/X86/tail-opts.ll
@@ -371,6 +371,44 @@ return:
ret void
}
+; two_minsize - Same as two, but with minsize instead of optsize.
+
+; CHECK-LABEL: two_minsize:
+; CHECK-NOT: XYZ
+; CHECK: ret
+; CHECK: movl $0, XYZ(%rip)
+; CHECK: movl $1, XYZ(%rip)
+; CHECK-NOT: XYZ
+
+define void @two_minsize() nounwind minsize {
+entry:
+ %0 = icmp eq i32 undef, 0
+ br i1 %0, label %bbx, label %bby
+
+bby:
+ switch i32 undef, label %bb7 [
+ i32 16, label %return
+ ]
+
+bb7:
+ store volatile i32 0, i32* @XYZ
+ store volatile i32 1, i32* @XYZ
+ unreachable
+
+bbx:
+ switch i32 undef, label %bb12 [
+ i32 128, label %return
+ ]
+
+bb12:
+ store volatile i32 0, i32* @XYZ
+ store volatile i32 1, i32* @XYZ
+ unreachable
+
+return:
+ ret void
+}
+
; two_nosize - Same as two, but without the optsize attribute.
; Now two instructions are enough to be tail-duplicated.
OpenPOWER on IntegriCloud