[NFC] Comment in MLInlineAdvisor as to why use std::map for FPICache
authorMircea Trofin <mtrofin@google.com>
Mon, 7 Nov 2022 19:10:58 +0000 (11:10 -0800)
committerMircea Trofin <mtrofin@google.com>
Mon, 7 Nov 2022 19:10:58 +0000 (11:10 -0800)
llvm/include/llvm/Analysis/MLInlineAdvisor.h

index 3db948d..7535464 100644 (file)
@@ -69,6 +69,9 @@ private:
   getSkipAdviceIfUnreachableCallsite(CallBase &CB);
   void print(raw_ostream &OS) const override;
 
+  // Using std::map to benefit from its iterator / reference non-invalidating
+  // semantics, which make it easy to use `getCachedFPI` results from multiple
+  // calls without needing to copy to avoid invalidation effects.
   mutable std::map<const Function *, FunctionPropertiesInfo> FPICache;
 
   LazyCallGraph &CG;