[clang] [HLSL][NFC] Remove unused location argument (PR #203467)
Helena Kotas via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 11 23:47:27 PDT 2026
https://github.com/hekota created https://github.com/llvm/llvm-project/pull/203467
The location argument was just passed around but never used.
>From b7e8f594c7273addac041080997e57f834007702 Mon Sep 17 00:00:00 2001
From: Helena Kotas <hekotas at microsoft.com>
Date: Thu, 11 Jun 2026 23:43:24 -0700
Subject: [PATCH] [HLSL][NFC] Remove unused location argument
---
clang/lib/CodeGen/CGExpr.cpp | 12 ++++--------
clang/lib/CodeGen/CGHLSLRuntime.cpp | 29 ++++++++++++-----------------
clang/lib/CodeGen/CGHLSLRuntime.h | 5 ++---
3 files changed, 18 insertions(+), 28 deletions(-)
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index f6cb636368598..746746c828acc 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -2378,8 +2378,7 @@ LValue CodeGenFunction::EmitMatrixElementExpr(const MatrixElementExpr *E) {
RawAddress MatAddr = Base.getAddress();
if (getLangOpts().HLSL &&
E->getBase()->getType().getAddressSpace() == LangAS::hlsl_constant)
- MatAddr = CGM.getHLSLRuntime().createBufferMatrixTempAddress(
- Base, E->getExprLoc(), *this);
+ MatAddr = CGM.getHLSLRuntime().createBufferMatrixTempAddress(Base, *this);
llvm::Constant *CV =
llvm::ConstantDataVector::get(getLLVMContext(), Indices);
@@ -2492,8 +2491,7 @@ static RValue EmitLoadOfMatrixLValue(LValue LV, SourceLocation Loc,
// non-padded local alloca before loading.
if (CGF.getLangOpts().HLSL &&
LV.getType().getAddressSpace() == LangAS::hlsl_constant)
- DestAddr =
- CGF.CGM.getHLSLRuntime().createBufferMatrixTempAddress(LV, Loc, CGF);
+ DestAddr = CGF.CGM.getHLSLRuntime().createBufferMatrixTempAddress(LV, CGF);
Address Addr = MaybeConvertMatrixAddress(DestAddr, CGF);
LV.setAddress(Addr);
@@ -3459,8 +3457,7 @@ static LValue EmitGlobalVarDeclLValue(CodeGenFunction &CGF,
// the initialized global resource array.
if (CGF.getLangOpts().HLSL && VD->getType()->isHLSLResourceRecordArray()) {
std::optional<LValue> LV =
- CGF.CGM.getHLSLRuntime().emitGlobalResourceArrayAsLValue(
- CGF, VD, E->getExprLoc());
+ CGF.CGM.getHLSLRuntime().emitGlobalResourceArrayAsLValue(CGF, VD);
if (LV.has_value())
return LV.value();
}
@@ -5206,8 +5203,7 @@ LValue CodeGenFunction::EmitMatrixSingleSubscriptExpr(
RawAddress MatAddr = Base.getAddress();
if (getLangOpts().HLSL &&
E->getBase()->getType().getAddressSpace() == LangAS::hlsl_constant)
- MatAddr = CGM.getHLSLRuntime().createBufferMatrixTempAddress(
- Base, E->getExprLoc(), *this);
+ MatAddr = CGM.getHLSLRuntime().createBufferMatrixTempAddress(Base, *this);
return LValue::MakeMatrixRow(MaybeConvertMatrixAddress(MatAddr, *this),
RowIdx, E->getBase()->getType(),
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 262a2d8dabf5d..db69f1d1b31ff 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -309,8 +309,7 @@ static std::optional<llvm::Value *> initializeResourceArrayFromGlobal(
CodeGenFunction &CGF, CXXRecordDecl *ResourceDecl,
const ConstantArrayType *ArrayTy, AggValueSlot &ValueSlot,
llvm::Value *Range, llvm::Value *StartIndex, StringRef ResourceName,
- ResourceBindingAttrs &Binding, ArrayRef<llvm::Value *> PrevGEPIndices,
- SourceLocation ArraySubsExprLoc) {
+ ResourceBindingAttrs &Binding, ArrayRef<llvm::Value *> PrevGEPIndices) {
ASTContext &AST = CGF.getContext();
llvm::IntegerType *IntTy = CGF.CGM.IntTy;
@@ -334,9 +333,9 @@ static std::optional<llvm::Value *> initializeResourceArrayFromGlobal(
GEPIndices.back() = llvm::ConstantInt::get(IntTy, I);
}
std::optional<llvm::Value *> MaybeIndex =
- initializeResourceArrayFromGlobal(
- CGF, ResourceDecl, SubArrayTy, ValueSlot, Range, Index,
- ResourceName, Binding, GEPIndices, ArraySubsExprLoc);
+ initializeResourceArrayFromGlobal(CGF, ResourceDecl, SubArrayTy,
+ ValueSlot, Range, Index,
+ ResourceName, Binding, GEPIndices);
if (!MaybeIndex)
return std::nullopt;
Index = *MaybeIndex;
@@ -1457,8 +1456,7 @@ std::optional<LValue> CGHLSLRuntime::emitResourceArraySubscriptExpr(
cast<ConstantArrayType>(ResultTy.getTypePtr());
std::optional<llvm::Value *> EndIndex = initializeResourceArrayFromGlobal(
CGF, ResourceTy->getAsCXXRecordDecl(), ArrayTy, ValueSlot, Range, Index,
- ArrayDecl->getName(), Binding, {llvm::ConstantInt::get(CGM.IntTy, 0)},
- ArraySubsExpr->getExprLoc());
+ ArrayDecl->getName(), Binding, {llvm::ConstantInt::get(CGM.IntTy, 0)});
if (!EndIndex)
return std::nullopt;
}
@@ -1468,7 +1466,6 @@ std::optional<LValue> CGHLSLRuntime::emitResourceArraySubscriptExpr(
// Initialize all resources of a global resource array into provided slot.
bool CGHLSLRuntime::initializeGlobalResourceArray(CodeGenFunction &CGF,
const VarDecl *ArrayDecl,
- SourceLocation Loc,
AggValueSlot &DestSlot) {
assert(ArrayDecl->getType()->isHLSLResourceRecordArray() &&
ArrayDecl->hasGlobalStorage() &&
@@ -1495,7 +1492,7 @@ bool CGHLSLRuntime::initializeGlobalResourceArray(CodeGenFunction &CGF,
// Initialize individual resources in the array into DestSlot.
std::optional<llvm::Value *> EndIndex = initializeResourceArrayFromGlobal(
CGF, ResTy->getAsCXXRecordDecl(), ResArrayTy, DestSlot, Range, Zero,
- ArrayDecl->getName(), Binding, {Zero}, Loc);
+ ArrayDecl->getName(), Binding, {Zero});
return EndIndex.has_value();
}
@@ -1515,16 +1512,16 @@ bool CGHLSLRuntime::emitGlobalResourceArray(CodeGenFunction &CGF, const Expr *E,
ArrayDecl->getStorageClass() == SC_Static)
return false;
- return initializeGlobalResourceArray(CGF, ArrayDecl, E->getExprLoc(),
- DestSlot);
+ return initializeGlobalResourceArray(CGF, ArrayDecl, DestSlot);
}
// If the expression is a global resource array, create a temporary and
// initialize all of its resources, and return it as an LValue. Returns nullopt
// if no initialization has been performed and the handling should follow the
// default path.
-std::optional<LValue> CGHLSLRuntime::emitGlobalResourceArrayAsLValue(
- CodeGenFunction &CGF, const VarDecl *ArrayDecl, SourceLocation Loc) {
+std::optional<LValue>
+CGHLSLRuntime::emitGlobalResourceArrayAsLValue(CodeGenFunction &CGF,
+ const VarDecl *ArrayDecl) {
assert(ArrayDecl->getType()->isHLSLResourceRecordArray() &&
"expected resource array declaration");
@@ -1534,14 +1531,13 @@ std::optional<LValue> CGHLSLRuntime::emitGlobalResourceArrayAsLValue(
AggValueSlot TmpArraySlot =
CGF.CreateAggTemp(ArrayDecl->getType(), "tmpResArray");
- if (initializeGlobalResourceArray(CGF, ArrayDecl, Loc, TmpArraySlot))
+ if (initializeGlobalResourceArray(CGF, ArrayDecl, TmpArraySlot))
return CGF.MakeAddrLValue(TmpArraySlot.getAddress(), ArrayDecl->getType(),
AlignmentSource::Decl);
return std::nullopt;
}
RawAddress CGHLSLRuntime::createBufferMatrixTempAddress(const LValue &LV,
- SourceLocation Loc,
CodeGenFunction &CGF) {
assert(LV.getType()->isConstantMatrixType() && "expected matrix type");
@@ -1638,9 +1634,8 @@ CGHLSLRuntime::emitResourceMemberExpr(CodeGenFunction &CGF,
// Handle member of resource array type.
if (ResourceVD->getType()->isHLSLResourceRecordArray())
- return emitGlobalResourceArrayAsLValue(CGF, ResourceVD, ME->getExprLoc());
+ return emitGlobalResourceArrayAsLValue(CGF, ResourceVD);
- // Handle member that is an individual resource.
GlobalVariable *ResGV =
cast<GlobalVariable>(CGM.GetAddrOfGlobalVar(ResourceVD));
const DataLayout &DL = CGM.getDataLayout();
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.h b/clang/lib/CodeGen/CGHLSLRuntime.h
index 2439084224334..cafa073fc4e68 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.h
+++ b/clang/lib/CodeGen/CGHLSLRuntime.h
@@ -306,13 +306,13 @@ class CGHLSLRuntime {
AggValueSlot &DestSlot);
std::optional<LValue>
emitGlobalResourceArrayAsLValue(CodeGenFunction &CGF,
- const VarDecl *ArrayDecl, SourceLocation Loc);
+ const VarDecl *ArrayDecl);
std::optional<LValue> emitBufferArraySubscriptExpr(
const ArraySubscriptExpr *E, CodeGenFunction &CGF,
llvm::function_ref<llvm::Value *(bool Promote)> EmitIdxAfterBase);
- RawAddress createBufferMatrixTempAddress(const LValue &LV, SourceLocation Loc,
+ RawAddress createBufferMatrixTempAddress(const LValue &LV,
CodeGenFunction &CGF);
bool emitBufferCopy(CodeGenFunction &CGF, Address DestPtr, Address SrcPtr,
@@ -358,7 +358,6 @@ class CGHLSLRuntime {
bool initializeGlobalResourceArray(CodeGenFunction &CGF,
const VarDecl *ArrayDecl,
- SourceLocation Loc,
AggValueSlot &DestSlot);
llvm::Triple::ArchType getArch();
More information about the cfe-commits
mailing list