[llvm] [SandboxIR] Add pointer-diff utility function (PR #110176)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 26 15:02:10 PDT 2024


================
@@ -57,6 +61,35 @@ class Utils {
   memoryLocationGetOrNone(const Instruction *I) {
     return llvm::MemoryLocation::getOrNone(cast<llvm::Instruction>(I->Val));
   }
+  /// \Returns true if \p I1 accesses a memory location lower than \p I2.
+  template <typename LoadOrStoreT>
+  static bool atLowerAddress(LoadOrStoreT *I0, LoadOrStoreT *I1,
+                             ScalarEvolution &SE, const DataLayout &DL) {
+    auto Diff = getPointerDiffInBytes(I0, I1, SE, DL);
+    if (!Diff)
+      return false;
+    return *Diff > 0;
+  }
+
+  /// \Returns the number gap between the memory locations accessed by \p I0 and
----------------
vporpo wrote:

"the number gap" did you mean to say "the gap" ?

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


More information about the llvm-commits mailing list