[llvm] [CodeGen] Resolve FIXME: Try SCEV getRange (PR #80623)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 13 08:53:14 PST 2024


================
@@ -263,10 +263,16 @@ bool SafeStack::IsMemIntrinsicSafe(const MemIntrinsic *MI, const Use &U,
       return true;
   }
 
-  const auto *Len = dyn_cast<ConstantInt>(MI->getLength());
-  // Non-constant size => unsafe. FIXME: try SCEV getRange.
-  if (!Len) return false;
-  return IsAccessSafe(U, Len->getZExtValue(), AllocaPtr, AllocaSize);
+  const SCEV *LenSCEV = SE.getSCEV(MI->getLength());
+  ConstantRange LenRange = SE.getUnsignedRange(LenSCEV);
+  auto element = LenRange.getSingleElement();
----------------
nikic wrote:

There's no point to doing this if you're only going to handle single-element ranges.

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


More information about the llvm-commits mailing list