summaryrefslogtreecommitdiff
path: root/lib/Bitcode
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2011-04-10 00:04:27 +0000
committerBill Wendling <isanbard@gmail.com>2011-04-10 00:04:27 +0000
commitd7bb295d223e028aa9ba7fbeafc8928db4a74972 (patch)
tree6bbe67645fc6f7c4500dc6df7b7966e203ffda3f /lib/Bitcode
parentb1145c8cee6ab749f00d07d3d7dab0d1d1fd0c06 (diff)
downloadllvm-d7bb295d223e028aa9ba7fbeafc8928db4a74972.tar.gz
llvm-d7bb295d223e028aa9ba7fbeafc8928db4a74972.tar.bz2
llvm-d7bb295d223e028aa9ba7fbeafc8928db4a74972.tar.xz
Beginning of the Great Exception Handling Rewrite.
* Add a "landing pad" attribute to the BasicBlock. * Modify the bitcode reader and writer to handle said attribute. Later: The verifier will ensure that the landing pad attribute is used in the appropriate manner. I.e., not applied to the entry block, and applied only to basic blocks that are branched to via a `dispatch' instruction. (This is a work-in-progress.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129235 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode')
-rw-r--r--lib/Bitcode/Reader/BitcodeReader.cpp9
-rw-r--r--lib/Bitcode/Writer/BitcodeWriter.cpp32
2 files changed, 31 insertions, 10 deletions
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp
index 8223f76bbb..235519850f 100644
--- a/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -714,7 +714,8 @@ bool BitcodeReader::ParseValueSymbolTable() {
// Read a record.
Record.clear();
- switch (Stream.ReadRecord(Code, Record)) {
+ unsigned VSTCode = Stream.ReadRecord(Code, Record);
+ switch (VSTCode) {
default: // Default behavior: unknown type.
break;
case bitc::VST_CODE_ENTRY: { // VST_ENTRY: [valueid, namechar x N]
@@ -729,13 +730,17 @@ bool BitcodeReader::ParseValueSymbolTable() {
ValueName.clear();
break;
}
- case bitc::VST_CODE_BBENTRY: {
+ case bitc::VST_CODE_BBENTRY:
+ case bitc::VST_CODE_LPADENTRY: {
if (ConvertToString(Record, 1, ValueName))
return Error("Invalid VST_BBENTRY record");
BasicBlock *BB = getBasicBlock(Record[0]);
if (BB == 0)
return Error("Invalid BB ID in VST_BBENTRY record");
+ if (VSTCode == bitc::VST_CODE_LPADENTRY)
+ BB->setIsLandingPad(true);
+
BB->setName(StringRef(ValueName.data(), ValueName.size()));
ValueName.clear();
break;
diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp
index e34137f615..51c13bd501 100644
--- a/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -40,6 +40,7 @@ enum {
VST_ENTRY_7_ABBREV,
VST_ENTRY_6_ABBREV,
VST_BBENTRY_6_ABBREV,
+ VST_LPADENTRY_6_ABBREV,
// CONSTANTS_BLOCK abbrev id's.
CONSTANTS_SETTYPE_ABBREV = bitc::FIRST_APPLICATION_ABBREV,
@@ -1179,13 +1180,20 @@ static void WriteValueSymbolTable(const ValueSymbolTable &VST,
unsigned AbbrevToUse = VST_ENTRY_8_ABBREV;
- // VST_ENTRY: [valueid, namechar x N]
- // VST_BBENTRY: [bbid, namechar x N]
+ // VST_ENTRY: [valueid, namechar x N]
+ // VST_BBENTRY: [bbid, namechar x N]
+ // VST_LPADENTRY: [lpadid, namechar x N]
unsigned Code;
- if (isa<BasicBlock>(SI->getValue())) {
- Code = bitc::VST_CODE_BBENTRY;
- if (isChar6)
- AbbrevToUse = VST_BBENTRY_6_ABBREV;
+ if (const BasicBlock *BB = dyn_cast<BasicBlock>(SI->getValue())) {
+ if (BB->isLandingPad()) {
+ Code = bitc::VST_CODE_LPADENTRY;
+ if (isChar6)
+ AbbrevToUse = VST_LPADENTRY_6_ABBREV;
+ } else {
+ Code = bitc::VST_CODE_BBENTRY;
+ if (isChar6)
+ AbbrevToUse = VST_BBENTRY_6_ABBREV;
+ }
} else {
Code = bitc::VST_CODE_ENTRY;
if (isChar6)
@@ -1366,8 +1374,16 @@ static void WriteBlockInfo(const ValueEnumerator &VE, BitstreamWriter &Stream) {
Abbv) != VST_BBENTRY_6_ABBREV)
llvm_unreachable("Unexpected abbrev ordering!");
}
-
-
+ { // 6-bit char6 VST_LPADENTRY strings.
+ BitCodeAbbrev *Abbv = new BitCodeAbbrev();
+ Abbv->Add(BitCodeAbbrevOp(bitc::VST_CODE_LPADENTRY));
+ Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
+ Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
+ Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Char6));
+ if (Stream.EmitBlockInfoAbbrev(bitc::VALUE_SYMTAB_BLOCK_ID,
+ Abbv) != VST_LPADENTRY_6_ABBREV)
+ llvm_unreachable("Unexpected abbrev ordering!");
+ }
{ // SETTYPE abbrev for CONSTANTS_BLOCK.
BitCodeAbbrev *Abbv = new BitCodeAbbrev();