[llvm] [DXIL] Consume Metadata Analysis information in passes (PR #108034)

S. Bharadwaj Yadavalli via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 18 13:08:51 PDT 2024


================
@@ -247,9 +247,10 @@ class DXILPrepareModule : public ModulePass {
 
   DXILPrepareModule() : ModulePass(ID) {}
   void getAnalysisUsage(AnalysisUsage &AU) const override {
+    AU.setPreservesAll();
     AU.addPreserved<ShaderFlagsAnalysisWrapper>();
     AU.addPreserved<DXILResourceMDWrapper>();
-    AU.addPreserved<DXILMetadataAnalysisWrapperPass>();
+    AU.addRequired<DXILMetadataAnalysisWrapperPass>();
----------------
bharadwajy wrote:

> Is it correct to say that this preserves all? I'm not sure if any analyses cache information about function attributes, so maybe it's okay there, but we do modify the IR so I doubt it's safe to really say we preserve all analyses...

I share the concern about specifying `setPreservedAll()` for `DXILPrepare` pass that actually changes the LLVM IR (as I was discussing offline with @damyanp earlier). As things stand, `DXContainerGlobals` pass that runs after `DXILPrepare` pass uses `DXILMetadataAnalysis` info (i.e., requires the pass) but running it before `DXContainerGlobals` would produce incomplete info since `DXILPrepare` deletes function attributes. Hence the unsatisfactory workaround of `setPreservedAll()` in `DXILPrepare`. 

To address this, I'd like to move attribute removal out of `DXILPrepare` into `DXContainerGlobals` pass and (correctly) delete `setPreservedAll()` from `DXILPrepare` pass. Is there a known reason for removing function attributes in `DXILPrepare` pass and not in a later pass?

https://github.com/llvm/llvm-project/pull/108034


More information about the llvm-commits mailing list