Skip to content

Commit 3938c74

Browse files
Cleanup code after all the mutator changes (#1625)
With this commit, the last call to Type::getPointerElementType in the translator is truly dead, completing the first phase of transitioning to opaque pointers.
1 parent dfc3e2d commit 3938c74

12 files changed

+9
-130
lines changed

lib/SPIRV/OCLUtil.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,25 +1314,6 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
13141314
Function *F; // SPIRV decorated function
13151315
};
13161316

1317-
CallInst *mutateCallInstOCL(
1318-
Module *M, CallInst *CI,
1319-
std::function<std::string(CallInst *, std::vector<Value *> &)> ArgMutate,
1320-
AttributeList *Attrs) {
1321-
OCLBuiltinFuncMangleInfo BtnInfo(CI->getCalledFunction());
1322-
return mutateCallInst(M, CI, ArgMutate, &BtnInfo, Attrs);
1323-
}
1324-
1325-
Instruction *mutateCallInstOCL(
1326-
Module *M, CallInst *CI,
1327-
std::function<std::string(CallInst *, std::vector<Value *> &, Type *&RetTy)>
1328-
ArgMutate,
1329-
std::function<Instruction *(CallInst *)> RetMutate, AttributeList *Attrs,
1330-
bool TakeFuncName) {
1331-
OCLBuiltinFuncMangleInfo BtnInfo(CI->getCalledFunction());
1332-
return mutateCallInst(M, CI, ArgMutate, RetMutate, &BtnInfo, Attrs,
1333-
TakeFuncName);
1334-
}
1335-
13361317
std::unique_ptr<SPIRV::BuiltinFuncMangleInfo> makeMangler(Function &F) {
13371318
return std::make_unique<OCLBuiltinFuncMangleInfo>(&F);
13381319
}

lib/SPIRV/OCLUtil.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -487,20 +487,6 @@ inline OCLMemOrderKind mapSPIRVMemOrderToOCL(unsigned Sema) {
487487
return OCLMemOrderMap::rmap(extractSPIRVMemOrderSemantic(Sema));
488488
}
489489

490-
/// Mutate call instruction to call OpenCL builtin function.
491-
CallInst *mutateCallInstOCL(
492-
Module *M, CallInst *CI,
493-
std::function<std::string(CallInst *, std::vector<Value *> &)> ArgMutate,
494-
AttributeList *Attrs = nullptr);
495-
496-
/// Mutate call instruction to call OpenCL builtin function.
497-
Instruction *mutateCallInstOCL(
498-
Module *M, CallInst *CI,
499-
std::function<std::string(CallInst *, std::vector<Value *> &, Type *&RetTy)>
500-
ArgMutate,
501-
std::function<Instruction *(CallInst *)> RetMutate,
502-
AttributeList *Attrs = nullptr, bool TakeFuncName = false);
503-
504490
/// If the value is a special type initializer (something that bitcasts from
505491
/// spirv.ConstantSampler to spirv.Sampler or likewise for PipeStorage), get the
506492
/// original type initializer, unwrap the bitcast. Otherwise, return nullptr.

lib/SPIRV/SPIRVInternal.h

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -705,20 +705,6 @@ Instruction *mutateCallInst(
705705
BuiltinFuncMangleInfo *Mangle = nullptr, AttributeList *Attrs = nullptr,
706706
bool TakeName = false);
707707

708-
/// Mutate call instruction to call SPIR-V builtin function.
709-
CallInst *mutateCallInstSPIRV(
710-
Module *M, CallInst *CI,
711-
std::function<std::string(CallInst *, std::vector<Value *> &)> ArgMutate,
712-
AttributeList *Attrs = nullptr);
713-
714-
/// Mutate call instruction to call SPIR-V builtin function.
715-
Instruction *mutateCallInstSPIRV(
716-
Module *M, CallInst *CI,
717-
std::function<std::string(CallInst *, std::vector<Value *> &, Type *&RetTy)>
718-
ArgMutate,
719-
std::function<Instruction *(CallInst *)> RetMutate,
720-
AttributeList *Attrs = nullptr);
721-
722708
/// Mutate function by change the arguments.
723709
/// \param ArgMutate mutates the function arguments.
724710
/// \param TakeName Take the original function's name if a new function with
@@ -771,13 +757,6 @@ Value *addVector(Instruction *InsPos, ValueVecRange Range);
771757
void makeVector(Instruction *InsPos, std::vector<Value *> &Ops,
772758
ValueVecRange Range);
773759

