Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ class SPIRVEmitIntrinsics
DenseMap<Instruction *, Constant *> AggrConsts;
DenseMap<Instruction *, Type *> AggrConstTypes;
DenseSet<Instruction *> AggrStores;
SPIRV::InstructionSet::InstructionSet InstrSet;

// map of function declarations to <pointer arg index => element type>
DenseMap<Function *, SmallVector<std::pair<unsigned, Type *>>> FDeclPtrTys;
Expand Down Expand Up @@ -896,8 +895,10 @@ bool SPIRVEmitIntrinsics::deduceOperandElementTypeCalledFunction(
getOclOrSpirvBuiltinDemangledName(CalledF->getName());
if (DemangledName.length() > 0 &&
!StringRef(DemangledName).starts_with("llvm.")) {
auto [Grp, Opcode, ExtNo] =
SPIRV::mapBuiltinToOpcode(DemangledName, InstrSet);
auto [Grp, Opcode, ExtNo] = SPIRV::mapBuiltinToOpcode(
DemangledName, TM->getSubtarget<SPIRVSubtarget>(*CalledF).isOpenCLEnv()
? SPIRV::InstructionSet::OpenCL_std
: SPIRV::InstructionSet::GLSL_std_450);
if (Opcode == SPIRV::OpGroupAsyncCopy) {
for (unsigned i = 0, PtrCnt = 0; i < CI->arg_size() && PtrCnt < 2; ++i) {
Value *Op = CI->getArgOperand(i);
Expand Down Expand Up @@ -2316,10 +2317,6 @@ bool SPIRVEmitIntrinsics::runOnFunction(Function &Func) {
return false;

const SPIRVSubtarget &ST = TM->getSubtarget<SPIRVSubtarget>(Func);
GR = ST.getSPIRVGlobalRegistry();
InstrSet = ST.isOpenCLEnv() ? SPIRV::InstructionSet::OpenCL_std
: SPIRV::InstructionSet::GLSL_std_450;

if (!CurrF)
HaveFunPtrs =
ST.canUseExtension(SPIRV::Extension::SPV_INTEL_function_pointers);
Expand Down Expand Up @@ -2475,8 +2472,10 @@ void SPIRVEmitIntrinsics::parseFunDeclarations(Module &M) {
if (DemangledName.empty())
continue;
// allow only OpGroupAsyncCopy use case at the moment
auto [Grp, Opcode, ExtNo] =
SPIRV::mapBuiltinToOpcode(DemangledName, InstrSet);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this variable be removed from the class?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessarily, it is in use in one more piece of the code in deduceOperandElementTypeCalledFunction(). However, it may make sense indeed, because it's the only use of it, so caching improves nothing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, removing the class member InstrSet

auto [Grp, Opcode, ExtNo] = SPIRV::mapBuiltinToOpcode(
DemangledName, TM->getSubtarget<SPIRVSubtarget>(F).isOpenCLEnv()
? SPIRV::InstructionSet::OpenCL_std
: SPIRV::InstructionSet::GLSL_std_450);
if (Opcode != SPIRV::OpGroupAsyncCopy)
continue;
// find pointer arguments
Expand Down
Loading