@@ -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
267264void 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
0 commit comments