================
@@ -6878,6 +6878,41 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID,
CallBase &Call) {
&Call);
break;
}
+ case Intrinsic::structured_gep: {
+ // Parser should refuse those 2 cases.
+ assert(Call.getNumOperands() >= 2);
+ assert(Call.getOperand(0)->getType()->isPointerTy());
+
+ Check(Call.paramHasAttr(0, Attribute::ElementType),
+ "Intrinsic first parameter is missing an ElementType attribute",
+ &Call);
+
+ Type *T = Call.getParamAttr(0, Attribute::ElementType).getValueAsType();
+ for (unsigned I = 1; I < Call.getNumOperands() - 1; ++I) {
+ Value *Index = Call.getOperand(I);
+ ConstantInt *CI = dyn_cast<ConstantInt>(Index);
+ Check(Index->getType()->isIntegerTy(),
+ "Index operand type must be an integer", &Call);
+
+ if (ArrayType *AT = dyn_cast<ArrayType>(T)) {
+ T = AT->getElementType();
+ if (CI && AT->getNumElements() != 0)
+ Check(CI->getZExtValue() < AT->getNumElements(),
+ "Indexing in an array should be inbounds", &Call);
----------------
Keenuts wrote:
Ah right, and since doc says it returns poison that's fine. Relaxed this check
and updated the test.
https://github.com/llvm/llvm-project/pull/176145
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits