================
@@ -6413,10 +6413,9 @@ CodeGenFunction::EmitCheckedInBoundsGEP(llvm::Type 
*ElemTy, Value *Ptr,
   GEPOffsetAndOverflow EvaluatedGEP =
       EmitGEPOffsetInBytes(Ptr, GEPVal, getLLVMContext(), CGM, Builder);
 
-  assert((!isa<llvm::Constant>(EvaluatedGEP.TotalOffset) ||
-          EvaluatedGEP.OffsetOverflows == Builder.getFalse()) &&
-         "If the offset got constant-folded, we don't expect that there was an 
"
-         "overflow.");
+  // Note: TotalOffset can be a constant even when the GEP is non-constant
+  // (e.g. runtime base pointer with constant index). In that case,
+  // OffsetOverflows may be true if the constant offset computation overflowed.
----------------
efriedma-quic wrote:

This comment is not wrong, I guess, but there's still a bug here: a few lines 
later we check `EvaluatedGEP.TotalOffset == Zero`.

https://github.com/llvm/llvm-project/pull/191278
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to