Commit 92b31446 by Jim Stichnoth

Subzero: Fix off-by-one asserts in intrinsic info lookup routines.

It turns out that getNumArgs() and getReturnType() were never actually called except to print errors, so this bug was never encountered until now. BUG= https://code.google.com/p/nativeclient/issues/detail?id=4315 R=ascull@google.com Review URL: https://codereview.chromium.org/1347683002 .
parent e7dbc0bc
......@@ -315,17 +315,17 @@ bool Intrinsics::isMemoryOrderValid(IntrinsicID ID, uint64_t Order,
}
Intrinsics::ValidateCallValue
Intrinsics::FullIntrinsicInfo::validateCall(const Ice::InstCall *Call,
Intrinsics::FullIntrinsicInfo::validateCall(const InstCall *Call,
SizeT &ArgIndex) const {
assert(NumTypes >= 1);
Variable *Result = Call->getDest();
if (Result == nullptr) {
if (Signature[0] != Ice::IceType_void)
if (getReturnType() != IceType_void)
return Intrinsics::BadReturnType;
} else if (Signature[0] != Result->getType()) {
} else if (getReturnType() != Result->getType()) {
return Intrinsics::BadReturnType;
}
if (Call->getNumArgs() + 1 != NumTypes) {
if (Call->getNumArgs() != getNumArgs()) {
return Intrinsics::WrongNumOfArgs;
}
for (size_t i = 1; i < NumTypes; ++i) {
......
......@@ -140,13 +140,13 @@ public:
/// Returns the return type of the intrinsic.
Type getReturnType() const {
assert(NumTypes > 1);
assert(NumTypes > 0);
return Signature[0];
}
/// Returns number of arguments expected.
SizeT getNumArgs() const {
assert(NumTypes > 1);
assert(NumTypes > 0);
return NumTypes - 1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment