Skip to content

Commit

Permalink
Fixes "within-file" scoping for Policy files.
Browse files Browse the repository at this point in the history
When multiple files are links with llvm-link calls to
getSourceFilename() return "llvm-link" as the source. This change
properly uses the debug info to the original source filename.
  • Loading branch information
bkidney committed Mar 3, 2019
1 parent 587ce43 commit e235fe8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/PolicyFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "NVSerializer.hh"
#include "Strings.hh"

#include <llvm/IR/DebugInfoMetadata.h>
#include <llvm/IR/Function.h>
#include <llvm/IR/Module.h>
#include <llvm/Support/CommandLine.h>
Expand Down Expand Up @@ -382,7 +383,11 @@ Policy::Directions PolicyFile::CallHooks(const llvm::Function &Fn) const {
Policy::Directions PolicyFile::FnHooks(const llvm::Function &Fn) const {
StringRef Name = Fn.getName();

std::string FileName = Fn.getParent()->getSourceFileName();
std::string FileName = "";
DISubprogram* Sp = Fn.getSubprogram();
if (Sp) {
FileName = Sp->getFilename();
}
std::string BaseFileName = FileName.substr(FileName.find_last_of("/\\") + 1);

for (FnInstrumentation &F : Policy->Functions) {
Expand Down

0 comments on commit e235fe8

Please sign in to comment.