llvm.org GIT mirror llvm / 5d7a5a4
Revert r129235 pending a vetting of the EH rewrite. --- Reverse-merging r129235 into '.': D test/Feature/bb_attrs.ll U include/llvm/BasicBlock.h U include/llvm/Bitcode/LLVMBitCodes.h U lib/VMCore/AsmWriter.cpp U lib/VMCore/BasicBlock.cpp U lib/AsmParser/LLParser.cpp U lib/AsmParser/LLLexer.cpp U lib/AsmParser/LLToken.h U lib/Bitcode/Reader/BitcodeReader.cpp U lib/Bitcode/Writer/BitcodeWriter.cpp git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129259 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 9 years ago
10 changed file(s) with 16 addition(s) and 87 deletion(s). Raw diff Collapse all Expand all
7373 private:
7474 InstListType InstList;
7575 Function *Parent;
76 bool IsLandingPad;
7776
7877 void setParent(Function *parent);
7978 friend class SymbolTableListTraits;
138137 return const_cast(this)->getFirstNonPHIOrDbg();
139138 }
140139
141 /// isLandingPad - True if this basic block is a landing pad for exception
142 /// handling.
143 bool isLandingPad() const { return IsLandingPad; }
144 void setIsLandingPad(bool Val = true) { IsLandingPad = Val; }
145
146140 /// removeFromParent - This method unlinks 'this' from the containing
147141 /// function, but does not delete it.
148142 ///
105105
106106 // The value symbol table only has one code (VST_ENTRY_CODE).
107107 enum ValueSymtabCodes {
108 VST_CODE_ENTRY = 1, // VST_ENTRY: [valid, namechar x N]
109 VST_CODE_BBENTRY = 2, // VST_BBENTRY: [bbid, namechar x N]
110 VST_CODE_LPADENTRY = 3 // VST_LPADENTRY: [lpadid, namechar x N]
108 VST_CODE_ENTRY = 1, // VST_ENTRY: [valid, namechar x N]
109 VST_CODE_BBENTRY = 2 // VST_BBENTRY: [bbid, namechar x N]
111110 };
112111
113112 enum MetadataCodes {
586586
587587 KEYWORD(x);
588588 KEYWORD(blockaddress);
589
590 KEYWORD(landingpad);
591589 #undef KEYWORD
592590
593591 // Keywords for types.
29172917 BasicBlock *BB = PFS.DefineBB(Name, NameLoc);
29182918 if (BB == 0) return true;
29192919
2920 if (Lex.getKind() == lltok::kw_landingpad) {
2921 BB->setIsLandingPad();
2922 Lex.Lex();
2923 }
2924
29252920 std::string NameStr;
29262921
29272922 // Parse the instructions in this block until we get a terminator.
124124 kw_extractelement, kw_insertelement, kw_shufflevector, kw_getresult,
125125 kw_extractvalue, kw_insertvalue, kw_blockaddress,
126126
127 // Basic block attribute.
128 kw_landingpad,
129
130127 // Unsigned Valued tokens (UIntVal).
131128 GlobalID, // @42
132129 LocalVarID, // %42
713713
714714 // Read a record.
715715 Record.clear();
716 unsigned VSTCode = Stream.ReadRecord(Code, Record);
717 switch (VSTCode) {
716 switch (Stream.ReadRecord(Code, Record)) {
718717 default: // Default behavior: unknown type.
719718 break;
720719 case bitc::VST_CODE_ENTRY: { // VST_ENTRY: [valueid, namechar x N]
729728 ValueName.clear();
730729 break;
731730 }
732 case bitc::VST_CODE_BBENTRY:
733 case bitc::VST_CODE_LPADENTRY: {
731 case bitc::VST_CODE_BBENTRY: {
734732 if (ConvertToString(Record, 1, ValueName))
735733 return Error("Invalid VST_BBENTRY record");
736734 BasicBlock *BB = getBasicBlock(Record[0]);
737735 if (BB == 0)
738736 return Error("Invalid BB ID in VST_BBENTRY record");
739
740 if (VSTCode == bitc::VST_CODE_LPADENTRY)
741 BB->setIsLandingPad(true);
742737
743738 BB->setName(StringRef(ValueName.data(), ValueName.size()));
744739 ValueName.clear();
3939 VST_ENTRY_7_ABBREV,
4040 VST_ENTRY_6_ABBREV,
4141 VST_BBENTRY_6_ABBREV,
42 VST_LPADENTRY_6_ABBREV,
4342
4443 // CONSTANTS_BLOCK abbrev id's.
4544 CONSTANTS_SETTYPE_ABBREV = bitc::FIRST_APPLICATION_ABBREV,
11791178
11801179 unsigned AbbrevToUse = VST_ENTRY_8_ABBREV;
11811180
1182 // VST_ENTRY: [valueid, namechar x N]
1183 // VST_BBENTRY: [bbid, namechar x N]
1184 // VST_LPADENTRY: [lpadid, namechar x N]
1181 // VST_ENTRY: [valueid, namechar x N]
1182 // VST_BBENTRY: [bbid, namechar x N]
11851183 unsigned Code;
1186 if (const BasicBlock *BB = dyn_cast(SI->getValue())) {
1187 if (BB->isLandingPad()) {
1188 Code = bitc::VST_CODE_LPADENTRY;
1189 if (isChar6)
1190 AbbrevToUse = VST_LPADENTRY_6_ABBREV;
1191 } else {
1192 Code = bitc::VST_CODE_BBENTRY;
1193 if (isChar6)
1194 AbbrevToUse = VST_BBENTRY_6_ABBREV;
1195 }
1184 if (isa(SI->getValue())) {
1185 Code = bitc::VST_CODE_BBENTRY;
1186 if (isChar6)
1187 AbbrevToUse = VST_BBENTRY_6_ABBREV;
11961188 } else {
11971189 Code = bitc::VST_CODE_ENTRY;
11981190 if (isChar6)
13731365 Abbv) != VST_BBENTRY_6_ABBREV)
13741366 llvm_unreachable("Unexpected abbrev ordering!");
13751367 }
1376 { // 6-bit char6 VST_LPADENTRY strings.
1377 BitCodeAbbrev *Abbv = new BitCodeAbbrev();
1378 Abbv->Add(BitCodeAbbrevOp(bitc::VST_CODE_LPADENTRY));
1379 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1380 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
1381 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Char6));
1382 if (Stream.EmitBlockInfoAbbrev(bitc::VALUE_SYMTAB_BLOCK_ID,
1383 Abbv) != VST_LPADENTRY_6_ABBREV)
1384 llvm_unreachable("Unexpected abbrev ordering!");
1385 }
1368
1369
13861370
13871371 { // SETTYPE abbrev for CONSTANTS_BLOCK.
13881372 BitCodeAbbrev *Abbv = new BitCodeAbbrev();
16861686 Out << "\n";
16871687 PrintLLVMName(Out, BB->getName(), LabelPrefix);
16881688 Out << ':';
1689 if (BB->isLandingPad())
1690 Out << " landingpad";
16911689 } else if (!BB->use_empty()) { // Don't print block # of no uses...
1692 Out << '\n';
1693 if (BB->isLandingPad())
1694 Out << "landingpad ";
1695 Out << ";
1690 Out << "\n;
16961691 int Slot = Machine.getLocalSlot(BB);
16971692 if (Slot != -1)
16981693 Out << Slot;
3737 // are not in the public header file...
3838 template class llvm::SymbolTableListTraits;
3939
40
4041 BasicBlock::BasicBlock(LLVMContext &C, const Twine &Name, Function *NewParent,
4142 BasicBlock *InsertBefore)
42 : Value(Type::getLabelTy(C), Value::BasicBlockVal), Parent(0),
43 IsLandingPad(false) {
43 : Value(Type::getLabelTy(C), Value::BasicBlockVal), Parent(0) {
4444
4545 // Make sure that we get added to a function
4646 LeakDetector::addGarbageObject(this);
5555
5656 setName(Name);
5757 }
58
5859
5960 BasicBlock::~BasicBlock() {
6061 // If the address of the block is taken and it is being deleted (e.g. because
+0
-29
test/Feature/bb_attrs.ll less more
None ; RUN: llvm-as < %s | llvm-dis > %t1.ll
1 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
2 ; RUN: diff %t1.ll %t2.ll
3
4 ; Test for basic block attributes.
5
6 define i32 @f1(i32 %a) {
7 entry:
8 %cmp = icmp slt i32 %a, 37
9 br i1 %cmp, label %bb, label %lpad
10
11 bb:
12 ret i32 37
13
14 lpad: landingpad
15 ret i32 927
16 }
17
18 define i32 @f2(i32 %a) {
19 ; entry : 0
20 %1 = icmp slt i32 %a, 37
21 br i1 %1, label %2, label %3
22
23 ; bb : 2
24 ret i32 37
25
26 landingpad ; bb : 3
27 ret i32 927
28 }