[llvm] [ValueTracking] Handle range attributes (PR #85143)

via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 13 15:46:39 PDT 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 3e6d56617f43f86d65dba04c94277dc4a40c2a86 a15ab683aee72b66b751ac38be7acae4593d9aa5 -- llvm/lib/Analysis/ValueTracking.cpp llvm/unittests/Analysis/ValueTrackingTest.cpp
``````````

</details>

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

``````````diff
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 2a23368019..1b5cc918c7 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -1467,20 +1467,20 @@ static void computeKnownBitsFromOperator(const Operator *I,
     break;
   }
   case Instruction::Call:
-  case Instruction::Invoke:{
+  case Instruction::Invoke: {
     // If range metadata is attached to this call, set known bits from that,
     // and then intersect with known bits based on other properties of the
     // function.
     if (MDNode *MD =
             Q.IIQ.getMetadata(cast<Instruction>(I), LLVMContext::MD_range))
       computeKnownBitsFromRangeMetadata(*MD, Known);
-      
+
     const CallBase *CB = cast<CallBase>(I);
-    
+
     const Attribute RangeAttr = CB->getRetAttr(llvm::Attribute::Range);
     if (RangeAttr.isValid())
       Known = RangeAttr.getRange().toKnownBits();
-    
+
     if (const Value *RV = CB->getReturnedArgOperand()) {
       if (RV->getType() == I->getType()) {
         computeKnownBits(RV, Known2, Depth + 1, Q);
@@ -9149,13 +9149,13 @@ ConstantRange llvm::computeConstantRange(const Value *V, bool ForSigned,
     }
   }
 
-  if (auto *I = dyn_cast<Instruction>(V)){ 
+  if (auto *I = dyn_cast<Instruction>(V)) {
     if (auto *Range = IIQ.getMetadata(I, LLVMContext::MD_range))
       CR = CR.intersectWith(getConstantRangeFromMetadata(*Range));
-    
+
     if (const CallBase *CB = dyn_cast<CallBase>(V)) {
       const Attribute RangeAttr = CB->getRetAttr(llvm::Attribute::Range);
-      if (RangeAttr.isValid()) 
+      if (RangeAttr.isValid())
         CR = CR.intersectWith(RangeAttr.getRange());
     }
   }

``````````

</details>


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


More information about the llvm-commits mailing list