[PATCH] D68345: Verify that assumption cache has valid entries.

Aditya Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 2 10:09:35 PDT 2019


hiraditya created this revision.
hiraditya added a reviewer: tejohnson.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Verify the AssumptionCache of the original function to make sure no stale entries remain


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68345

Files:
  llvm/include/llvm/Transforms/Utils/CodeExtractor.h
  llvm/lib/Transforms/Utils/CodeExtractor.cpp
  llvm/test/Transforms/HotColdSplit/assumption-cache-invalidation.ll


Index: llvm/test/Transforms/HotColdSplit/assumption-cache-invalidation.ll
===================================================================
--- llvm/test/Transforms/HotColdSplit/assumption-cache-invalidation.ll
+++ llvm/test/Transforms/HotColdSplit/assumption-cache-invalidation.ll
@@ -1,4 +1,6 @@
-; RUN: opt -instcombine -hotcoldsplit -instsimplify %s -o /dev/null
+; REQUIRES: asserts
+; RUN: opt -instcombine -hotcoldsplit -instsimplify -debug %s -o /dev/null
+; XFAIL: *
 
 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
 target triple = "aarch64"
Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
===================================================================
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -1563,5 +1563,17 @@
   });
   LLVM_DEBUG(if (verifyFunction(*oldFunction))
              report_fatal_error("verification of oldFunction failed!"));
+  LLVM_DEBUG(if (AC && verifyAssumptionCache(*oldFunction, AC))
+             report_fatal_error("Stale Asumption cache for old Function!"));
   return newFunction;
 }
+
+bool CodeExtractor::verifyAssumptionCache(const Function& F,
+                                          AssumptionCache *AC) {
+  for (auto AssumeVH : AC->assumptions()) {
+    CallInst *I = cast<CallInst>(AssumeVH);
+    if (I->getParent()->getParent() != &F)
+      return true;
+  }
+  return false;
+}
Index: llvm/include/llvm/Transforms/Utils/CodeExtractor.h
===================================================================
--- llvm/include/llvm/Transforms/Utils/CodeExtractor.h
+++ llvm/include/llvm/Transforms/Utils/CodeExtractor.h
@@ -106,6 +106,11 @@
     /// returns false.
     Function *extractCodeRegion();
 
+    /// Verify that assumption cache isn't stale after a region is extracted.
+    /// Returns false when verifier finds errors. AssumptionCache is passed as
+    /// parameter to make this function stateless.
+    static bool verifyAssumptionCache(const Function& F, AssumptionCache *AC);
+
     /// Test whether this code extractor is eligible.
     ///
     /// Based on the blocks used when constructing the code extractor,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68345.222859.patch
Type: text/x-patch
Size: 2175 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191002/4034370c/attachment-0001.bin>


More information about the llvm-commits mailing list