[clang] [llvm] [CVP] Infer range return attribute (PR #99620)

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 20 02:55:36 PDT 2024


================
@@ -1289,6 +1299,14 @@ static bool runImpl(Function &F, LazyValueInfo *LVI, DominatorTree *DT,
     FnChanged |= BBChanged;
   }
 
+  // Infer range attribute on return value.
+  if (RetRange && !RetRange->isFullSet()) {
+    Attribute RangeAttr = F.getRetAttribute(Attribute::Range);
+    if (RangeAttr.isValid())
+      RetRange = RetRange->intersectWith(RangeAttr.getRange());
+    if (!RetRange->isEmptySet() && !RetRange->isSingleElement())
+      F.addRangeRetAttr(*RetRange);
----------------
nikic wrote:

Good point, fixed.

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


More information about the cfe-commits mailing list