[AMDGPU] Fix running ResourceUsageAnalysis
authorSebastian Neubauer <sebastian.neubauer@amd.com>
Wed, 21 Jul 2021 17:14:12 +0000 (19:14 +0200)
committerSebastian Neubauer <Sebastian.Neubauer@amd.com>
Fri, 23 Jul 2021 07:25:15 +0000 (09:25 +0200)
Clear the map when running the analysis multiple times.
The assertion that should ensure that every function is only
analyzed once triggered sometimes (once every ~70 compiles of some
graphics pipelines) when two functions of subsequent runs were allocated
at the same address.

Differential Revision: https://reviews.llvm.org/D106452

llvm/lib/Target/AMDGPU/AMDGPUResourceUsageAnalysis.h

index b6a55f2..832e811 100644 (file)
@@ -51,13 +51,21 @@ public:
 
   bool runOnSCC(CallGraphSCC &SCC) override;
 
+  bool doInitialization(CallGraph &CG) override {
+    CallGraphResourceInfo.clear();
+    return CallGraphSCCPass::doInitialization(CG);
+  }
+
   void getAnalysisUsage(AnalysisUsage &AU) const override {
     AU.addRequired<MachineModuleInfoWrapperPass>();
     AU.setPreservesAll();
   }
 
   const SIFunctionResourceInfo &getResourceInfo(const Function *F) const {
-    return CallGraphResourceInfo.find(F)->getSecond();
+    auto Info = CallGraphResourceInfo.find(F);
+    assert(Info != CallGraphResourceInfo.end() &&
+           "Failed to find resource info for function");
+    return Info->getSecond();
   }
 
 private: