commit 50d68fc44948ab3b25a7af2f5fc9918110b1939a Author: goodtaeeun Date: 2024-02-13 15:24:01 +0900 [DAFL] extract file name from function diff --git a/llvm_mode/afl-llvm-pass.so.cc b/llvm_mode/afl-llvm-pass.so.cc index af989c2037b2..ecc017e9f3e0 100644 --- a/llvm_mode/afl-llvm-pass.so.cc +++ b/llvm_mode/afl-llvm-pass.so.cc @@ -162,12 +162,21 @@ bool AFLCoverage::runOnModule(Module &M) { std::string file_name = M.getSourceFileName(); std::set covered_targets; - std::size_t tokloc = file_name.find_last_of('/'); - if (tokloc != std::string::npos) { - file_name = file_name.substr(tokloc + 1, std::string::npos); - } + for (auto &F : M) { + + // Get file name from function in case the module is a combined bc file. + if (auto *SP = F.getSubprogram()) { + file_name = SP->getFilename().str(); + } + + // Keep only the file name. + std::size_t tokloc = file_name.find_last_of('/'); + if (tokloc != std::string::npos) { + file_name = file_name.substr(tokloc + 1, std::string::npos); + } + bool is_inst_targ = false; const std::string func_name = F.getName().str(); std::set::iterator it;