[llvm] [llvm] Use LazyValueInfo to improve llvm.objectsize computation (PR #114673)

via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 5 12:16:55 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff af6ebb70d22ed75d4472a6069ba3a0890e0d3a00 8842c80936ab2f240bd42a102289f648fd8210c1 --extensions cpp,h -- llvm/include/llvm/Analysis/MemoryBuiltins.h llvm/lib/Analysis/MemoryBuiltins.cpp llvm/lib/Transforms/InstCombine/InstructionCombining.cpp llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/Analysis/MemoryBuiltins.cpp b/llvm/lib/Analysis/MemoryBuiltins.cpp
index e0e7189d17..043c5d24f4 100644
--- a/llvm/lib/Analysis/MemoryBuiltins.cpp
+++ b/llvm/lib/Analysis/MemoryBuiltins.cpp
@@ -722,35 +722,34 @@ OffsetSpan ObjectSizeOffsetVisitor::computeImpl(Value *V) {
 
   // External Analysis used to compute the Min/Max value of individual Offsets
   // within a GEP.
-  auto OffsetRangeAnalysis =
-      [this, V](Value &VOffset, APInt &Offset) {
-        if (auto *C = dyn_cast<ConstantInt>(&VOffset)) {
-          Offset = C->getValue();
-          return true;
-        }
-        if (Options.EvalMode != ObjectSizeOpts::Mode::Min &&
-            Options.EvalMode != ObjectSizeOpts::Mode::Max) {
-          return false;
-        }
-        ConstantRange CR = computeConstantRange(
-            &VOffset, /*ForSigned*/ true, /*UseInstrInfo*/ true, /*AC=*/nullptr,
-            /*CtxtI=*/dyn_cast<Instruction>(V), /*DT=*/Options.DT);
-        if (CR.isFullSet())
-          return false;
-
-        if (Options.EvalMode == ObjectSizeOpts::Mode::Min) {
-          Offset = CR.getSignedMax();
-          // Upper bound actually unknown.
-          if (Offset.isMaxSignedValue())
-            return false;
-        } else {
-          Offset = CR.getSignedMin();
-          // Lower bound actually unknown.
-          if (Offset.isMinSignedValue())
-            return false;
-        }
-        return true;
-      };
+  auto OffsetRangeAnalysis = [this, V](Value &VOffset, APInt &Offset) {
+    if (auto *C = dyn_cast<ConstantInt>(&VOffset)) {
+      Offset = C->getValue();
+      return true;
+    }
+    if (Options.EvalMode != ObjectSizeOpts::Mode::Min &&
+        Options.EvalMode != ObjectSizeOpts::Mode::Max) {
+      return false;
+    }
+    ConstantRange CR = computeConstantRange(
+        &VOffset, /*ForSigned*/ true, /*UseInstrInfo*/ true, /*AC=*/nullptr,
+        /*CtxtI=*/dyn_cast<Instruction>(V), /*DT=*/Options.DT);
+    if (CR.isFullSet())
+      return false;
+
+    if (Options.EvalMode == ObjectSizeOpts::Mode::Min) {
+      Offset = CR.getSignedMax();
+      // Upper bound actually unknown.
+      if (Offset.isMaxSignedValue())
+        return false;
+    } else {
+      Offset = CR.getSignedMin();
+      // Lower bound actually unknown.
+      if (Offset.isMinSignedValue())
+        return false;
+    }
+    return true;
+  };
 
   V = const_cast<Value *>(V->stripAndAccumulateConstantOffsets(
       DL, Offset, /* AllowNonInbounds */ true, /* AllowInvariantGroup */ true,

``````````

</details>


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


More information about the llvm-commits mailing list