Skip to content

Commit 0496e16

Browse files
committed
[RISCV] Enable merging of external globals by default
1 parent eb00182 commit 0496e16

File tree

6 files changed

+22
-27
lines changed

6 files changed

+22
-27
lines changed

llvm/lib/Target/RISCV/RISCVTargetMachine.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,9 @@ static cl::opt<cl::boolOrDefault>
5151
EnableGlobalMerge("riscv-enable-global-merge", cl::Hidden,
5252
cl::desc("Enable the global merge pass"));
5353

54-
static cl::opt<bool> ForceEnableGlobalMergeExternalGlobals(
55-
"riscv-force-enable-global-merge-external-globals", cl::Hidden,
56-
cl::init(false),
57-
cl::desc(
58-
"If the global merge pass is enabled, force enable global merging of "
59-
"external globals (overriding any logic that might disable it)"));
54+
static cl::opt<bool> DisableGlobalMergeExternalGlobals(
55+
"riscv-disable-global-merge-external-globals", cl::Hidden, cl::init(false),
56+
cl::desc("Disable global merging of external globals"));
6057

6158
static cl::opt<bool>
6259
EnableMachineCombiner("riscv-enable-machine-combiner",
@@ -484,7 +481,7 @@ bool RISCVPassConfig::addPreISel() {
484481
addPass(createGlobalMergePass(TM, /* MaxOffset */ 2047,
485482
/* OnlyOptimizeForSize */ false,
486483
/* MergeExternalByDefault */
487-
ForceEnableGlobalMergeExternalGlobals));
484+
!DisableGlobalMergeExternalGlobals));
488485
}
489486

490487
return false;

llvm/test/CodeGen/RISCV/global-merge-minsize-smalldata-nonzero.ll

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2-
; RUN: llc -mtriple=riscv64 -riscv-force-enable-global-merge-external-globals \
3-
; RUN: -verify-machineinstrs < %s | FileCheck %s -check-prefix=SMALL-DATA
4-
; RUN: llc -mtriple=riscv64 -global-merge-min-data-size=0 \
5-
; RUN: -riscv-force-enable-global-merge-external-globals -verify-machineinstrs < %s \
2+
; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
3+
; RUN: | FileCheck %s -check-prefix=SMALL-DATA
4+
; RUN: llc -mtriple=riscv64 -global-merge-min-data-size=0 -verify-machineinstrs < %s \
65
; RUN: | FileCheck %s -check-prefix=MINSIZE
76

87
@ig1 = internal global i32 0, align 4

llvm/test/CodeGen/RISCV/global-merge-minsize-smalldata-zero.ll

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2-
; RUN: llc -mtriple=riscv32 -riscv-force-enable-global-merge-external-globals \
3-
; RUN: -verify-machineinstrs < %s | FileCheck %s -check-prefix=SMALL-DATA
4-
; RUN: llc -mtriple=riscv64 -global-merge-min-data-size=5 \
5-
; RUN: -riscv-force-enable-global-merge-external-globals -verify-machineinstrs < %s \
2+
; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
3+
; RUN: | FileCheck %s -check-prefix=SMALL-DATA
4+
; RUN: llc -mtriple=riscv64 -global-merge-min-data-size=5 -verify-machineinstrs < %s \
65
; RUN: | FileCheck %s -check-prefix=MINSIZE
76

87
@ig1 = internal global i32 0, align 4

llvm/test/CodeGen/RISCV/global-merge-minsize.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2-
; RUN: llc -mtriple=riscv32 -riscv-force-enable-global-merge-external-globals \
2+
; RUN: llc -mtriple=riscv32 \
33
; RUN: -verify-machineinstrs < %s | FileCheck %s -check-prefix=RV32
44
; RUN: llc -mtriple=riscv32 -global-merge-min-data-size=5 \
5-
; RUN: -riscv-force-enable-global-merge-external-globals -verify-machineinstrs < %s | FileCheck %s -check-prefix=RV32-MINSIZE
5+
; RUN: -verify-machineinstrs < %s | FileCheck %s -check-prefix=RV32-MINSIZE
66

77
@ig1 = internal global i32 0, align 4
88
@ig2 = internal global i32 0, align 4

llvm/test/CodeGen/RISCV/global-merge-offset.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
22
; RUN: sed 's/ArrSize/100/g' %s | llc -mtriple=riscv32 \
3-
; RUN: -riscv-force-enable-global-merge-external-globals -verify-machineinstrs | FileCheck %s
3+
; RUN: -verify-machineinstrs | FileCheck %s
44
; RUN: sed 's/ArrSize/100/g' %s | llc -mtriple=riscv64 \
5-
; RUN: -riscv-force-enable-global-merge-external-globals -verify-machineinstrs | FileCheck %s
5+
; RUN: -verify-machineinstrs | FileCheck %s
66
; RUN: sed 's/ArrSize/101/g' %s | llc -mtriple=riscv32 \
7-
; RUN: -riscv-force-enable-global-merge-external-globals -verify-machineinstrs | FileCheck %s -check-prefix=CHECK-TOOBIG
7+
; RUN: -verify-machineinstrs | FileCheck %s -check-prefix=CHECK-TOOBIG
88
; RUN: sed 's/ArrSize/101/g' %s | llc -mtriple=riscv64 \
9-
; RUN: -riscv-force-enable-global-merge-external-globals -verify-machineinstrs | FileCheck %s -check-prefix=CHECK-TOOBIG
9+
; RUN: -verify-machineinstrs | FileCheck %s -check-prefix=CHECK-TOOBIG
1010

1111
; This test demonstrates that the MaxOffset is set correctly for RISC-V by
1212
; constructing an input that is at the limit and comparing.

llvm/test/CodeGen/RISCV/global-merge.ll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2-
; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s | FileCheck %s
3-
; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s | FileCheck %s
4-
; RUN: llc -mtriple=riscv32 \
5-
; RUN: -riscv-force-enable-global-merge-external-globals -verify-machineinstrs < %s \
2+
; RUN: llc -mtriple=riscv32 -riscv-disable-global-merge-external-globals \
3+
; RUN: -verify-machineinstrs < %s | FileCheck %s
4+
; RUN: llc -mtriple=riscv64 -riscv-disable-global-merge-external-globals \
5+
; RUN: -verify-machineinstrs < %s | FileCheck %s
6+
; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
67
; RUN: | FileCheck -check-prefix=CHECK-WEXTERN %s
7-
; RUN: llc -mtriple=riscv64 \
8-
; RUN: -riscv-force-enable-global-merge-external-globals -verify-machineinstrs < %s \
8+
; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
99
; RUN: | FileCheck -check-prefix=CHECK-WEXTERN %s
1010

1111
@ig1 = internal global i32 0, align 4

0 commit comments

Comments
 (0)