[llvm-branch-commits] [llvm-branch] r100440 - in /llvm/branches/Apple/Morbo: ./ include/llvm/Bitcode/LLVMBitCodes.h lib/Bitcode/Reader/BitcodeReader.cpp lib/Bitcode/Writer/BitcodeWriter.cpp lib/Bitcode/Writer/ValueEnumerator.cpp lib/Transforms/IPO/FunctionAttrs.cpp tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
Devang Patel
dpatel at apple.com
Mon Apr 5 11:09:47 PDT 2010
Author: dpatel
Date: Mon Apr 5 13:09:46 2010
New Revision: 100440
URL: http://llvm.org/viewvc/llvm-project?rev=100440&view=rev
Log:
merge Chris's metadata improvements from mainline.
r100257,100261
Modified:
llvm/branches/Apple/Morbo/ (props changed)
llvm/branches/Apple/Morbo/include/llvm/Bitcode/LLVMBitCodes.h
llvm/branches/Apple/Morbo/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/branches/Apple/Morbo/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/branches/Apple/Morbo/lib/Bitcode/Writer/ValueEnumerator.cpp
llvm/branches/Apple/Morbo/lib/Transforms/IPO/FunctionAttrs.cpp (props changed)
llvm/branches/Apple/Morbo/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
Propchange: llvm/branches/Apple/Morbo/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Apr 5 13:09:46 2010
@@ -1,2 +1,2 @@
/llvm/branches/Apple/Hermes:96832,96835,96858,96870,96876,96879
-/llvm/trunk:98602,98604,98612,98615-98616,98675,98686,98743-98744,98773,98778,98780,98810,98835,98839,98845,98855,98862,98881,98920,98977,99032-99033,99043,99196,99223,99263,99282-99284,99306,99319-99321,99324,99336,99378,99418,99423,99429,99455,99463,99465,99469,99484,99490,99492-99494,99507,99524,99537,99539-99540,99544,99570,99575,99598,99620,99629-99630,99636,99671,99692,99695,99697,99699,99722,99816,99836,99845-99846,99848,99850,99855,99879,99899,99910,99916,99952-99954,99957,99959,99974-99975,99982,99984-99986,99988,99992-99993,99995,99997-99999,100016,100035,100038,100042,100044,100072,100074,100081-100090,100092,100094-100095,100116,100134,100209,100214-100218,100220-100221,100223-100225
+/llvm/trunk:98602,98604,98612,98615-98616,98675,98686,98743-98744,98773,98778,98780,98810,98835,98839,98845,98855,98862,98881,98920,98977,99032-99033,99043,99196,99223,99263,99282-99284,99306,99319-99321,99324,99336,99378,99418,99423,99429,99455,99463,99465,99469,99484,99490,99492-99494,99507,99524,99537,99539-99540,99544,99570,99575,99598,99620,99629-99630,99636,99671,99692,99695,99697,99699,99722,99816,99836,99845-99846,99848,99850,99855,99879,99899,99910,99916,99952-99954,99957,99959,99974-99975,99982,99984-99986,99988,99992-99993,99995,99997-99999,100016,100035,100038,100042,100044,100072,100074,100081-100090,100092,100094-100095,100116,100134,100209,100214-100218,100220-100221,100223-100225,100257,100261
Modified: llvm/branches/Apple/Morbo/include/llvm/Bitcode/LLVMBitCodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/include/llvm/Bitcode/LLVMBitCodes.h?rev=100440&r1=100439&r2=100440&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/include/llvm/Bitcode/LLVMBitCodes.h (original)
+++ llvm/branches/Apple/Morbo/include/llvm/Bitcode/LLVMBitCodes.h Mon Apr 5 13:09:46 2010
@@ -240,7 +240,10 @@
// new select on i1 or [N x i1]
FUNC_CODE_INST_VSELECT = 29, // VSELECT: [ty,opval,opval,predty,pred]
FUNC_CODE_INST_INBOUNDS_GEP= 30, // INBOUNDS_GEP: [n x operands]
- FUNC_CODE_INST_INDIRECTBR = 31 // INDIRECTBR: [opty, op0, op1, ...]
+ FUNC_CODE_INST_INDIRECTBR = 31, // INDIRECTBR: [opty, op0, op1, ...]
+
+ FUNC_CODE_DEBUG_LOC = 32, // DEBUG_LOC: [Line,Col,ScopeVal, IAVal]
+ FUNC_CODE_DEBUG_LOC_AGAIN = 33 // DEBUG_LOC_AGAIN
};
} // End bitc namespace
} // End llvm namespace
Modified: llvm/branches/Apple/Morbo/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/Bitcode/Reader/BitcodeReader.cpp?rev=100440&r1=100439&r2=100440&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/Bitcode/Reader/BitcodeReader.cpp Mon Apr 5 13:09:46 2010
@@ -1638,6 +1638,8 @@
BasicBlock *CurBB = 0;
unsigned CurBBNo = 0;
+ DebugLoc LastLoc;
+
// Read all the records.
SmallVector<uint64_t, 64> Record;
while (1) {
@@ -1693,6 +1695,46 @@
CurBB = FunctionBBs[0];
continue;
+
+ case bitc::FUNC_CODE_DEBUG_LOC_AGAIN: // DEBUG_LOC_AGAIN
+ // This record indicates that the last instruction is at the same
+ // location as the previous instruction with a location.
+ I = 0;
+
+ // Get the last instruction emitted.
+ if (CurBB && !CurBB->empty())
+ I = &CurBB->back();
+ else if (CurBBNo && FunctionBBs[CurBBNo-1] &&
+ !FunctionBBs[CurBBNo-1]->empty())
+ I = &FunctionBBs[CurBBNo-1]->back();
+
+ if (I == 0) return Error("Invalid DEBUG_LOC_AGAIN record");
+ I->setDebugLoc(LastLoc);
+ I = 0;
+ continue;
+
+ case bitc::FUNC_CODE_DEBUG_LOC: { // DEBUG_LOC: [line, col, scope, ia]
+ I = 0; // Get the last instruction emitted.
+ if (CurBB && !CurBB->empty())
+ I = &CurBB->back();
+ else if (CurBBNo && FunctionBBs[CurBBNo-1] &&
+ !FunctionBBs[CurBBNo-1]->empty())
+ I = &FunctionBBs[CurBBNo-1]->back();
+ if (I == 0 || Record.size() < 4)
+ return Error("Invalid FUNC_CODE_DEBUG_LOC record");
+
+ unsigned Line = Record[0], Col = Record[1];
+ unsigned ScopeID = Record[2], IAID = Record[3];
+
+ MDNode *Scope = 0, *IA = 0;
+ if (ScopeID) Scope = cast<MDNode>(MDValueList.getValueFwdRef(ScopeID-1));
+ if (IAID) IA = cast<MDNode>(MDValueList.getValueFwdRef(IAID-1));
+ LastLoc = DebugLoc::get(Line, Col, Scope, IA);
+ I->setDebugLoc(LastLoc);
+ I = 0;
+ continue;
+ }
+
case bitc::FUNC_CODE_INST_BINOP: { // BINOP: [opval, ty, opval, opcode]
unsigned OpNum = 0;
Value *LHS, *RHS;
@@ -2279,8 +2321,6 @@
// See if anything took the address of blocks in this function. If so,
// resolve them now.
- /// BlockAddrFwdRefs - These are blockaddr references to basic blocks. These
- /// are resolved lazily when functions are loaded.
DenseMap<Function*, std::vector<BlockAddrRefTy> >::iterator BAFRI =
BlockAddrFwdRefs.find(F);
if (BAFRI != BlockAddrFwdRefs.end()) {
Modified: llvm/branches/Apple/Morbo/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=100440&r1=100439&r2=100440&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/Bitcode/Writer/BitcodeWriter.cpp Mon Apr 5 13:09:46 2010
@@ -596,7 +596,8 @@
static void WriteMetadataAttachment(const Function &F,
const ValueEnumerator &VE,
BitstreamWriter &Stream) {
- bool StartedMetadataBlock = false;
+ Stream.EnterSubblock(bitc::METADATA_ATTACHMENT_ID, 3);
+
SmallVector<uint64_t, 64> Record;
// Write metadata attachments
@@ -607,7 +608,7 @@
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end();
I != E; ++I) {
MDs.clear();
- I->getAllMetadata(MDs);
+ I->getAllMetadataOtherThanDebugLoc(MDs);
// If no metadata, ignore instruction.
if (MDs.empty()) continue;
@@ -618,16 +619,11 @@
Record.push_back(MDs[i].first);
Record.push_back(VE.getValueID(MDs[i].second));
}
- if (!StartedMetadataBlock) {
- Stream.EnterSubblock(bitc::METADATA_ATTACHMENT_ID, 3);
- StartedMetadataBlock = true;
- }
Stream.EmitRecord(bitc::METADATA_ATTACHMENT, Record, 0);
Record.clear();
}
- if (StartedMetadataBlock)
- Stream.ExitBlock();
+ Stream.ExitBlock();
}
static void WriteModuleMetadataStore(const Module *M, BitstreamWriter &Stream) {
@@ -1242,19 +1238,49 @@
// Keep a running idea of what the instruction ID is.
unsigned InstID = CstEnd;
+ bool NeedsMetadataAttachment = false;
+
+ DebugLoc LastDL;
+
// Finally, emit all the instructions, in order.
for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end();
I != E; ++I) {
WriteInstruction(*I, InstID, VE, Stream, Vals);
+
if (!I->getType()->isVoidTy())
++InstID;
+
+ // If the instruction has metadata, write a metadata attachment later.
+ NeedsMetadataAttachment |= I->hasMetadataOtherThanDebugLoc();
+
+ // If the instruction has a debug location, emit it.
+ DebugLoc DL = I->getDebugLoc();
+ if (DL.isUnknown()) {
+ // nothing todo.
+ } else if (DL == LastDL) {
+ // Just repeat the same debug loc as last time.
+ Stream.EmitRecord(bitc::FUNC_CODE_DEBUG_LOC_AGAIN, Vals);
+ } else {
+ MDNode *Scope, *IA;
+ DL.getScopeAndInlinedAt(Scope, IA, I->getContext());
+
+ Vals.push_back(DL.getLine());
+ Vals.push_back(DL.getCol());
+ Vals.push_back(Scope ? VE.getValueID(Scope)+1 : 0);
+ Vals.push_back(IA ? VE.getValueID(IA)+1 : 0);
+ Stream.EmitRecord(bitc::FUNC_CODE_DEBUG_LOC, Vals);
+ Vals.clear();
+
+ LastDL = DL;
+ }
}
// Emit names for all the instructions etc.
WriteValueSymbolTable(F.getValueSymbolTable(), VE, Stream);
- WriteMetadataAttachment(F, VE, Stream);
+ if (NeedsMetadataAttachment)
+ WriteMetadataAttachment(F, VE, Stream);
VE.purgeFunction();
Stream.ExitBlock();
}
Modified: llvm/branches/Apple/Morbo/lib/Bitcode/Writer/ValueEnumerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/Bitcode/Writer/ValueEnumerator.cpp?rev=100440&r1=100439&r2=100440&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/Bitcode/Writer/ValueEnumerator.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/Bitcode/Writer/ValueEnumerator.cpp Mon Apr 5 13:09:46 2010
@@ -104,9 +104,16 @@
// Enumerate metadata attached with this instruction.
MDs.clear();
- I->getAllMetadata(MDs);
+ I->getAllMetadataOtherThanDebugLoc(MDs);
for (unsigned i = 0, e = MDs.size(); i != e; ++i)
EnumerateMetadata(MDs[i].second);
+
+ if (!I->getDebugLoc().isUnknown()) {
+ MDNode *Scope, *IA;
+ I->getDebugLoc().getScopeAndInlinedAt(Scope, IA, I->getContext());
+ if (Scope) EnumerateMetadata(Scope);
+ if (IA) EnumerateMetadata(IA);
+ }
}
}
Propchange: llvm/branches/Apple/Morbo/lib/Transforms/IPO/FunctionAttrs.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Apr 5 13:09:46 2010
@@ -1 +1 @@
-/llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp:99196,99492,99507,99524,99539-99540,99636,99699,99816,99836,99845-99846,99848,99850,99855,99879,99899,99910,99916,99952-99954,99957,99959,99974-99975,99982,99984-99986,99988,99992-99993,99995,99997-99999,100016,100035,100038,100042,100044,100072,100074,100081-100090,100092,100094-100095,100116,100132-100134,100137,100170,100208-100209,100214-100218,100220-100221,100223-100225
+/llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp:99196,99492,99507,99524,99539-99540,99636,99699,99816,99836,99845-99846,99848,99850,99855,99879,99899,99910,99916,99952-99954,99957,99959,99974-99975,99982,99984-99986,99988,99992-99993,99995,99997-99999,100016,100035,100038,100042,100044,100072,100074,100081-100090,100092,100094-100095,100116,100132-100134,100137,100170,100208-100209,100214-100218,100220-100221,100223-100225,100257,100261
Modified: llvm/branches/Apple/Morbo/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp?rev=100440&r1=100439&r2=100440&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp (original)
+++ llvm/branches/Apple/Morbo/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp Mon Apr 5 13:09:46 2010
@@ -237,6 +237,8 @@
case bitc::FUNC_CODE_INST_INSERTVAL: return "INST_INSERTVAL";
case bitc::FUNC_CODE_INST_CMP2: return "INST_CMP2";
case bitc::FUNC_CODE_INST_VSELECT: return "INST_VSELECT";
+ case bitc::FUNC_CODE_DEBUG_LOC: return "DEBUG_LOC";
+ case bitc::FUNC_CODE_DEBUG_LOC_AGAIN: return "DEBUG_LOC_AGAIN";
}
case bitc::TYPE_SYMTAB_BLOCK_ID:
switch (CodeID) {
@@ -259,9 +261,11 @@
default:return 0;
case bitc::METADATA_STRING: return "MDSTRING";
case bitc::METADATA_NODE: return "MDNODE";
+ case bitc::METADATA_FN_NODE: return "FN_MDNODE";
case bitc::METADATA_NAME: return "METADATA_NAME";
case bitc::METADATA_NAMED_NODE: return "NAMEDMDNODE";
case bitc::METADATA_KIND: return "METADATA_KIND";
+ case bitc::METADATA_ATTACHMENT: return "METADATA_ATTACHMENT";
}
}
}
More information about the llvm-branch-commits
mailing list