[PATCH] D10966: [ARM] Make GlobalMerge merge extern globals by default
John Brawn
john.brawn at arm.com
Mon Jul 6 09:41:26 PDT 2015
john.brawn added reviewers: ab, echristo.
john.brawn added a subscriber: llvm-commits.
Herald added subscribers: rengolin, aemerson.
Enabling merging of extern globals appears to be generally either beneficial or harmless. On some benchmarks suites (on Cortex-M4F, Cortex-A9, and Cortex-A57) it gives improvements in the 1-5% range, but in the rest the overall effect is zero.
Repository:
rL LLVM
http://reviews.llvm.org/D10966
Files:
lib/Target/ARM/ARMTargetMachine.cpp
test/CodeGen/ARM/global-merge-external.ll
Index: test/CodeGen/ARM/global-merge-external.ll
===================================================================
--- /dev/null
+++ test/CodeGen/ARM/global-merge-external.ll
@@ -0,0 +1,47 @@
+; RUN: llc < %s -mtriple=arm-eabi -arm-global-merge | FileCheck %s --check-prefix=CHECK-MERGE
+; RUN: llc < %s -mtriple=arm-eabi -arm-global-merge -global-merge-on-external=true | FileCheck %s --check-prefix=CHECK-MERGE
+; RUN: llc < %s -mtriple=arm-eabi -arm-global-merge -global-merge-on-external=false | FileCheck %s --check-prefix=CHECK-NO-MERGE
+
+ at x = global i32 0, align 4
+ at y = global i32 0, align 4
+ at z = global i32 0, align 4
+
+define void @f1(i32 %a1, i32 %a2) {
+;CHECK: f1:
+;CHECK: ldr {{r[0-9]+}}, [[LABEL1:\.LCPI[0-9]+_[0-9]]]
+;CHECK: [[LABEL1]]:
+;CHECK-MERGE: .long _MergedGlobals_x
+;CHECK-NO-MERGE: .long x
+ store i32 %a1, i32* @x, align 4
+ store i32 %a2, i32* @y, align 4
+ ret void
+}
+
+define void @g1(i32 %a1, i32 %a2) {
+;CHECK: g1:
+;CHECK: ldr {{r[0-9]+}}, [[LABEL2:\.LCPI[0-9]+_[0-9]]]
+;CHECK: [[LABEL2]]:
+;CHECK-MERGE: .long _MergedGlobals_x
+;CHECK-NO-MERGE: .long y
+ store i32 %a1, i32* @y, align 4
+ store i32 %a2, i32* @z, align 4
+ ret void
+}
+
+;CHECK-NO-MERGE-NOT: .globl _MergedGlobals_x
+
+;CHECK-MERGE: .type _MergedGlobals_x,%object
+;CHECK-MERGE: .globl _MergedGlobals_x
+;CHECK-MERGE: .align 2
+;CHECK-MERGE: _MergedGlobals_x:
+;CHECK-MERGE: .size _MergedGlobals_x, 12
+
+;CHECK-MERGE: .globl x
+;CHECK-MERGE: x = _MergedGlobals_x
+;CHECK-MERGE: .size x, 4
+;CHECK-MERGE: .globl y
+;CHECK-MERGE: y = _MergedGlobals_x+4
+;CHECK-MERGE: .size y, 4
+;CHECK-MERGE: .globl z
+;CHECK-MERGE: z = _MergedGlobals_x+8
+;CHECK-MERGE: .size z, 4
Index: lib/Target/ARM/ARMTargetMachine.cpp
===================================================================
--- lib/Target/ARM/ARMTargetMachine.cpp
+++ lib/Target/ARM/ARMTargetMachine.cpp
@@ -349,7 +349,9 @@
// tricky when doing code gen per function.
bool OnlyOptimizeForSize = (TM->getOptLevel() < CodeGenOpt::Aggressive) &&
(EnableGlobalMerge == cl::BOU_UNSET);
- addPass(createGlobalMergePass(TM, 127, OnlyOptimizeForSize));
+ // Merging of extern globals is enabled by default as we expect it to be
+ // generally either beneficial or harmless.
+ addPass(createGlobalMergePass(TM, 127, OnlyOptimizeForSize, true));
}
return false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10966.29100.patch
Type: text/x-patch
Size: 2479 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150706/82edba3d/attachment.bin>
More information about the llvm-commits
mailing list