Skip to content

Commit 076897f

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:33f3ebc86e7d3afcb65c551feba5bbc2421b42ed into amd-gfx:f1e094d86999
Local branch amd-gfx f1e094d Merged main:1193f7d6487d2d94009f8d8d27da3907136482b9 into amd-gfx:56dd30a1ccd0 Remote branch main 33f3ebc [AMDGPU][LTO] Assume closed world after linking (llvm#105845)
2 parents f1e094d + 33f3ebc commit 076897f

File tree

5 files changed

+195
-3
lines changed

5 files changed

+195
-3
lines changed

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 509558
19+
#define LLVM_MAIN_REVISION 509560
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,10 @@ static bool runImpl(Module &M, AnalysisGetter &AG, TargetMachine &TM,
10661066

10671067
Attributor A(Functions, InfoCache, AC);
10681068

1069+
LLVM_DEBUG(dbgs() << "Module " << M.getName() << " is "
1070+
<< (AC.IsClosedWorldModule ? "" : "not ")
1071+
<< "assumed to be a closed world.\n");
1072+
10691073
for (Function &F : M) {
10701074
if (F.isIntrinsic())
10711075
continue;

llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,8 +762,12 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
762762
// module is partitioned for codegen.
763763
if (EnableLowerModuleLDS)
764764
PM.addPass(AMDGPULowerModuleLDSPass(*this));
765-
if (EnableAMDGPUAttributor && Level != OptimizationLevel::O0)
766-
PM.addPass(AMDGPUAttributorPass(*this));
765+
766+
if (EnableAMDGPUAttributor && Level != OptimizationLevel::O0) {
767+
AMDGPUAttributorOptions Opts;
768+
Opts.IsClosedWorld = true;
769+
PM.addPass(AMDGPUAttributorPass(*this, Opts));
770+
}
767771
});
768772

769773
PB.registerRegClassFilterParsingCallback(
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
; RUN: opt -O3 -debug-only=amdgpu-attributor -S -o - %s 2>&1 | FileCheck %s --check-prefix=PRE-LINK
2+
; RUN: opt -passes="lto<O3>" -debug-only=amdgpu-attributor -S -o - %s 2>&1 | FileCheck %s --check-prefix=POST-LINK
3+
4+
target triple = "amdgcn-amd-amdhsa"
5+
6+
; PRE-LINK: Module {{.*}} is not assumed to be a closed world.
7+
; POST-LINK: Module {{.*}} is assumed to be a closed world.
8+
define hidden noundef i32 @_Z3foov() {
9+
ret i32 1
10+
}
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
// RUN: mlir-opt %s --convert-scf-to-cf --convert-cf-to-llvm --convert-vector-to-llvm \
2+
// RUN: --convert-func-to-llvm --convert-arith-to-llvm | \
3+
// RUN: mlir-cpu-runner -e entry -entry-point-result=void \
4+
// RUN: --shared-libs=%mlir_c_runner_utils | \
5+
// RUN: FileCheck %s --match-full-lines
6+
7+
func.func @cmpi_eq_i1(%v1 : i1, %v2 : i1) {
8+
vector.print str "@cmpi_eq_i1\n"
9+
%res = arith.cmpi eq, %v1, %v2 : i1
10+
vector.print %res : i1
11+
return
12+
}
13+
14+
func.func @cmpi_slt_i1(%v1 : i1, %v2 : i1) {
15+
vector.print str "@cmpi_slt_i1\n"
16+
%res = arith.cmpi slt, %v1, %v2 : i1
17+
vector.print %res : i1
18+
return
19+
}
20+
21+
func.func @cmpi_sle_i1(%v1 : i1, %v2 : i1) {
22+
vector.print str "@cmpi_sle_i1\n"
23+
%res = arith.cmpi sle, %v1, %v2 : i1
24+
vector.print %res : i1
25+
return
26+
}
27+
28+
func.func @cmpi_sgt_i1(%v1 : i1, %v2 : i1) {
29+
vector.print str "@cmpi_sgt_i1\n"
30+
%res = arith.cmpi sgt, %v1, %v2 : i1
31+
vector.print %res : i1
32+
return
33+
}
34+
35+
func.func @cmpi_sge_i1(%v1 : i1, %v2 : i1) {
36+
vector.print str "@cmpi_sge_i1\n"
37+
%res = arith.cmpi sge, %v1, %v2 : i1
38+
vector.print %res : i1
39+
return
40+
}
41+
42+
func.func @cmpi_eq() {
43+
// ------------------------------------------------
44+
// Test i1
45+
// ------------------------------------------------
46+
%false_i1 = arith.constant 0 : i1
47+
%true_i1 = arith.constant 1 : i1
48+
%true_i1_n1 = arith.constant -1 : i1
49+
50+
// int values 1 and -1 are represented with the same bitvector (`0b1`)
51+
// CHECK-LABEL: @cmpi_eq_i1
52+
// CHECK-NEXT: 1
53+
func.call @cmpi_eq_i1(%true_i1, %true_i1_n1) : (i1, i1) -> ()
54+
55+
// CHECK-LABEL: @cmpi_eq_i1
56+
// CHECK-NEXT: 0
57+
func.call @cmpi_eq_i1(%false_i1, %true_i1) : (i1, i1) -> ()
58+
59+
// CHECK-LABEL: @cmpi_eq_i1
60+
// CHECK-NEXT: 0
61+
func.call @cmpi_eq_i1(%true_i1, %false_i1) : (i1, i1) -> ()
62+
63+
// CHECK-LABEL: @cmpi_eq_i1
64+
// CHECK-NEXT: 1
65+
func.call @cmpi_eq_i1(%true_i1, %true_i1) : (i1, i1) -> ()
66+
67+
// CHECK-LABEL: @cmpi_eq_i1
68+
// CHECK-NEXT: 1
69+
func.call @cmpi_eq_i1(%false_i1, %false_i1) : (i1, i1) -> ()
70+
71+
%false = arith.constant false
72+
%true = arith.constant true
73+
74+
// CHECK-LABEL: @cmpi_eq_i1
75+
// CHECK-NEXT: 1
76+
func.call @cmpi_eq_i1(%true, %true_i1) : (i1, i1) -> ()
77+
78+
// CHECK-LABEL: @cmpi_eq_i1
79+
// CHECK-NEXT: 1
80+
func.call @cmpi_eq_i1(%false, %false_i1) : (i1, i1) -> ()
81+
82+
// CHECK-LABEL: @cmpi_eq_i1
83+
// CHECK-NEXT: 1
84+
func.call @cmpi_eq_i1(%true, %true_i1_n1) : (i1, i1) -> ()
85+
86+
// ------------------------------------------------
87+
// TODO: Test i8, i16 etc..
88+
// ------------------------------------------------
89+
return
90+
}
91+
92+
func.func @cmpi_signed() {
93+
// ------------------------------------------------
94+
// Test i1
95+
// ------------------------------------------------
96+
%false_i1 = arith.constant 0 : i1
97+
%true_i1 = arith.constant 1 : i1
98+
%true_i1_n1 = arith.constant -1 : i1
99+
100+
// int values 1 and -1 are represented with the same bitvector (`0b1`)
101+
// But, bitvector `1` is interpreted as int value -1 in signed comparison
102+
103+
// CHECK-LABEL: @cmpi_sge_i1
104+
// CHECK-NEXT: 1
105+
func.call @cmpi_sge_i1(%false_i1, %true_i1_n1) : (i1, i1) -> ()
106+
107+
// CHECK-LABEL: @cmpi_sge_i1
108+
// CHECK-NEXT: 1
109+
func.call @cmpi_sge_i1(%false_i1, %true_i1) : (i1, i1) -> ()
110+
111+
// CHECK-LABEL: @cmpi_sge_i1
112+
// CHECK-NEXT: 0
113+
func.call @cmpi_sge_i1(%true_i1, %false_i1) : (i1, i1) -> ()
114+
115+
%false = arith.constant false
116+
%true = arith.constant true
117+
118+
// CHECK-LABEL: @cmpi_slt_i1
119+
// CHECK-NEXT: 0
120+
func.call @cmpi_slt_i1(%false, %true) : (i1, i1) -> ()
121+
122+
// CHECK-LABEL: @cmpi_sle_i1
123+
// CHECK-NEXT: 0
124+
func.call @cmpi_sle_i1(%false, %true) : (i1, i1) -> ()
125+
126+
// CHECK-LABEL: @cmpi_sgt_i1
127+
// CHECK-NEXT: 1
128+
func.call @cmpi_sgt_i1(%false, %true) : (i1, i1) -> ()
129+
130+
// CHECK-LABEL: @cmpi_sge_i1
131+
// CHECK-NEXT: 1
132+
func.call @cmpi_sge_i1(%false, %true) : (i1, i1) -> ()
133+
134+
// CHECK-LABEL: @cmpi_sge_i1
135+
// CHECK-NEXT: 0
136+
func.call @cmpi_sge_i1(%true, %false) : (i1, i1) -> ()
137+
138+
// ------------------------------------------------
139+
// TODO: Test i8, i16 etc..
140+
// ------------------------------------------------
141+
return
142+
}
143+
144+
func.func @cmpi_ult_index(%v1 : index, %v2 : index) {
145+
vector.print str "@cmpi_ult_index\n"
146+
%res = arith.cmpi ult, %v1, %v2 : index
147+
vector.print %res : i1
148+
return
149+
}
150+
151+
func.func @cmpi_unsigned() {
152+
// ------------------------------------------------
153+
// Test index
154+
// ------------------------------------------------
155+
// 0 `ult` -2^63 = true
156+
%zero = arith.constant 0 : index
157+
%index_min = arith.constant -9223372036854775808 : index
158+
159+
// CHECK-LABEL: @cmpi_ult_index
160+
// CHECK-NEXT: 1
161+
func.call @cmpi_ult_index(%zero, %index_min) : (index, index) -> ()
162+
163+
// ------------------------------------------------
164+
// TODO: i1, i8, i16, uge, ule etc..
165+
// ------------------------------------------------
166+
return
167+
}
168+
169+
func.func @entry() {
170+
func.call @cmpi_eq() : () -> ()
171+
func.call @cmpi_signed() : () -> ()
172+
func.call @cmpi_unsigned() : () -> ()
173+
return
174+
}

0 commit comments

Comments
 (0)