Skip to content

Commit c5a5604

Browse files
committed
Address PR comments on gatherGlobalModuleFlags
1 parent 79c7a25 commit c5a5604

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

llvm/lib/Target/DirectX/DXILShaderFlags.cpp

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,12 @@ void ModuleShaderFlags::updateFunctionFlags(ComputedShaderFlags &CSF,
208208
}
209209

210210
/// Set shader flags that apply to all functions within the module
211-
void ModuleShaderFlags::gatherGlobalModuleFlags(
212-
ComputedShaderFlags &CSF, const Module &M, const DXILResourceMap &DRM,
213-
const ModuleMetadataInfo &MMDI) {
211+
ComputedShaderFlags
212+
ModuleShaderFlags::gatherGlobalModuleFlags(const Module &M,
213+
const DXILResourceMap &DRM,
214+
const ModuleMetadataInfo &MMDI) {
215+
216+
ComputedShaderFlags CSF;
214217

215218
// Set DisableOptimizations flag based on the presence of OptimizeNone
216219
// attribute of entry functions.
@@ -249,27 +252,28 @@ void ModuleShaderFlags::gatherGlobalModuleFlags(
249252
if (MMDI.ShaderModelVersion >= VersionTuple(6, 2))
250253
CSF.NativeLowPrecisionMode = NativeLowPrec->getValue().getBoolValue();
251254

252-
CanSetResMayNotAlias = MMDI.DXILVersion >= VersionTuple(1, 7);
253-
// The command line option -res-may-alias will set the dx.resmayalias module
254-
// flag to 1, thereby disabling the ability to set the ResMayNotAlias flag
255-
if (auto *ResMayAlias = mdconst::extract_or_null<ConstantInt>(
256-
M.getModuleFlag("dx.resmayalias")))
257-
if (ResMayAlias->getValue().getBoolValue())
258-
CanSetResMayNotAlias = false;
259-
260255
// Set ResMayNotAlias to true if DXIL validator version < 1.8 and there
261256
// are UAVs present globally.
262257
if (CanSetResMayNotAlias && MMDI.ValidatorVersion < VersionTuple(1, 8))
263258
CSF.ResMayNotAlias = !DRM.uavs().empty();
259+
260+
return CSF;
264261
}
265262

266263
/// Construct ModuleShaderFlags for module Module M
267264
void ModuleShaderFlags::initialize(Module &M, DXILResourceTypeMap &DRTM,
268265
const DXILResourceMap &DRM,
269266
const ModuleMetadataInfo &MMDI) {
270267

271-
ComputedShaderFlags GlobalSFMask;
272-
gatherGlobalModuleFlags(GlobalSFMask, M, DRM, MMDI);
268+
CanSetResMayNotAlias = MMDI.DXILVersion >= VersionTuple(1, 7);
269+
// The command line option -res-may-alias will set the dx.resmayalias module
270+
// flag to 1, thereby disabling the ability to set the ResMayNotAlias flag
271+
if (auto *ResMayAlias = mdconst::extract_or_null<ConstantInt>(
272+
M.getModuleFlag("dx.resmayalias")))
273+
if (ResMayAlias->getValue().getBoolValue())
274+
CanSetResMayNotAlias = false;
275+
276+
ComputedShaderFlags GlobalSFMask = gatherGlobalModuleFlags(M, DRM, MMDI);
273277

274278
CallGraph CG(M);
275279

llvm/lib/Target/DirectX/DXILShaderFlags.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ struct ModuleShaderFlags {
101101
DenseMap<const Function *, ComputedShaderFlags> FunctionFlags;
102102
/// Combined Shader Flag Mask of all functions of the module
103103
ComputedShaderFlags CombinedSFMask{};
104-
void gatherGlobalModuleFlags(ComputedShaderFlags &, const Module &M,
105-
const DXILResourceMap &,
106-
const ModuleMetadataInfo &);
104+
ComputedShaderFlags gatherGlobalModuleFlags(const Module &M,
105+
const DXILResourceMap &,
106+
const ModuleMetadataInfo &);
107107
void updateFunctionFlags(ComputedShaderFlags &, const Instruction &,
108108
DXILResourceTypeMap &, const ModuleMetadataInfo &);
109109
};

0 commit comments

Comments
 (0)