55 std::string srcName = Module.getSourceFileName();
56 std::string absPath = std::filesystem::absolute(srcName).string();
58 std::hash<std::string> hash_fn;
59 size_t hash_value = hash_fn(absPath);
60 std::string stable_hash = std::to_string(hash_value);
100 if (
auto* compile_unit = Module.getNamedMetadata(
"llvm.dbg.cu")) {
101 if (
auto* Node = compile_unit->getOperand(0)) {
102 if (
auto* CUNode = llvm::dyn_cast<llvm::DICompileUnit>(Node)) {
103 unsigned lang = CUNode->getSourceLanguage();
105 case llvm::dwarf::DW_LANG_C:
106 case llvm::dwarf::DW_LANG_C89:
107 case llvm::dwarf::DW_LANG_C99:
108 case llvm::dwarf::DW_LANG_C11: {
109 return llvm::dwarf::DW_LANG_C;
111 case llvm::dwarf::DW_LANG_C_plus_plus:
112 case llvm::dwarf::DW_LANG_C_plus_plus_03:
113 case llvm::dwarf::DW_LANG_C_plus_plus_11:
114 case llvm::dwarf::DW_LANG_C_plus_plus_14: {
115 return llvm::dwarf::DW_LANG_C_plus_plus;
124 return llvm::dwarf::DW_LANG_C_plus_plus;
143 llvm::DebugLoc dbg = inst.getDebugLoc();
144 if (!dbg || dbg->getLine() == 0) {
151 const llvm::DILocation* loc = dbg.get();
155 const llvm::DIFile* file = loc->getFile();
159 llvm::StringRef directory = file->getDirectory();
160 llvm::StringRef filename_ref = file->getFilename();
161 std::filesystem::path filepath;
162 if (!directory.empty()) {
163 filepath = std::filesystem::path(directory.str()) / filename_ref.str();
165 filepath = std::filesystem::path(filename_ref.str());
170 std::string filename = std::filesystem::absolute(filepath).lexically_normal().string();
173 size_t line = loc->getLine();
174 size_t col = loc->getColumn();
177 std::string subprogram_name;
178 const auto* LS = llvm::dyn_cast<llvm::DILocalScope>(loc->getScope());
180 const llvm::DISubprogram* SP = LS->getSubprogram();
182 if (!SP->getName().empty()) {
184 std::string name = SP->getLinkageName().str();
186 name = SP->getName().str();
188 size_t pos = name.find(
".extracted");
189 if (pos != std::string::npos) {
190 name = name.substr(0, pos);
197 return sdfg::DebugInfo(filename, subprogram_name, line, col, line, col);
248 std::vector<std::string> Flags;
250 if (
auto* CMD = M.getNamedMetadata(
"llvm.commandline")) {
251 for (llvm::MDNode* Op : CMD->operands()) {
252 auto* S = llvm::dyn_cast<llvm::MDString>(Op->getOperand(0));
255 std::string cmd = S->getString().str();
256 std::stringstream ss(cmd);
258 while (std::getline(ss, part,
' ')) {
259 Flags.emplace_back(part);