Skip to content

Commit 42cf770

Browse files
Use TypedPointerType in lieu of PointerIndirectPair in mangleBuiltin. (#1568)
1 parent e2bb479 commit 42cf770

File tree

7 files changed

+134
-206
lines changed

7 files changed

+134
-206
lines changed

include/LLVMSPIRVLib.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,6 @@ std::unique_ptr<SPIRVModule> readSpirvModule(std::istream &IS,
106106
const SPIRV::TranslatorOpts &Opts,
107107
std::string &ErrMsg);
108108

109-
/// This contains a pair of the pointer element type and an indirection
110-
/// parameter (to capture cases where an array of OpenCL types is used).
111-
typedef llvm::PointerIntPair<llvm::Type *, 1, bool> PointerIndirectPair;
112-
113109
} // End namespace SPIRV
114110

115111
namespace llvm {
@@ -160,13 +156,11 @@ bool regularizeLlvmForSpirv(Module *M, std::string &ErrMsg,
160156
const SPIRV::TranslatorOpts &Opts);
161157

162158
/// \brief Mangle OpenCL builtin function function name.
163-
/// If any type in ArgTypes is a pointer type, the corresponding entry in
164-
/// ArgPointerTypes should contain the type should point to. If there are no
165-
/// pointer-typed arguments in ArgTypes, then ArgPointerTypes may be empty.
159+
/// If any type in ArgTypes is a pointer type, it should be represented as a
160+
/// TypedPointerType instead, to faithfully represent the pointer element types
161+
/// for name mangling.
166162
void mangleOpenClBuiltin(const std::string &UnmangledName,
167-
ArrayRef<Type *> ArgTypes,
168-
ArrayRef<SPIRV::PointerIndirectPair> ArgPointerTypes,
169-
std::string &MangledName);
163+
ArrayRef<Type *> ArgTypes, std::string &MangledName);
170164

171165
/// Create a pass for translating LLVM to SPIR-V.
172166
ModulePass *createLLVMToSPIRVLegacy(SPIRV::SPIRVModule *);

lib/SPIRV/OCLUtil.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,9 +1604,7 @@ Value *SPIRV::transSPIRVMemorySemanticsIntoOCLMemFenceFlags(
16041604

16051605
void llvm::mangleOpenClBuiltin(const std::string &UniqName,
16061606
ArrayRef<Type *> ArgTypes,
1607-
ArrayRef<PointerIndirectPair> PointerElementTys,
16081607
std::string &MangledName) {
16091608
OCLUtil::OCLBuiltinFuncMangleInfo BtnInfo(ArgTypes);
1610-
BtnInfo.fillPointerElementTypes(PointerElementTys);
16111609
MangledName = SPIRV::mangleBuiltin(UniqName, ArgTypes, &BtnInfo);
16121610
}

lib/SPIRV/SPIRVInternal.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -457,11 +457,11 @@ struct BuiltinArgTypeMangleInfo {
457457
bool IsLocalArgBlock;
458458
SPIR::TypePrimitiveEnum Enum;
459459
unsigned Attr;
460-
PointerIndirectPair PointerElementType;
460+
Type *PointerTy;
461461
BuiltinArgTypeMangleInfo()
462462
: IsSigned(true), IsVoidPtr(false), IsEnum(false), IsSampler(false),
463463
IsAtomic(false), IsLocalArgBlock(false), Enum(SPIR::PRIMITIVE_NONE),
464-
Attr(0), PointerElementType(nullptr, false) {}
464+
Attr(0), PointerTy(nullptr) {}
465465
};
466466

467467
/// Information for mangling builtin function.
@@ -519,8 +519,6 @@ class BuiltinFuncMangleInfo {
519519
UnmangledName = UniqUnmangledName.str();
520520
}
521521

522-
void fillPointerElementTypes(ArrayRef<PointerIndirectPair>);
523-
524522
protected:
525523
std::string UnmangledName;
526524
std::vector<BuiltinArgTypeMangleInfo> ArgInfo;
@@ -987,7 +985,6 @@ inline void getParameterTypes(CallInst *CI,
987985
/// manner
988986
std::string getSPIRVFriendlyIRFunctionName(OCLExtOpKind ExtOpId,
989987
ArrayRef<Type *> ArgTys,
990-
ArrayRef<PointerIndirectPair> PETs,
991988
Type *RetTy = nullptr);
992989

993990
/// Mangle a function in SPIR-V friendly IR manner
@@ -999,8 +996,7 @@ std::string getSPIRVFriendlyIRFunctionName(OCLExtOpKind ExtOpId,
999996
/// \param Types of arguments of SPIR-V built-in function
1000997
/// \return IA64 mangled name.
1001998
std::string getSPIRVFriendlyIRFunctionName(const std::string &UniqName,
1002-
spv::Op OC, ArrayRef<Type *> ArgTys,
1003-
ArrayRef<PointerIndirectPair> PETs);
999+
spv::Op OC, ArrayRef<Type *> ArgTys);
10041000

10051001
/// Cast a function to a void(void) funtion pointer.
10061002
Constant *castToVoidFuncPtr(Function *F);

0 commit comments

Comments
 (0)