Skip to content

Commit ab6f272

Browse files
Renamed SCYL kernels to SPIR kernels
1 parent e30b2bf commit ab6f272

File tree

8 files changed

+45
-43
lines changed

8 files changed

+45
-43
lines changed

llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ class DeadArgumentEliminationPass
7474
enum Liveness { Live, MaybeLive };
7575

7676
DeadArgumentEliminationPass(bool ShouldHackArguments_ = false,
77-
bool CheckSyclKernels_ = false)
77+
bool CheckSpirKernels_ = false)
7878
: ShouldHackArguments(ShouldHackArguments_),
79-
CheckSyclKernels(CheckSyclKernels_) {}
79+
CheckSpirKernels(CheckSpirKernels_) {}
8080

8181
PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
8282

@@ -123,9 +123,9 @@ class DeadArgumentEliminationPass
123123
/// (used only by bugpoint).
124124
bool ShouldHackArguments = false;
125125

126-
/// This allows to eliminate dead arguments in SYCL kernel functions with
127-
/// external linkage
128-
bool CheckSyclKernels = false;
126+
/// This allows to eliminate dead arguments in SPIR kernel functions with
127+
/// external linkage in SYCL environment
128+
bool CheckSpirKernels = false;
129129

130130
private:
131131
Liveness MarkIfNotLive(RetOrArg Use, UseVector &MaybeLiveUses);

llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ namespace {
8484
if (skipModule(M))
8585
return false;
8686
DeadArgumentEliminationPass DAEP(ShouldHackArguments(),
87-
CheckSyclKernels());
87+
CheckSpirKernels());
8888
ModuleAnalysisManager DummyMAM;
8989
PreservedAnalyses PA = DAEP.run(M, DummyMAM);
9090
return !PA.areAllPreserved();
9191
}
9292

9393
virtual bool ShouldHackArguments() const { return false; }
94-
virtual bool CheckSyclKernels() const { return false; }
94+
virtual bool CheckSpirKernels() const { return false; }
9595
};
9696

9797
} // end anonymous namespace
@@ -111,7 +111,7 @@ namespace {
111111
DAH() : DAE(ID) {}
112112

113113
bool ShouldHackArguments() const override { return true; }
114-
bool CheckSyclKernels() const override { return false; }
114+
bool CheckSpirKernels() const override { return false; }
115115
};
116116

