| OLD | NEW |
| 1 //===- PNaClABIVerifyFunctions.cpp - Verify PNaCl ABI rules ---------------===// | 1 //===- PNaClABIVerifyFunctions.cpp - Verify PNaCl ABI rules ---------------===// |
| 2 // | 2 // |
| 3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
| 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 // Verify function-level PNaCl ABI requirements. | 10 // Verify function-level PNaCl ABI requirements. |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 if (!isValidScalarOperand(Switch->getCondition())) | 459 if (!isValidScalarOperand(Switch->getCondition())) |
| 460 return "bad switch condition"; | 460 return "bad switch condition"; |
| 461 if (Switch->getCondition()->getType()->isIntegerTy(1)) | 461 if (Switch->getCondition()->getType()->isIntegerTy(1)) |
| 462 return "switch on i1"; | 462 return "switch on i1"; |
| 463 | 463 |
| 464 // SwitchInst requires the cases to be ConstantInts, but it | 464 // SwitchInst requires the cases to be ConstantInts, but it |
| 465 // doesn't require their types to be the same as the condition | 465 // doesn't require their types to be the same as the condition |
| 466 // value, so check all the cases too. | 466 // value, so check all the cases too. |
| 467 for (SwitchInst::ConstCaseIt Case = Switch->case_begin(), | 467 for (SwitchInst::ConstCaseIt Case = Switch->case_begin(), |
| 468 E = Switch->case_end(); Case != E; ++Case) { | 468 E = Switch->case_end(); Case != E; ++Case) { |
| 469 // This check will go away when we merge upstream's r190328, | |
| 470 // which removes all case range support. | |
| 471 if (!Case.getCaseValueEx().isSingleNumber()) | |
| 472 return "case range in switch instruction"; | |
| 473 | |
| 474 if (!isValidScalarOperand(Case.getCaseValue())) | 469 if (!isValidScalarOperand(Case.getCaseValue())) |
| 475 return "bad switch case"; | 470 return "bad switch case"; |
| 476 } | 471 } |
| 477 | 472 |
| 478 // Allow the instruction and skip the later checks. | 473 // Allow the instruction and skip the later checks. |
| 479 return NULL; | 474 return NULL; |
| 480 } | 475 } |
| 481 } | 476 } |
| 482 | 477 |
| 483 // Check the instruction's operands. We have already checked any | 478 // Check the instruction's operands. We have already checked any |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 } | 555 } |
| 561 | 556 |
| 562 char PNaClABIVerifyFunctions::ID = 0; | 557 char PNaClABIVerifyFunctions::ID = 0; |
| 563 INITIALIZE_PASS(PNaClABIVerifyFunctions, "verify-pnaclabi-functions", | 558 INITIALIZE_PASS(PNaClABIVerifyFunctions, "verify-pnaclabi-functions", |
| 564 "Verify functions for PNaCl", false, true) | 559 "Verify functions for PNaCl", false, true) |
| 565 | 560 |
| 566 FunctionPass *llvm::createPNaClABIVerifyFunctionsPass( | 561 FunctionPass *llvm::createPNaClABIVerifyFunctionsPass( |
| 567 PNaClABIErrorReporter *Reporter) { | 562 PNaClABIErrorReporter *Reporter) { |
| 568 return new PNaClABIVerifyFunctions(Reporter); | 563 return new PNaClABIVerifyFunctions(Reporter); |
| 569 } | 564 } |
| OLD | NEW |