[llvm] Print source filename when invalid debug info is found in LTO. (PR #138201)

via llvm-commits llvm-commits at lists.llvm.org
Thu May 1 14:16:46 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lto

Author: Shubham Sandeep Rastogi (rastogishubham)

<details>
<summary>Changes</summary>

When invalid debug info is found in a module during LTO, the debug info from that module is stripped. However, we do not print the source filename, which makes it impossible to figure out where the invalid debug info is coming from.

This patch prints the source file name.

---
Full diff: https://github.com/llvm/llvm-project/pull/138201.diff


2 Files Affected:

- (modified) llvm/lib/LTO/LTOCodeGenerator.cpp (+1) 
- (modified) llvm/lib/LTO/ThinLTOCodeGenerator.cpp (+2) 


``````````diff
diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp
index 70b7135fcbef0..bd0dfed76e3d4 100644
--- a/llvm/lib/LTO/LTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -548,6 +548,7 @@ void LTOCodeGenerator::verifyMergedModuleOnce() {
     report_fatal_error("Broken module found, compilation aborted!");
   if (BrokenDebugInfo) {
     emitWarning("Invalid debug info found, debug info will be stripped");
+    emitWarning("Source FileName: " + MergedModule->getSourceFileName());
     StripDebugInfo(*MergedModule);
   }
 }
diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
index 42dba0abe245f..5c4883c8ddae9 100644
--- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
@@ -182,6 +182,8 @@ static void verifyLoadedModule(Module &TheModule) {
   if (BrokenDebugInfo) {
     TheModule.getContext().diagnose(ThinLTODiagnosticInfo(
         "Invalid debug info found, debug info will be stripped", DS_Warning));
+    TheModule.getContext().diagnose(ThinLTODiagnosticInfo(
+        "Source File Name: " + TheModule.getSourceFileName(), DS_Warning));
     StripDebugInfo(TheModule);
   }
 }

``````````

</details>


https://github.com/llvm/llvm-project/pull/138201


More information about the llvm-commits mailing list