[llvm] [hwasan] Invalidate DominatorTreeAnalysis after each function is sanitized (PR #66935)

Thurston Dang via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 21 12:57:12 PDT 2023


================
@@ -430,8 +430,16 @@ PreservedAnalyses HWAddressSanitizerPass::run(Module &M,
 
   HWAddressSanitizer HWASan(M, Options.CompileKernel, Options.Recover, SSI);
   auto &FAM = MAM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
-  for (Function &F : M)
+  for (Function &F : M) {
     HWASan.sanitizeFunction(F, FAM);
+    // After sanitizing F - which may split blocks via insertShadowTagCheck -
+    // some cached analyses are invalid. This matters because
+    // sanitizeFunction(F', FAM) may indirectly call the global stack safety
+    // analysis, hence we need to make sure the analyses of F are up to date.
+    PreservedAnalyses PA = PreservedAnalyses::all();
----------------
thurstond wrote:

P.S. I'm honored to have two Florians review my patch :grinning: 

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


More information about the llvm-commits mailing list