diff options
author | Dehao Chen <dehao@google.com> | 2015-11-09 17:30:38 +0000 |
---|---|---|
committer | Dehao Chen <dehao@google.com> | 2015-11-09 17:30:38 +0000 |
commit | 3656e3064b54f00ee884fc36120bcb25673233af (patch) | |
tree | 7247fea33ed1aa604085fead31ff58db349bb192 /llvm/lib/Transforms | |
parent | 19dc92dc8d5a7c041e6c3dc9e31e4518a70fcf3e (diff) | |
download | bcm5719-llvm-3656e3064b54f00ee884fc36120bcb25673233af.tar.gz bcm5719-llvm-3656e3064b54f00ee884fc36120bcb25673233af.zip |
Add discriminators for call instructions that are from the same line and same basic block.
Summary: Call instructions that are from the same line and same basic block needs to have separate discriminators to distinguish between different callsites.
Reviewers: davidxl, dnovillo, dblaikie
Subscribers: dblaikie, probinson, llvm-commits
Differential Revision: http://reviews.llvm.org/D14464
llvm-svn: 252492
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Utils/AddDiscriminators.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/AddDiscriminators.cpp b/llvm/lib/Transforms/Utils/AddDiscriminators.cpp index 1a101879d26..c8a8b6bd2c0 100644 --- a/llvm/lib/Transforms/Utils/AddDiscriminators.cpp +++ b/llvm/lib/Transforms/Utils/AddDiscriminators.cpp @@ -224,5 +224,37 @@ bool AddDiscriminators::runOnFunction(Function &F) { } } } + + // Traverse all instructions and assign new discriminators to call + // instructions with the same lineno that are in the same basic block. + // Sample base profile needs to distinguish different function calls within + // a same source line for correct profile annotation. + for (BasicBlock &B : F) { + const DILocation *FirstDIL = NULL; + for (auto &I : B.getInstList()) { + CallInst *Current = dyn_cast<CallInst>(&I); + if (Current) { + DILocation *CurrentDIL = Current->getDebugLoc(); + if (FirstDIL) { + if (CurrentDIL && CurrentDIL->getLine() == FirstDIL->getLine() && + CurrentDIL->getFilename() == FirstDIL->getFilename()) { + auto *Scope = FirstDIL->getScope(); + auto *File = Builder.createFile(FirstDIL->getFilename(), + Scope->getDirectory()); + auto *NewScope = Builder.createLexicalBlockFile( + Scope, File, FirstDIL->computeNewDiscriminator()); + Current->setDebugLoc(DILocation::get( + Ctx, CurrentDIL->getLine(), CurrentDIL->getColumn(), NewScope, + CurrentDIL->getInlinedAt())); + Changed = true; + } else { + FirstDIL = CurrentDIL; + } + } else { + FirstDIL = CurrentDIL; + } + } + } + } return Changed; } |