[PATCH] D104620: [LoopVersioning] Add utility to fetch the runtime check basic block

Yueh-Ting Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 21 00:24:13 PDT 2021


eopXD created this revision.
eopXD added reviewers: fhahn, Ayal.
Herald added a subscriber: hiraditya.
eopXD requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This allow user to get the basic block, get the BranchInst from BB.
The utility is needed when other passes that versions the loops want to
append more conditions to the runtime check.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104620

Files:
  llvm/include/llvm/Transforms/Utils/LoopVersioning.h
  llvm/lib/Transforms/Utils/LoopVersioning.cpp


Index: llvm/lib/Transforms/Utils/LoopVersioning.cpp
===================================================================
--- llvm/lib/Transforms/Utils/LoopVersioning.cpp
+++ llvm/lib/Transforms/Utils/LoopVersioning.cpp
@@ -58,7 +58,7 @@
   Value *RuntimeCheck = nullptr;
 
   // Add the memcheck in the original preheader (this is empty initially).
-  BasicBlock *RuntimeCheckBB = VersionedLoop->getLoopPreheader();
+  *RuntimeCheckBB = VersionedLoop->getLoopPreheader();
   const auto &RtPtrChecking = *LAI.getRuntimePointerChecking();
 
   SCEVExpander Exp2(*RtPtrChecking.getSE(),
Index: llvm/include/llvm/Transforms/Utils/LoopVersioning.h
===================================================================
--- llvm/include/llvm/Transforms/Utils/LoopVersioning.h
+++ llvm/include/llvm/Transforms/Utils/LoopVersioning.h
@@ -75,6 +75,9 @@
   /// loop may alias (i.e. one of the memchecks failed).
   Loop *getNonVersionedLoop() { return NonVersionedLoop; }
 
+  /// Returns the basic block that contains the runtime check BranchInst
+  BasicBlock *getRuntimeCheckBB() { return RuntimeCheckBB; }
+
   /// Annotate memory instructions in the versioned loop with no-alias
   /// metadata based on the memchecks issued.
   ///
@@ -115,6 +118,9 @@
   /// loop may alias (memchecks failed).
   Loop *NonVersionedLoop;
 
+  /// The basic Block that stores the BranchInst to Versioned / NonVersioned
+  BasicBlock *RuntimeCheckBB;
+
   /// This maps the instructions from VersionedLoop to their counterpart
   /// in NonVersionedLoop.
   ValueToValueMapTy VMap;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104620.353285.patch
Type: text/x-patch
Size: 1555 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210621/43d9ad24/attachment.bin>


More information about the llvm-commits mailing list