diff options
author | Dehao Chen <dehao@google.com> | 2015-10-30 02:38:29 +0000 |
---|---|---|
committer | Dehao Chen <dehao@google.com> | 2015-10-30 02:38:29 +0000 |
commit | 9a5d2b18e0ce6ec15daff77c6bc5a657fdd31aea (patch) | |
tree | b923e5e9b00fe5bf1f55a7f05371f88fc46addee /llvm/lib/Transforms/Utils/AddDiscriminators.cpp | |
parent | 0c774deb9c094f58d8b4b402b099c0b818f0f668 (diff) | |
download | bcm5719-llvm-9a5d2b18e0ce6ec15daff77c6bc5a657fdd31aea.tar.gz bcm5719-llvm-9a5d2b18e0ce6ec15daff77c6bc5a657fdd31aea.zip |
Update the discriminator assignment algorithm
* If a scope has already been assigned a discriminator, do not reassign a nested discriminator for it.
* If the file and line both match, even if the column does not match, we should assign a new discriminator for the stmt.
original code:
; #1 int foo(int i) {
; #2 if (i == 3 || i == 5) return 100; else return 99;
; #3 }
; i == 3: discriminator 0
; i == 5: discriminator 2
; return 100: discriminator 1
; return 99: discriminator 3
llvm-svn: 251680
Diffstat (limited to 'llvm/lib/Transforms/Utils/AddDiscriminators.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/AddDiscriminators.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/Utils/AddDiscriminators.cpp b/llvm/lib/Transforms/Utils/AddDiscriminators.cpp index 34c2f4525ea..1a101879d26 100644 --- a/llvm/lib/Transforms/Utils/AddDiscriminators.cpp +++ b/llvm/lib/Transforms/Utils/AddDiscriminators.cpp @@ -180,7 +180,7 @@ bool AddDiscriminators::runOnFunction(Function &F) { BasicBlock *Succ = Last->getSuccessor(I); Instruction *First = Succ->getFirstNonPHIOrDbgOrLifetime(); const DILocation *FirstDIL = First->getDebugLoc(); - if (!FirstDIL) + if (!FirstDIL || FirstDIL->getDiscriminator()) continue; // If the first instruction (First) of Succ is at the same file @@ -202,21 +202,22 @@ bool AddDiscriminators::runOnFunction(Function &F) { unsigned Discriminator = FirstDIL->computeNewDiscriminator(); auto *NewScope = Builder.createLexicalBlockFile(Scope, File, Discriminator); - auto *NewDIL = - DILocation::get(Ctx, FirstDIL->getLine(), FirstDIL->getColumn(), - NewScope, FirstDIL->getInlinedAt()); - DebugLoc newDebugLoc = NewDIL; // Attach this new debug location to First and every // instruction following First that shares the same location. for (BasicBlock::iterator I1(*First), E1 = Succ->end(); I1 != E1; ++I1) { - if (I1->getDebugLoc().get() != FirstDIL) - break; - I1->setDebugLoc(newDebugLoc); - DEBUG(dbgs() << NewDIL->getFilename() << ":" << NewDIL->getLine() - << ":" << NewDIL->getColumn() << ":" - << NewDIL->getDiscriminator() << *I1 << "\n"); + const DILocation *CurrentDIL = I1->getDebugLoc(); + if (CurrentDIL && CurrentDIL->getLine() == FirstDIL->getLine() && + CurrentDIL->getFilename() == FirstDIL->getFilename()) { + I1->setDebugLoc(DILocation::get(Ctx, CurrentDIL->getLine(), + CurrentDIL->getColumn(), NewScope, + CurrentDIL->getInlinedAt())); + DEBUG(dbgs() << CurrentDIL->getFilename() << ":" + << CurrentDIL->getLine() << ":" + << CurrentDIL->getColumn() << ":" + << CurrentDIL->getDiscriminator() << *I1 << "\n"); + } } DEBUG(dbgs() << "\n"); Changed = true; |