Add special case bitcode support for DebugLoc. This avoids

having the bitcode writer materialize mdnodes for all the
debug location tuples when writing out the bc file and 
stores the information in a more compact form.  For example,
the -O0 -g bc file for combine.c in 176.gcc shrinks from
739392 to 512096 bytes.

This concludes my planned short-term debug info work.

llvm-svn: 100261
This commit is contained in:
Chris Lattner
2010-04-03 02:17:50 +00:00
parent 729bcaded9
commit 07d09ed49a
5 changed files with 91 additions and 13 deletions

View File

@@ -1644,6 +1644,8 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
BasicBlock *CurBB = 0;
unsigned CurBBNo = 0;
DebugLoc LastLoc;
// Read all the records.
SmallVector<uint64_t, 64> Record;
while (1) {
@@ -1699,6 +1701,46 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
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;
@@ -2285,8 +2327,6 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
// 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()) {