================
@@ -4983,6 +4996,83 @@ static Value *upgradeConvertIntrinsicCall(StringRef 
Name, CallBase *CI,
   return nullptr;
 }
 
+static StructuredGEPFlags getLegacyStructuredGEPIndexFlags(Type *&CurrentType,
+                                                           Value *Index) {
+  StructuredGEPFlags Flags = StructuredGEPFlags::unsignedIndex();
+  if (!CurrentType)
+    return Flags;
+
+  if (auto *AT = dyn_cast<ArrayType>(CurrentType)) {
+    if (AT->getNumElements() != 0)
+      Flags |= StructuredGEPFlags::inBounds();
+    CurrentType = AT->getElementType();
+    return Flags;
+  }
+
+  if (auto *VT = dyn_cast<VectorType>(CurrentType)) {
+    Flags |= StructuredGEPFlags::inBounds();
+    CurrentType = VT->getElementType();
+    return Flags;
+  }
+
+  if (auto *ST = dyn_cast<StructType>(CurrentType)) {
+    Flags |= StructuredGEPFlags::inBounds() | StructuredGEPFlags::nneg();
+    if (auto *CI = dyn_cast<ConstantInt>(Index))
+      if (CI->getZExtValue() < ST->getNumElements())
+        CurrentType = ST->getElementType(CI->getZExtValue());
----------------
Flakebi wrote:

This is all silently failing and setting pretty much random flags (as 
`CurrentType` stays the previous type) when one of the checks fails. Is this 
intended?

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

Reply via email to