Skip to content

Commit f009f45

Browse files
authored
Explicitly add 'sret' parameter attribute for builtins (#1438)
* Explicitly add 'sret' parameter attribute for builtins It's required after: commit 2182665305d90ae7d0d2b573dced9ef0ef414a9a Author: Nikita Popov <[email protected]> Date: Fri Mar 11 17:30:34 2022 +0100 [Bitcode] Don't confuse type attributes on declaration and call We should not be using APIs here that try to fetch the attribute from both the call attributes and the function attributes. Otherwise we'll try to upgrade a non-existent sret attribute on the call using the attribute on the function. Signed-off-by: Dmitry Sidorov <[email protected]> * Little refactoring Signed-off-by: Dmitry Sidorov <[email protected]>
1 parent 697458f commit f009f45

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/SPIRV/SPIRVUtil.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,13 +1949,14 @@ bool postProcessBuiltinReturningStruct(Function *F) {
19491949
PointerType::get(F->getReturnType(), SPIRAS_Private));
19501950
auto *NewF =
19511951
getOrCreateFunction(M, Type::getVoidTy(*Context), ArgTys, Name);
1952-
NewF->addParamAttr(0, Attribute::get(*Context,
1953-
Attribute::AttrKind::StructRet,
1954-
F->getReturnType()));
1952+
auto SretAttr = Attribute::get(*Context, Attribute::AttrKind::StructRet,
1953+
F->getReturnType());
1954+
NewF->addParamAttr(0, SretAttr);
19551955
NewF->setCallingConv(F->getCallingConv());
19561956
auto Args = getArguments(CI);
19571957
Args.insert(Args.begin(), ST->getPointerOperand());
19581958
auto *NewCI = CallInst::Create(NewF, Args, CI->getName(), CI);
1959+
NewCI->addParamAttr(0, SretAttr);
19591960
NewCI->setCallingConv(CI->getCallingConv());
19601961
InstToRemove.push_back(ST);
19611962
InstToRemove.push_back(CI);

0 commit comments

Comments
 (0)