117117
} // end anonymous namespace
@@ -124,7 +124,7 @@ INITIALIZE_PASS(DAH, "deadarghaX0r",
124124

125125
namespace {
126126

127-
/// DAESYCL - DeadArgumentElimination pass for SYCL kernel functions even
127+
/// DAESYCL - DeadArgumentElimination pass for SPIR kernel functions even
128128
/// if they are external.
129129
struct DAESYCL : public DAE {
130130
static char ID;
@@ -134,19 +134,21 @@ struct DAESYCL : public DAE {
134134
}
135135

136136
StringRef getPassName() const override {
137-
return "Dead Argument Elimination for SYCL kernels";
137+
return "Dead Argument Elimination for SPIR kernels in SYCL environment";
138138
}
139139

140140
bool ShouldHackArguments() const override { return false; }
141-
bool CheckSyclKernels() const override { return true; }
141+
bool CheckSpirKernels() const override { return true; }
142142
};
143143

144144
} // end anonymous namespace
145145

146146
char DAESYCL::ID = 0;
147147

148-
INITIALIZE_PASS(DAESYCL, "deadargelim-sycl",
149-
"Dead Argument Elimination for SYCL kernels", false, false)
148+
INITIALIZE_PASS(
149+
DAESYCL, "deadargelim-sycl",
150+
"Dead Argument Elimination for SPIR kernels in SYCL environment", false,
151+
false)
150152

151153
/// createDeadArgEliminationPass - This pass removes arguments from functions
152154
/// which are not used by the body of the function.
@@ -573,12 +575,12 @@ void DeadArgumentEliminationPass::SurveyFunction(const Function &F) {
573575
}
574576

575577
// We can't modify arguments if the function is not local
576-
// but we can do so for SYCL kernel function.
577-
bool FuncIsSyclKernel =
578-
CheckSyclKernels &&
578+
// but we can do so for SPIR kernel function in SYCL environment.
579+
bool FuncIsSpirKernel =
580+
CheckSpirKernels &&
579581
StringRef(F.getParent()->getTargetTriple()).contains("sycldevice") &&
580582
F.getCallingConv() == CallingConv::SPIR_KERNEL;
581-
bool FuncIsLive = !F.hasLocalLinkage() && !FuncIsSyclKernel;
583+
bool FuncIsLive = !F.hasLocalLinkage() && !FuncIsSpirKernel;
582584
if (FuncIsLive && (!ShouldHackArguments || F.isIntrinsic())) {
583585
MarkLive(F);
584586
return;
@@ -768,10 +770,10 @@ void DeadArgumentEliminationPass::PropagateLiveness(const RetOrArg &RA) {
768770
// false, false,
769771
// // OMIT_TABLE_END
770772
// };
771-
// TODO: batch changes to multiple SYCL kernels and do one bulk update.
773+
// TODO: batch changes to multiple SPIR kernels and do one bulk update.
772774
constexpr StringLiteral OMIT_TABLE_BEGIN("// OMIT_TABLE_BEGIN");
773775
constexpr StringLiteral OMIT_TABLE_END("// OMIT_TABLE_END");
774-
static void updateIntegrationHeader(StringRef SyclKernelName,
776+
static void updateIntegrationHeader(StringRef SpirKernelName,
775777
const ArrayRef<bool> &ArgAlive) {
776778
ErrorOr<std::unique_ptr<MemoryBuffer>> IntHeaderBuffer =
777779
MemoryBuffer::getFile(IntegrationHeaderFileName);
@@ -796,14 +798,14 @@ static void updateIntegrationHeader(StringRef SyclKernelName,
796798

797799
StringRef OmitArgTable = IntHeader.slice(BeginRegionPos, EndRegionPos);
798800

799-
// 2. Find the line that corresponds to the SYCL kernel
800-
if (!OmitArgTable.contains(SyclKernelName))
801+
// 2. Find the line that corresponds to the SPIR kernel
802+
if (!OmitArgTable.contains(SpirKernelName))
801803
report_fatal_error(
802804
"Argument table not found in integration header for function '" +
803-
SyclKernelName + "'");
805+
SpirKernelName + "'");
804806

805807
size_t BeginLinePos =
806-
OmitArgTable.find(SyclKernelName) + SyclKernelName.size();
808+
OmitArgTable.find(SpirKernelName) + SpirKernelName.size();
807809
size_t EndLinePos = OmitArgTable.find("//", BeginLinePos);
808810

809811
StringRef OmitArgLine = OmitArgTable.slice(BeginLinePos, EndLinePos);
@@ -873,7 +875,7 @@ bool DeadArgumentEliminationPass::RemoveDeadStuffFromFunction(Function *F) {
873875
}
874876
}
875877

876-
if (CheckSyclKernels)
878+
if (CheckSpirKernels)
877879
updateIntegrationHeader(F->getName(), ArgAlive);
878880

879881
// Find out the new return value.
@@ -1193,7 +1195,7 @@ PreservedAnalyses DeadArgumentEliminationPass::run(Module &M,
11931195
ModuleAnalysisManager &) {
11941196
// Integration header file must be provided for
11951197
// DAE to work on SPIR kernels.
1196-
if (CheckSyclKernels && !IntegrationHeaderFileName.getNumOccurrences())
1198+
if (CheckSpirKernels && !IntegrationHeaderFileName.getNumOccurrences())
11971199
return PreservedAnalyses::all();
11981200

11991201
bool Changed = false;

llvm/test/Transforms/DeadArgElim/sycl-kernels-neg1.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
target triple = "spir64-unknown-unknown-sycldevice"
66

7-
define weak_odr spir_kernel void @NegativeSyclKernel(float %arg1, float %arg2) {
8-
; CHECK-LABEL: define {{[^@]+}}@NegativeSyclKernel
7+
define weak_odr spir_kernel void @NegativeSpirKernel(float %arg1, float %arg2) {
8+
; CHECK-LABEL: define {{[^@]+}}@NegativeSpirKernel
99
; CHECK-SAME: (float [[ARG1:%.*]], float [[ARG2:%.*]])
1010
; CHECK-NEXT: call void @foo(float [[ARG1]])
1111
; CHECK-NEXT: ret void

llvm/test/Transforms/DeadArgElim/sycl-kernels-neg2.ll

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

66
target triple = "spir64-unknown-unknown-sycldevice"
77

8-
define weak_odr spir_kernel void @NegativeSyclKernel(float %arg1, float %arg2) {
8+
define weak_odr spir_kernel void @NegativeSpirKernel(float %arg1, float %arg2) {
99
call void @foo(float %arg1)
1010
ret void
1111
}

llvm/test/Transforms/DeadArgElim/sycl-kernels-neg3.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; RUN: echo 'static constexpr const bool param_omit_table[] = {' >> %t-int_header.h
2-
; RUN: echo ' // NegativeSyclKernel' >> %t-int_header.h
2+
; RUN: echo ' // NegativeSpirKernel' >> %t-int_header.h
33
; RUN: echo ' false, false,' >> %t-int_header.h
44
; RUN: echo '};' >> %t-int_header.h
55
; RUN: not --crash opt < %s -deadargelim-sycl -S -integr-header-file %t-int_header.h
@@ -8,7 +8,7 @@
88

99
target triple = "spir64-unknown-unknown-sycldevice"
1010

11-
define weak_odr spir_kernel void @NegativeSyclKernel(float %arg1, float %arg2) {
11+
define weak_odr spir_kernel void @NegativeSpirKernel(float %arg1, float %arg2) {
1212
call void @foo(float %arg1)
1313
ret void
1414
}

llvm/test/Transforms/DeadArgElim/sycl-kernels-neg4.ll

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

1111
target triple = "spir64-unknown-unknown-sycldevice"
1212

13-
define weak_odr spir_kernel void @NegativeSyclKernel(float %arg1, float %arg2) {
13+
define weak_odr spir_kernel void @NegativeSpirKernel(float %arg1, float %arg2) {
1414
call void @foo(float %arg1)
1515
ret void
1616
}

llvm/test/Transforms/DeadArgElim/sycl-kernels-neg5.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
target triple = "spir64-unknown-unknown-sycldevice"
99

10-
define weak_odr void @NotASyclKernel(float %arg1, float %arg2) {
11-
; CHECK-LABEL: define {{[^@]+}}@NotASyclKernel
10+
define weak_odr void @NotASpirKernel(float %arg1, float %arg2) {
11+
; CHECK-LABEL: define {{[^@]+}}@NotASpirKernel
1212
; CHECK-SAME: (float [[ARG1:%.*]], float [[ARG2:%.*]])
1313
; CHECK-NEXT: call void @foo(float [[ARG1]])
1414
; CHECK-NEXT: ret void

llvm/test/Transforms/DeadArgElim/sycl-kernels.ll

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
; RUN: echo 'some code we want to preserve' >> %t-int_header.h
33
; RUN: echo 'static constexpr const bool param_omit_table[] = {' >> %t-int_header.h
44
; RUN: echo ' // OMIT_TABLE_BEGIN' >> %t-int_header.h
5-
; RUN: echo ' // SyclKernel1' >> %t-int_header.h
5+
; RUN: echo ' // SpirKernel1' >> %t-int_header.h
66
; RUN: echo ' false, false,' >> %t-int_header.h
7-
; RUN: echo ' // SyclKernel2' >> %t-int_header.h
7+
; RUN: echo ' // SpirKernel2' >> %t-int_header.h
88
; RUN: echo ' false, false,' >> %t-int_header.h
99
; RUN: echo ' // OMIT_TABLE_END' >> %t-int_header.h
1010
; RUN: echo '};' >> %t-int_header.h
@@ -18,13 +18,13 @@
1818

1919
target triple = "spir64-unknown-unknown-sycldevice"
2020

21-
define weak_odr spir_kernel void @SyclKernel1(float %arg1, float %arg2) {
22-
; CHECK-LABEL: define {{[^@]+}}@SyclKernel1
21+
define weak_odr spir_kernel void @SpirKernel1(float %arg1, float %arg2) {
22+
; CHECK-LABEL: define {{[^@]+}}@SpirKernel1
2323
; CHECK-SAME: (float [[ARG1:%.*]], float [[ARG2:%.*]])
2424
; CHECK-NEXT: call void @foo(float [[ARG1]])
2525
; CHECK-NEXT: ret void
2626
;
27-
; CHECK-SYCL-LABEL: define {{[^@]+}}@SyclKernel1
27+
; CHECK-SYCL-LABEL: define {{[^@]+}}@SpirKernel1
2828
; CHECK-SYCL-SAME: (float [[ARG1:%.*]])
2929
; CHECK-SYCL-NEXT: call void @foo(float [[ARG1]])
3030
; CHECK-SYCL-NEXT: ret void
@@ -33,13 +33,13 @@ define weak_odr spir_kernel void @SyclKernel1(float %arg1, float %arg2) {
3333
ret void
3434
}
3535

36-
define weak_odr spir_kernel void @SyclKernel2(float %arg1, float %arg2) {
37-
; CHECK-LABEL: define {{[^@]+}}@SyclKernel2
36+
define weak_odr spir_kernel void @SpirKernel2(float %arg1, float %arg2) {
37+
; CHECK-LABEL: define {{[^@]+}}@SpirKernel2
3838
; CHECK-SAME: (float [[ARG1:%.*]], float [[ARG2:%.*]])
3939
; CHECK-NEXT: call void @foo(float [[ARG2]])
4040
; CHECK-NEXT: ret void
4141
;
42-
; CHECK-SYCL-LABEL: define {{[^@]+}}@SyclKernel2
42+
; CHECK-SYCL-LABEL: define {{[^@]+}}@SpirKernel2
4343
; CHECK-SYCL-SAME: (float [[ARG2:%.*]])
4444
; CHECK-SYCL-NEXT: call void @foo(float [[ARG2]])
4545
; CHECK-SYCL-NEXT: ret void
@@ -51,9 +51,9 @@ define weak_odr spir_kernel void @SyclKernel2(float %arg1, float %arg2) {
5151
; CHECK-INT-HEADER: some code we want to preserve
5252
; CHECK-INT-HEADER: static constexpr const bool param_omit_table[] = {
5353
; CHECK-INT-HEADER: // OMIT_TABLE_BEGIN
54-
; CHECK-INT-HEADER: // SyclKernel1
54+
; CHECK-INT-HEADER: // SpirKernel1
5555
; CHECK-INT-HEADER: false, true,
56-
; CHECK-INT-HEADER: // SyclKernel2
56+
; CHECK-INT-HEADER: // SpirKernel2
5757
; CHECK-INT-HEADER: true, false,
5858
; CHECK-INT-HEADER: // OMIT_TABLE_END
5959
; CHECK-INT-HEADER: };

0 commit comments

Comments
 (0)