[llvm] [NFC] Reduce copies created of ConstantRange when getting ConstantRangeAttributes. (PR #90335)

Andreas Jonson via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 28 23:34:19 PDT 2024


================
@@ -2199,8 +2199,8 @@ class CallBase : public Instruction {
   FPClassTest getParamNoFPClass(unsigned i) const;
 
   /// If this return value has a range attribute, return the value range of the
-  /// argument. Otherwise, std::nullopt is returned.
-  std::optional<ConstantRange> getRange() const;
+  /// argument. Otherwise, nullptr is returned.
+  const ConstantRange *getRange() const;
----------------
andjo403 wrote:

I'm not sure that I understand this comment, the intersect methods seems to works on `const ConstantRange*` as it is e.g.
`ConstantRange intersectWith(const ConstantRange &CR, PreferredRangeType Type = Smallest) const;` 
or was there something else that you was thinking about?

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


More information about the llvm-commits mailing list