@@ -74,7 +74,6 @@ class SPIRVEmitIntrinsics
7474 DenseMap<Instruction *, Constant *> AggrConsts;
7575 DenseMap<Instruction *, Type *> AggrConstTypes;
7676 DenseSet<Instruction *> AggrStores;
77- SPIRV::InstructionSet::InstructionSet InstrSet;
7877
7978 // map of function declarations to <pointer arg index => element type>
8079 DenseMap<Function *, SmallVector<std::pair<unsigned , Type *>>> FDeclPtrTys;
@@ -896,8 +895,9 @@ bool SPIRVEmitIntrinsics::deduceOperandElementTypeCalledFunction(
896895 getOclOrSpirvBuiltinDemangledName (CalledF->getName ());
897896 if (DemangledName.length () > 0 &&
898897 !StringRef (DemangledName).starts_with (" llvm." )) {
899- auto [Grp, Opcode, ExtNo] =
900- SPIRV::mapBuiltinToOpcode (DemangledName, InstrSet);
898+ const SPIRVSubtarget &ST = TM->getSubtarget <SPIRVSubtarget>(*CalledF);
899+ auto [Grp, Opcode, ExtNo] = SPIRV::mapBuiltinToOpcode (
900+ DemangledName, ST.getPreferredInstructionSet ());
901901 if (Opcode == SPIRV::OpGroupAsyncCopy) {
902902 for (unsigned i = 0 , PtrCnt = 0 ; i < CI->arg_size () && PtrCnt < 2 ; ++i) {
903903 Value *Op = CI->getArgOperand (i);
@@ -2317,8 +2317,6 @@ bool SPIRVEmitIntrinsics::runOnFunction(Function &Func) {
23172317
23182318 const SPIRVSubtarget &ST = TM->getSubtarget <SPIRVSubtarget>(Func);
23192319 GR = ST.getSPIRVGlobalRegistry ();
2320- InstrSet = ST.isOpenCLEnv () ? SPIRV::InstructionSet::OpenCL_std
2321- : SPIRV::InstructionSet::GLSL_std_450;
23222320
23232321 if (!CurrF)
23242322 HaveFunPtrs =
@@ -2475,8 +2473,9 @@ void SPIRVEmitIntrinsics::parseFunDeclarations(Module &M) {
24752473 if (DemangledName.empty ())
24762474 continue ;
24772475 // allow only OpGroupAsyncCopy use case at the moment
2478- auto [Grp, Opcode, ExtNo] =
2479- SPIRV::mapBuiltinToOpcode (DemangledName, InstrSet);
2476+ const SPIRVSubtarget &ST = TM->getSubtarget <SPIRVSubtarget>(F);
2477+ auto [Grp, Opcode, ExtNo] = SPIRV::mapBuiltinToOpcode (
2478+ DemangledName, ST.getPreferredInstructionSet ());
24802479 if (Opcode != SPIRV::OpGroupAsyncCopy)
24812480 continue ;
24822481 // find pointer arguments
0 commit comments