[clang] [clang] fix OutputSemantic list in HLSL (PR #185550)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 9 18:28:40 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Jameson Nash (vtjnash)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/185550.diff
1 Files Affected:
- (modified) clang/lib/CodeGen/CGHLSLRuntime.cpp (+7-7)
``````````diff
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();
``````````
</details>
https://github.com/llvm/llvm-project/pull/185550
More information about the cfe-commits
mailing list