From 939993ff2fe38eca498b0806b22a35412222a0eb Mon Sep 17 00:00:00 2001 From: Dehao Chen Date: Mon, 29 Feb 2016 18:59:48 +0000 Subject: Move discriminator assignment to the right place. Summary: Now discriminator is assigned per-function instead of per-module. Reviewers: davidxl, dnovillo Subscribers: dblaikie, llvm-commits Differential Revision: http://reviews.llvm.org/D17664 llvm-svn: 262240 --- llvm/lib/Transforms/Utils/AddDiscriminators.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/Utils/AddDiscriminators.cpp b/llvm/lib/Transforms/Utils/AddDiscriminators.cpp index 3e585c623dd..e0f58606d63 100644 --- a/llvm/lib/Transforms/Utils/AddDiscriminators.cpp +++ b/llvm/lib/Transforms/Utils/AddDiscriminators.cpp @@ -173,8 +173,10 @@ bool AddDiscriminators::runOnFunction(Function &F) { typedef std::pair Location; typedef DenseMap BBScopeMap; typedef DenseMap LocationBBMap; + typedef DenseMap LocationDiscriminatorMap; LocationBBMap LBM; + LocationDiscriminatorMap LDM; // Traverse all instructions in the function. If the source line location // of the instruction appears in other basic block, assign a new @@ -199,8 +201,7 @@ bool AddDiscriminators::runOnFunction(Function &F) { auto *Scope = DIL->getScope(); auto *File = Builder.createFile(DIL->getFilename(), Scope->getDirectory()); - NewScope = Builder.createLexicalBlockFile( - Scope, File, DIL->computeNewDiscriminator()); + NewScope = Builder.createLexicalBlockFile(Scope, File, ++LDM[L]); } I.setDebugLoc(DILocation::get(Ctx, DIL->getLine(), DIL->getColumn(), NewScope, DIL->getInlinedAt())); @@ -230,8 +231,10 @@ bool AddDiscriminators::runOnFunction(Function &F) { auto *Scope = FirstDIL->getScope(); auto *File = Builder.createFile(FirstDIL->getFilename(), Scope->getDirectory()); - auto *NewScope = Builder.createLexicalBlockFile( - Scope, File, FirstDIL->computeNewDiscriminator()); + Location L = + std::make_pair(FirstDIL->getFilename(), FirstDIL->getLine()); + auto *NewScope = + Builder.createLexicalBlockFile(Scope, File, ++LDM[L]); Current->setDebugLoc(DILocation::get( Ctx, CurrentDIL->getLine(), CurrentDIL->getColumn(), NewScope, CurrentDIL->getInlinedAt())); -- cgit v1.2.3