[llvm] Local: Handle noalias_addrspace in combineMetadata (PR #103938)

Fraser Cormack via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 22 02:17:58 PDT 2024


================
@@ -39,12 +39,14 @@ void ConstantRangeList::insert(const ConstantRange &NewRange) {
     return;
   assert(!NewRange.isFullSet() && "Do not support full set");
   assert(NewRange.getLower().slt(NewRange.getUpper()));
-  assert(getBitWidth() == NewRange.getBitWidth());
   // Handle common cases.
   if (empty() || Ranges.back().getUpper().slt(NewRange.getLower())) {
     Ranges.push_back(NewRange);
     return;
   }
+
+  assert(getBitWidth() == NewRange.getBitWidth());
----------------
frasercrmck wrote:

I agree that an empty range has no bitwidth. I missed that `ConstantRangeList` only deals with the insertion of pre-existing `ConstantRange`s. I think it's okay on balance to require users to only insert/union/intersect `ConstantRange`s of matching bitwidths.

I think a good way of expressing this would be to keep the asserts where they are but have `getBitWidth` return a value that represents "none" or "empty" which always compares `==` true with bitwidths of other non-empty ranges. That's probably not worth the effort, though. What you have now is probably okay.

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


More information about the llvm-commits mailing list