OLD | NEW |
---|---|
1 //===- NaClBitcodeReader.cpp ----------------------------------------------===// | 1 //===- NaClBitcodeReader.cpp ----------------------------------------------===// |
2 // Internal NaClBitcodeReader implementation | 2 // Internal NaClBitcodeReader implementation |
3 // | 3 // |
4 // The LLVM Compiler Infrastructure | 4 // The LLVM Compiler Infrastructure |
5 // | 5 // |
6 // This file is distributed under the University of Illinois Open Source | 6 // This file is distributed under the University of Illinois Open Source |
7 // License. See LICENSE.TXT for details. | 7 // License. See LICENSE.TXT for details. |
8 // | 8 // |
9 //===----------------------------------------------------------------------===// | 9 //===----------------------------------------------------------------------===// |
10 | 10 |
(...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1503 for (size_t i = 0; i != NumCases; ++i) { | 1503 for (size_t i = 0; i != NumCases; ++i) { |
1504 // The PNaCl bitcode format has vestigial support for case | 1504 // The PNaCl bitcode format has vestigial support for case |
1505 // ranges, but we no longer support reading them because | 1505 // ranges, but we no longer support reading them because |
1506 // no-one produced them. | 1506 // no-one produced them. |
1507 // See https://code.google.com/p/nativeclient/issues/detail?id=3758 | 1507 // See https://code.google.com/p/nativeclient/issues/detail?id=3758 |
1508 if (CurIdx + 3 >= Record.size()) | 1508 if (CurIdx + 3 >= Record.size()) |
1509 return Error(InvalidRecord, | 1509 return Error(InvalidRecord, |
1510 "Incomplete case entry in SWITCH record"); | 1510 "Incomplete case entry in SWITCH record"); |
1511 uint64_t NumItems = Record[CurIdx++]; | 1511 uint64_t NumItems = Record[CurIdx++]; |
1512 bool isSingleNumber = Record[CurIdx++]; | 1512 bool isSingleNumber = Record[CurIdx++]; |
1513 if (NumItems != 1 || !isSingleNumber) | 1513 if (NumItems != 1 || !isSingleNumber) { |
1514 delete SI; | |
JF
2015/08/18 17:07:46
Can this file as well as upstream lib/Bitcode/Read
Karl
2015/08/19 19:39:00
Switches are not special. The code was written thi
| |
1514 return Error(InvalidRecord, | 1515 return Error(InvalidRecord, |
1515 "Case ranges are not supported in PNaCl bitcode"); | 1516 "Case ranges are not supported in PNaCl bitcode"); |
1517 } | |
1516 | 1518 |
1517 APInt CaseValue(ValueBitWidth, | 1519 APInt CaseValue(ValueBitWidth, |
1518 NaClDecodeSignRotatedValue(Record[CurIdx++])); | 1520 NaClDecodeSignRotatedValue(Record[CurIdx++])); |
1519 BasicBlock *DestBB = getBasicBlock(Record[CurIdx++]); | 1521 BasicBlock *DestBB = getBasicBlock(Record[CurIdx++]); |
1522 if (DestBB == nullptr) { | |
1523 delete SI; | |
1524 return Error(InvalidValue, "Invalid branch in SWITCH case"); | |
1525 } | |
1520 SI->addCase(ConstantInt::get(Context, CaseValue), DestBB); | 1526 SI->addCase(ConstantInt::get(Context, CaseValue), DestBB); |
1521 } | 1527 } |
1522 I = SI; | 1528 I = SI; |
1523 break; | 1529 break; |
1524 } | 1530 } |
1525 case naclbitc::FUNC_CODE_INST_UNREACHABLE: // UNREACHABLE | 1531 case naclbitc::FUNC_CODE_INST_UNREACHABLE: // UNREACHABLE |
1526 I = new UnreachableInst(Context); | 1532 I = new UnreachableInst(Context); |
1527 break; | 1533 break; |
1528 case naclbitc::FUNC_CODE_INST_PHI: { // PHI: [ty, val0,bb0, ...] | 1534 case naclbitc::FUNC_CODE_INST_PHI: { // PHI: [ty, val0,bb0, ...] |
1529 if (Record.size() < 1 || ((Record.size()-1)&1)) | 1535 if (Record.size() < 1 || ((Record.size()-1)&1)) |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1992 if (std::error_code EC = M->materializeAllPermanently()) { | 1998 if (std::error_code EC = M->materializeAllPermanently()) { |
1993 delete M; | 1999 delete M; |
1994 return EC; | 2000 return EC; |
1995 } | 2001 } |
1996 | 2002 |
1997 // TODO: Restore the use-lists to the in-memory state when the bitcode was | 2003 // TODO: Restore the use-lists to the in-memory state when the bitcode was |
1998 // written. We must defer until the Module has been fully materialized. | 2004 // written. We must defer until the Module has been fully materialized. |
1999 | 2005 |
2000 return M; | 2006 return M; |
2001 } | 2007 } |
OLD | NEW |