@@ -65,7 +65,8 @@ bool SPIRVCallLowering::lowerReturn(MachineIRBuilder &MIRBuilder,
6565}
6666
6767// Based on the LLVM function attributes, get a SPIR-V FunctionControl.
68- static uint32_t getFunctionControl (const Function &F) {
68+ static uint32_t getFunctionControl (const Function &F,
69+ const SPIRVSubtarget *ST) {
6970 MemoryEffects MemEffects = F.getMemoryEffects ();
7071
7172 uint32_t FuncControl = static_cast <uint32_t >(SPIRV::FunctionControl::None);
@@ -80,6 +81,11 @@ static uint32_t getFunctionControl(const Function &F) {
8081 else if (MemEffects.onlyReadsMemory ())
8182 FuncControl |= static_cast <uint32_t >(SPIRV::FunctionControl::Const);
8283
84+ if (ST->canUseExtension (SPIRV::Extension::SPV_INTEL_optnone) ||
85+ ST->canUseExtension (SPIRV::Extension::SPV_EXT_optnone))
86+ if (F.hasFnAttribute (Attribute::OptimizeNone))
87+ FuncControl |= static_cast <uint32_t >(SPIRV::FunctionControl::OptNoneEXT);
88+
8389 return FuncControl;
8490}
8591
@@ -346,6 +352,12 @@ bool SPIRVCallLowering::lowerFormalArguments(MachineIRBuilder &MIRBuilder,
346352 buildOpDecorate (VRegs[i][0 ], MIRBuilder,
347353 SPIRV::Decoration::FuncParamAttr, {Attr});
348354 }
355+ if (Arg.hasAttribute (Attribute::StructRet)) {
356+ auto Attr =
357+ static_cast <unsigned >(SPIRV::FunctionParameterAttribute::Sret);
358+ buildOpDecorate (VRegs[i][0 ], MIRBuilder,
359+ SPIRV::Decoration::FuncParamAttr, {Attr});
360+ }
349361
350362 if (F.getCallingConv () == CallingConv::SPIR_KERNEL) {
351363 std::vector<SPIRV::Decoration::Decoration> ArgTypeQualDecs =
@@ -397,7 +409,7 @@ bool SPIRVCallLowering::lowerFormalArguments(MachineIRBuilder &MIRBuilder,
397409 FTy = fixFunctionTypeIfPtrArgs (GR, F, FTy, RetTy, ArgTypeVRegs);
398410 SPIRVType *FuncTy = GR->getOrCreateOpTypeFunctionWithArgs (
399411 FTy, RetTy, ArgTypeVRegs, MIRBuilder);
400- uint32_t FuncControl = getFunctionControl (F);
412+ uint32_t FuncControl = getFunctionControl (F, ST );
401413
402414 // Add OpFunction instruction
403415 MachineInstrBuilder MB = MIRBuilder.buildInstr (SPIRV::OpFunction)
@@ -427,10 +439,8 @@ bool SPIRVCallLowering::lowerFormalArguments(MachineIRBuilder &MIRBuilder,
427439
428440 // Handle entry points and function linkage.
429441 if (isEntryPoint (F)) {
430- const auto &STI = MIRBuilder.getMF ().getSubtarget <SPIRVSubtarget>();
431- auto executionModel = getExecutionModel (STI, F);
432442 auto MIB = MIRBuilder.buildInstr (SPIRV::OpEntryPoint)
433- .addImm (static_cast <uint32_t >(executionModel ))
443+ .addImm (static_cast <uint32_t >(getExecutionModel (*ST, F) ))
434444 .addUse (FuncVReg);
435445 addStringImm (F.getName (), MIB);
436446 } else if (F.getLinkage () != GlobalValue::InternalLinkage &&
0 commit comments