diff options
| author | Justin Bogner <mail@justinbogner.com> | 2017-02-18 02:00:27 +0000 |
|---|---|---|
| committer | Justin Bogner <mail@justinbogner.com> | 2017-02-18 02:00:27 +0000 |
| commit | 7bc978b54372d141d8361888c59800445412874f (patch) | |
| tree | 5676c73cf42082eb7f8334afc3739c8a70e7e466 /llvm/lib/IR | |
| parent | c4ebb6402a35f3741292d2e5e0115d820c546247 (diff) | |
| download | bcm5719-llvm-7bc978b54372d141d8361888c59800445412874f.tar.gz bcm5719-llvm-7bc978b54372d141d8361888c59800445412874f.zip | |
OptDiag: Allow constructing DiagnosticLocation from DISubprograms
This avoids creating a DILocation just to represent a line number,
since creating Metadata is expensive. Creating a DiagnosticLocation
directly is much cheaper.
llvm-svn: 295531
Diffstat (limited to 'llvm/lib/IR')
| -rw-r--r-- | llvm/lib/IR/DiagnosticInfo.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/IR/DiagnosticInfo.cpp b/llvm/lib/IR/DiagnosticInfo.cpp index 9526614796e..2af2ab9d7a9 100644 --- a/llvm/lib/IR/DiagnosticInfo.cpp +++ b/llvm/lib/IR/DiagnosticInfo.cpp @@ -156,6 +156,14 @@ DiagnosticLocation::DiagnosticLocation(const DebugLoc &DL) { Column = DL->getColumn(); } +DiagnosticLocation::DiagnosticLocation(const DISubprogram *SP) { + if (!SP) + return; + Filename = SP->getFilename(); + Line = SP->getScopeLine(); + Column = 0; +} + void DiagnosticInfoWithLocationBase::getLocation(StringRef *Filename, unsigned *Line, unsigned *Column) const { @@ -177,7 +185,7 @@ DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, const Value *V : Key(Key) { if (auto *F = dyn_cast<Function>(V)) { if (DISubprogram *SP = F->getSubprogram()) - Loc = DebugLoc::get(SP->getScopeLine(), 0, SP); + Loc = SP; } else if (auto *I = dyn_cast<Instruction>(V)) Loc = I->getDebugLoc(); |