774-
/// Expand a vector type value in \param Ops at index \param VecPos.
775-
/// Generate extract element instructions at \param InsPos and replace
776-
/// the vector type value with scalar type values.
777-
/// If the value to be expanded is not vector type, do nothing.
778-
void expandVector(Instruction *InsPos, std::vector<Value *> &Ops,
779-
size_t VecPos);
780-
781760
/// Get size_t type.
782761
IntegerType *getSizetType(Module *M);
783762

@@ -884,11 +863,6 @@ std::string getSPIRVTypeName(StringRef BaseTyName, StringRef Postfixes = "");
884863
/// Checks if given type name is either ConstantSampler or ConsantPipeStorage.
885864
bool isSPIRVConstantName(StringRef TyName);
886865

887-
/// Get SPIR-V type by changing the type name from spirv.OldName.Postfixes
888-
/// to spirv.NewName.Postfixes.
889-
Type *getSPIRVTypeByChangeBaseTypeName(Module *M, Type *T, StringRef OldName,
890-
StringRef NewName);
891-
892866
/// Get SPIR-V type by changing the type name from spirv.OldName.Postfixes
893867
/// to spirv.NewName.Postfixes.
894868
Type *getSPIRVStructTypeByChangeBaseTypeName(Module *M, Type *T,

lib/SPIRV/SPIRVUtil.cpp

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -918,26 +918,6 @@ void getParameterTypes(Function *F, SmallVectorImpl<TypedPointerType *> &ArgTys,
918918
}
919919
}
920920

