Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: src/IceIntrinsics.cpp

Issue 1347683002: Subzero: Fix off-by-one asserts in intrinsic info lookup routines. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Add real uses of getReturnType() and getNumArgs() Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceIntrinsics.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceIntrinsics.cpp - Functions related to intrinsics ----===// 1 //===- subzero/src/IceIntrinsics.cpp - Functions related to intrinsics ----===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 /// 9 ///
10 /// \file 10 /// \file
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 case MemoryOrderAcquire: 308 case MemoryOrderAcquire:
309 case MemoryOrderAcquireRelease: 309 case MemoryOrderAcquireRelease:
310 return false; 310 return false;
311 default: 311 default:
312 return true; 312 return true;
313 } 313 }
314 } 314 }
315 } 315 }
316 316
317 Intrinsics::ValidateCallValue 317 Intrinsics::ValidateCallValue
318 Intrinsics::FullIntrinsicInfo::validateCall(const Ice::InstCall *Call, 318 Intrinsics::FullIntrinsicInfo::validateCall(const InstCall *Call,
319 SizeT &ArgIndex) const { 319 SizeT &ArgIndex) const {
320 assert(NumTypes >= 1); 320 assert(NumTypes >= 1);
321 Variable *Result = Call->getDest(); 321 Variable *Result = Call->getDest();
322 if (Result == nullptr) { 322 if (Result == nullptr) {
323 if (Signature[0] != Ice::IceType_void) 323 if (getReturnType() != IceType_void)
324 return Intrinsics::BadReturnType; 324 return Intrinsics::BadReturnType;
325 } else if (Signature[0] != Result->getType()) { 325 } else if (getReturnType() != Result->getType()) {
326 return Intrinsics::BadReturnType; 326 return Intrinsics::BadReturnType;
327 } 327 }
328 if (Call->getNumArgs() + 1 != NumTypes) { 328 if (Call->getNumArgs() != getNumArgs()) {
329 return Intrinsics::WrongNumOfArgs; 329 return Intrinsics::WrongNumOfArgs;
330 } 330 }
331 for (size_t i = 1; i < NumTypes; ++i) { 331 for (size_t i = 1; i < NumTypes; ++i) {
332 if (Call->getArg(i - 1)->getType() != Signature[i]) { 332 if (Call->getArg(i - 1)->getType() != Signature[i]) {
333 ArgIndex = i; 333 ArgIndex = i;
334 return Intrinsics::WrongCallArgType; 334 return Intrinsics::WrongCallArgType;
335 } 335 }
336 } 336 }
337 return Intrinsics::IsValidCall; 337 return Intrinsics::IsValidCall;
338 } 338 }
339 339
340 Type Intrinsics::FullIntrinsicInfo::getArgType(SizeT Index) const { 340 Type Intrinsics::FullIntrinsicInfo::getArgType(SizeT Index) const {
341 assert(NumTypes > 1); 341 assert(NumTypes > 1);
342 assert(Index + 1 < NumTypes); 342 assert(Index + 1 < NumTypes);
343 return Signature[Index + 1]; 343 return Signature[Index + 1];
344 } 344 }
345 345
346 } // end of namespace Ice 346 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceIntrinsics.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698