https://github.com/vtjnash created https://github.com/llvm/llvm-project/pull/185550
Normally sane front-ends with the common calling-conventions avoid having multiple sret with a return value, so this is NFCI. However, multiple can be valid. This rewrites an odd looking DenseMap of one element that was needed for iteration into a more sensible vector. Noted in https://github.com/llvm/llvm-project/pull/181740 review. >From a49e05ccc5846af1b310daa44f2c7d08310a9be3 Mon Sep 17 00:00:00 2001 From: Jameson Nash <[email protected]> Date: Mon, 9 Mar 2026 21:24:55 -0400 Subject: [PATCH] [clang] fix OutputSemantic list in HLSL Normally sane front-ends with the common calling-conventions avoid having multiple sret with a return value, so this is NFCI. However, multiple can be valid. This rewrites an odd looking DenseMap of one element that was needed for iteration into a more sensible vector. Noted in https://github.com/llvm/llvm-project/pull/181740 review. --- clang/lib/CodeGen/CGHLSLRuntime.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp b/clang/lib/CodeGen/CGHLSLRuntime.cpp index c1329ede7430f..29c200448ac84 100644 --- a/clang/lib/CodeGen/CGHLSLRuntime.cpp +++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp @@ -951,7 +951,7 @@ void CGHLSLRuntime::emitEntryFunction(const FunctionDecl *FD, OB.emplace_back("convergencectrl", bundleArgs); } - llvm::DenseMap<const DeclaratorDecl *, llvm::Value *> OutputSemantic; + std::vector<llvm::Value *> OutputSemantic; unsigned SRetOffset = 0; for (const auto &Param : Fn->args()) { @@ -959,7 +959,7 @@ void CGHLSLRuntime::emitEntryFunction(const FunctionDecl *FD, SRetOffset = 1; llvm::Type *VarType = Param.getParamStructRetType(); llvm::Value *Var = B.CreateAlloca(VarType); - OutputSemantic.try_emplace(FD, Var); + OutputSemantic.push_back(Var); Args.push_back(Var); continue; } @@ -995,16 +995,16 @@ void CGHLSLRuntime::emitEntryFunction(const FunctionDecl *FD, CI->setCallingConv(Fn->getCallingConv()); if (Fn->getReturnType() != CGM.VoidTy) - OutputSemantic.try_emplace(FD, CI); + OutputSemantic.push_back(CI); - for (auto &[Decl, Source] : OutputSemantic) { + for (Value *Source : OutputSemantic) { AllocaInst *AI = dyn_cast<AllocaInst>(Source); llvm::Value *SourceValue = AI ? B.CreateLoad(AI->getAllocatedType(), Source) : Source; - auto AttrBegin = Decl->specific_attr_begin<HLSLAppliedSemanticAttr>(); - auto AttrEnd = Decl->specific_attr_end<HLSLAppliedSemanticAttr>(); - handleSemanticStore(B, FD, SourceValue, Decl, AttrBegin, AttrEnd); + auto AttrBegin = FD->specific_attr_begin<HLSLAppliedSemanticAttr>(); + auto AttrEnd = FD->specific_attr_end<HLSLAppliedSemanticAttr>(); + handleSemanticStore(B, FD, SourceValue, FD, AttrBegin, AttrEnd); } B.CreateRetVoid(); _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