921-
static Type *toTypedPointerType(Type *T) {
922-
if (!isa<PointerType>(T))
923-
return T;
924-
return TypedPointerType::get(
925-
toTypedPointerType(T->getNonOpaquePointerElementType()),
926-
T->getPointerAddressSpace());
927-
}
928-
929-
// This is a transitional helper function to fill in mangling information for
930-
// mangleBuiltin while all the calls to mutateCallInst are being transitioned.
931-
static void typeMangle(BuiltinFuncMangleInfo *Mangle, ArrayRef<Value *> Args) {
932-
if (!Mangle)
933-
return;
934-
for (unsigned I = 0; I < Args.size(); I++)
935-
if (Args[I]->getType()->isPointerTy()) {
936-
Mangle->getTypeMangleInfo(I).PointerTy =
937-
toTypedPointerType(Args[I]->getType());
938-
}
939-
}
940-
941921
CallInst *mutateCallInst(
942922
Module *M, CallInst *CI,
943923
std::function<std::string(CallInst *, std::vector<Value *> &)> ArgMutate,
@@ -951,7 +931,6 @@ CallInst *mutateCallInst(
951931
InstName = CI->getName().str();
952932
CI->setName(InstName + ".old");
953933
}
954-
typeMangle(Mangle, Args);
955934
auto NewCI = addCallInst(M, NewName, CI->getType(), Args, Attrs, CI, Mangle,
956935
InstName, TakeFuncName);
957936
NewCI->setDebugLoc(CI->getDebugLoc());
@@ -973,7 +952,6 @@ Instruction *mutateCallInst(
973952
Type *RetTy = CI->getType();
974953
auto NewName = ArgMutate(CI, Args, RetTy);
975954
StringRef InstName = CI->getName();
976-
typeMangle(Mangle, Args);
977955
auto NewCI = addCallInst(M, NewName, RetTy, Args, Attrs, CI, Mangle, InstName,
978956
TakeFuncName);
979957
auto NewI = RetMutate(NewCI);
@@ -1014,23 +992,6 @@ void mutateFunction(
1014992
F->eraseFromParent();
1015993
}
1016994

1017-
CallInst *mutateCallInstSPIRV(
1018-
Module *M, CallInst *CI,
1019-
std::function<std::string(CallInst *, std::vector<Value *> &)> ArgMutate,
1020-
AttributeList *Attrs) {
1021-
BuiltinFuncMangleInfo BtnInfo;
1022-
return mutateCallInst(M, CI, ArgMutate, &BtnInfo, Attrs);
1023-
}
1024-
1025-
Instruction *mutateCallInstSPIRV(
1026-
Module *M, CallInst *CI,
1027-
std::function<std::string(CallInst *, std::vector<Value *> &, Type *&RetTy)>
1028-
ArgMutate,
1029-
std::function<Instruction *(CallInst *)> RetMutate, AttributeList *Attrs) {
1030-
BuiltinFuncMangleInfo BtnInfo;
1031-
return mutateCallInst(M, CI, ArgMutate, RetMutate, &BtnInfo, Attrs);
1032-
}
1033-
1034995
CallInst *addCallInst(Module *M, StringRef FuncName, Type *RetTy,
1035996
ArrayRef<Value *> Args, AttributeList *Attrs,
1036997
Instruction *Pos, BuiltinFuncMangleInfo *Mangle,
@@ -1087,22 +1048,6 @@ void makeVector(Instruction *InsPos, std::vector<Value *> &Ops,
10871048
Ops.push_back(Vec);
10881049
}
10891050

1090-
void expandVector(Instruction *InsPos, std::vector<Value *> &Ops,
1091-
size_t VecPos) {
1092-
auto Vec = Ops[VecPos];
1093-
auto *VT = dyn_cast<FixedVectorType>(Vec->getType());
1094-
if (!VT)
1095-
return;
1096-
size_t N = VT->getNumElements();
1097-
IRBuilder<> Builder(InsPos);
1098-
for (size_t I = 0; I != N; ++I)
1099-
Ops.insert(Ops.begin() + VecPos + I,
1100-
Builder.CreateExtractElement(
1101-
Vec, ConstantInt::get(Type::getInt32Ty(InsPos->getContext()),
1102-
I, false)));
1103-
Ops.erase(Ops.begin() + VecPos + N);
1104-
}
1105-
11061051
Constant *castToInt8Ptr(Constant *V, unsigned Addr = 0) {
11071052
return ConstantExpr::getBitCast(V, Type::getInt8PtrTy(V->getContext(), Addr));
11081053
}
@@ -1586,13 +1531,6 @@ bool isSPIRVConstantName(StringRef TyName) {
15861531
return false;
15871532
}
15881533

1589-
Type *getSPIRVTypeByChangeBaseTypeName(Module *M, Type *T, StringRef OldName,
1590-
StringRef NewName) {
1591-
return PointerType::get(
1592-
getSPIRVStructTypeByChangeBaseTypeName(M, T, OldName, NewName),
1593-
SPIRAS_Global);
1594-
}
1595-
15961534
Type *getSPIRVStructTypeByChangeBaseTypeName(Module *M, Type *T,
15971535
StringRef OldName,
15981536
StringRef NewName) {

test/read_image.cl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -triple spir64 -fdeclare-opencl-builtins -finclude-default-header -O0 -cl-std=CL2.0 -emit-llvm-bc %s -o %t.bc -no-opaque-pointers
1+
// RUN: %clang_cc1 -triple spir64 -fdeclare-opencl-builtins -finclude-default-header -O0 -cl-std=CL2.0 -emit-llvm-bc %s -o %t.bc
22
// RUN: llvm-spirv --spirv-max-version=1.3 %t.bc -o %t.spv
33
// RUN: spirv-val %t.spv
44
// RUN: llvm-spirv %t.spv -to-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
@@ -8,7 +8,7 @@
88
// RUN: spirv-val %t.rev.spv
99
// RUN: llvm-spirv --spirv-max-version=1.3 %t.rev.spv -to-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
1010

11-
// CHECK-SPIRV: TypeInt [[IntTy:[0-9]+]]
11+
// CHECK-SPIRV: TypeInt [[IntTy:[0-9]+]] 32
1212
// CHECK-SPIRV: TypeVector [[IVecTy:[0-9]+]] [[IntTy]]
1313
// CHECK-SPIRV: TypeFloat [[FloatTy:[0-9]+]]
1414
// CHECK-SPIRV: TypeVector [[FVecTy:[0-9]+]] [[FloatTy]]

test/transcoding/AtomicCompareExchangeExplicit_cl20.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -triple spir-unknown-unknown -O1 -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header -emit-llvm-bc %s -o %t.bc -no-opaque-pointers
1+
// RUN: %clang_cc1 -triple spir-unknown-unknown -O1 -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header -emit-llvm-bc %s -o %t.bc
22
// RUN: llvm-spirv %t.bc -spirv-text -o %t.txt
33
// RUN: FileCheck < %t.txt %s --check-prefix=CHECK-SPIRV
44
// RUN: llvm-spirv %t.bc -o %t.spv

test/transcoding/OpImageWrite.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -O1 -triple spir-unknown-unknown -cl-std=CL2.0 %s -finclude-default-header -emit-llvm-bc -o %t.bc -no-opaque-pointers
1+
// RUN: %clang_cc1 -O1 -triple spir-unknown-unknown -cl-std=CL2.0 %s -finclude-default-header -emit-llvm-bc -o %t.bc
22
// RUN: llvm-spirv %t.bc -spirv-text -o %t.txt
33
// RUN: FileCheck < %t.txt %s --check-prefix=CHECK-SPIRV
44
// RUN: llvm-spirv %t.bc -o %t.spv

test/transcoding/OpenCL/atomic_cmpxchg.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 %s -triple spir -cl-std=CL1.2 -emit-llvm-bc -fdeclare-opencl-builtins -o %t.bc -no-opaque-pointers
1+
// RUN: %clang_cc1 %s -triple spir -cl-std=CL1.2 -emit-llvm-bc -fdeclare-opencl-builtins -o %t.bc
22
// RUN: llvm-spirv %t.bc -o %t.spv
33
// RUN: spirv-val %t.spv
44
// RUN: llvm-spirv %t.spv -to-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV

test/transcoding/OpenCL/atomic_legacy.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 %s -triple spir -cl-std=CL1.2 -emit-llvm-bc -fdeclare-opencl-builtins -o %t.bc -no-opaque-pointers
1+
// RUN: %clang_cc1 %s -triple spir -cl-std=CL1.2 -emit-llvm-bc -fdeclare-opencl-builtins -o %t.bc
22
// RUN: llvm-spirv %t.bc -o %t.spv
33
// RUN: spirv-val %t.spv
44
// RUN: llvm-spirv %t.spv -to-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV

test/transcoding/SPV_INTEL_media_block_io.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -triple spir-unknown-unknown -O1 -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header -emit-llvm-bc %s -o %t.bc -no-opaque-pointers
1+
// RUN: %clang_cc1 -triple spir-unknown-unknown -O1 -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header -emit-llvm-bc %s -o %t.bc
22
// RUN: llvm-spirv --spirv-ext=+SPV_INTEL_media_block_io %t.bc -o %t.spv
33
// RUN: llvm-spirv %t.spv -to-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
44
// RUN: spirv-val %t.spv

test/transcoding/atomic_explicit_arguments.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -triple spir -cl-std=cl2.0 %s -fdeclare-opencl-builtins -finclude-default-header -emit-llvm-bc -o %t.bc -no-opaque-pointers
1+
// RUN: %clang_cc1 -triple spir -cl-std=cl2.0 %s -fdeclare-opencl-builtins -finclude-default-header -emit-llvm-bc -o %t.bc
22
// RUN: llvm-spirv %t.bc -o %t.spv
33
// RUN: llvm-spirv %t.spv -to-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
44
// RUN: llvm-spirv %t.spv -r --spirv-target-env=CL2.0 -o - | llvm-dis -o - | FileCheck %s --check-prefix=CHECK-LLVM

test/transcoding/atomic_flag.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -triple spir-unknown-unknown -O1 -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header -emit-llvm-bc %s -o %t.bc -no-opaque-pointers
1+
// RUN: %clang_cc1 -triple spir-unknown-unknown -O1 -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header -emit-llvm-bc %s -o %t.bc
22
// RUN: llvm-spirv %t.bc -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
33
// RUN: llvm-spirv %t.bc -o %t.spv
44
// RUN: spirv-val %t.spv

0 commit comments

Comments
 (0)