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

Side by Side Diff: src/PNaClTranslator.cpp

Issue 1359993002: Fix code checking arguments to an intrinsic call. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix nits. Created 5 years, 2 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.cpp ('k') | tests_lit/parse_errs/Inputs/bad-intrinsic-arg.tbc » ('j') | 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/PNaClTranslator.cpp - ICE from bitcode -----------------===// 1 //===- subzero/src/PNaClTranslator.cpp - ICE from bitcode -----------------===//
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 2648 matching lines...) Expand 10 before | Expand all | Expand 10 after
2659 return; 2659 return;
2660 ParamsStartIndex = 3; 2660 ParamsStartIndex = 3;
2661 } 2661 }
2662 2662
2663 // Extract out the called function and its return type. 2663 // Extract out the called function and its return type.
2664 uint32_t CalleeIndex = convertRelativeToAbsIndex(Values[1], BaseIndex); 2664 uint32_t CalleeIndex = convertRelativeToAbsIndex(Values[1], BaseIndex);
2665 Ice::Operand *Callee = getOperand(CalleeIndex); 2665 Ice::Operand *Callee = getOperand(CalleeIndex);
2666 const Ice::FuncSigType *Signature = nullptr; 2666 const Ice::FuncSigType *Signature = nullptr;
2667 Ice::Type ReturnType = Ice::IceType_void; 2667 Ice::Type ReturnType = Ice::IceType_void;
2668 const Ice::Intrinsics::FullIntrinsicInfo *IntrinsicInfo = nullptr; 2668 const Ice::Intrinsics::FullIntrinsicInfo *IntrinsicInfo = nullptr;
2669 // Name of function if a direct call/intrinsic. Null otherwise.
2670 Ice::FunctionDeclaration *Fcn = nullptr;
2669 if (Record.GetCode() == naclbitc::FUNC_CODE_INST_CALL) { 2671 if (Record.GetCode() == naclbitc::FUNC_CODE_INST_CALL) {
2670 Ice::FunctionDeclaration *Fcn = Context->getFunctionByID(CalleeIndex); 2672 Fcn = Context->getFunctionByID(CalleeIndex);
2671 Signature = &Fcn->getSignature(); 2673 Signature = &Fcn->getSignature();
2672 ReturnType = Signature->getReturnType(); 2674 ReturnType = Signature->getReturnType();
2673 2675
2674 // Check if this direct call is to an Intrinsic (starts with "llvm.") 2676 // Check if this direct call is to an Intrinsic (starts with "llvm.")
2675 bool BadIntrinsic; 2677 bool BadIntrinsic;
2676 const Ice::IceString &Name = Fcn->getName(); 2678 const Ice::IceString &Name = Fcn->getName();
2677 IntrinsicInfo = getTranslator().getContext()->getIntrinsicsInfo().find( 2679 IntrinsicInfo = getTranslator().getContext()->getIntrinsicsInfo().find(
2678 Name, BadIntrinsic); 2680 Name, BadIntrinsic);
2679 if (BadIntrinsic) { 2681 if (BadIntrinsic) {
2680 std::string Buffer; 2682 std::string Buffer;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
2793 2795
2794 // If intrinsic call, validate call signature. 2796 // If intrinsic call, validate call signature.
2795 if (IntrinsicInfo) { 2797 if (IntrinsicInfo) {
2796 Ice::SizeT ArgIndex = 0; 2798 Ice::SizeT ArgIndex = 0;
2797 switch (IntrinsicInfo->validateCall(Inst.get(), ArgIndex)) { 2799 switch (IntrinsicInfo->validateCall(Inst.get(), ArgIndex)) {
2798 case Ice::Intrinsics::IsValidCall: 2800 case Ice::Intrinsics::IsValidCall:
2799 break; 2801 break;
2800 case Ice::Intrinsics::BadReturnType: { 2802 case Ice::Intrinsics::BadReturnType: {
2801 std::string Buffer; 2803 std::string Buffer;
2802 raw_string_ostream StrBuf(Buffer); 2804 raw_string_ostream StrBuf(Buffer);
2803 StrBuf << "Intrinsic call expects return type " 2805 StrBuf << "Intrinsic " << Fcn->getName() << " expects return type"
2804 << IntrinsicInfo->getReturnType() 2806 << IntrinsicInfo->getReturnType()
2805 << ". Found: " << Inst->getReturnType(); 2807 << ". Found: " << Inst->getReturnType();
2806 Error(StrBuf.str()); 2808 Error(StrBuf.str());
2807 break; 2809 break;
2808 } 2810 }
2809 case Ice::Intrinsics::WrongNumOfArgs: { 2811 case Ice::Intrinsics::WrongNumOfArgs: {
2810 std::string Buffer; 2812 std::string Buffer;
2811 raw_string_ostream StrBuf(Buffer); 2813 raw_string_ostream StrBuf(Buffer);
2812 StrBuf << "Intrinsic call expects " << IntrinsicInfo->getNumArgs() 2814 StrBuf << "Intrinsic " << Fcn->getName() << " expects "
2815 << IntrinsicInfo->getNumArgs()
2813 << ". Found: " << Inst->getNumArgs(); 2816 << ". Found: " << Inst->getNumArgs();
2814 Error(StrBuf.str()); 2817 Error(StrBuf.str());
2815 break; 2818 break;
2816 } 2819 }
2817 case Ice::Intrinsics::WrongCallArgType: { 2820 case Ice::Intrinsics::WrongCallArgType: {
2818 std::string Buffer; 2821 std::string Buffer;
2819 raw_string_ostream StrBuf(Buffer); 2822 raw_string_ostream StrBuf(Buffer);
2820 StrBuf << "Intrinsic call argument " << ArgIndex << " expects type " 2823 StrBuf << "Intrinsic " << Fcn->getName() << " expects "
2821 << IntrinsicInfo->getArgType(ArgIndex) 2824 << IntrinsicInfo->getArgType(ArgIndex) << " for argument "
2825 << (ArgIndex + 1)
2822 << ". Found: " << Inst->getArg(ArgIndex)->getType(); 2826 << ". Found: " << Inst->getArg(ArgIndex)->getType();
2823 Error(StrBuf.str()); 2827 Error(StrBuf.str());
2824 break; 2828 break;
2825 } 2829 }
2826 } 2830 }
2827 } 2831 }
2828 2832
2829 CurrentNode->appendInst(Inst.release()); 2833 CurrentNode->appendInst(Inst.release());
2830 return; 2834 return;
2831 } 2835 }
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
3292 raw_string_ostream StrBuf(Buffer); 3296 raw_string_ostream StrBuf(Buffer);
3293 StrBuf << IRFilename << ": Does not contain a module!"; 3297 StrBuf << IRFilename << ": Does not contain a module!";
3294 llvm::report_fatal_error(StrBuf.str()); 3298 llvm::report_fatal_error(StrBuf.str());
3295 } 3299 }
3296 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) { 3300 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) {
3297 llvm::report_fatal_error("Bitcode stream should be a multiple of 4 bytes"); 3301 llvm::report_fatal_error("Bitcode stream should be a multiple of 4 bytes");
3298 } 3302 }
3299 } 3303 }
3300 3304
3301 } // end of namespace Ice 3305 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceIntrinsics.cpp ('k') | tests_lit/parse_errs/Inputs/bad-intrinsic-arg.tbc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698