Skip to content

Conversation

@PikachuHyA
Copy link
Contributor

fix #121368

@llvmbot
Copy link
Member

llvmbot commented Dec 31, 2024

@llvm/pr-subscribers-llvm-transforms

Author: PikachuHy (PikachuHyA)

Changes

fix #121368


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

1 Files Affected:

  • (modified) llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp (+7-2)
diff --git a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
index f9be7f933d31e4..fe476038498194 100644
--- a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -973,8 +973,13 @@ bool GCOVProfiler::emitProfileNotes(
         out.write(Tmp, 4);
       }
       write(Stamp);
-      if (Version >= 90)
-        writeString(""); // unuseful current_working_directory
+      if (Version >= 90) {
+        SmallString<256> CWD;
+        llvm::sys::fs::current_path(CWD);
+        // the current_working_directory is used by gcov
+        // if the source file is relative path
+        writeString(CWD);
+      }
       if (Version >= 80)
         write(0); // unuseful has_unexecuted_blocks
 

@PikachuHyA PikachuHyA closed this Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[gcov] source file location error due to miss current_working_directory in gcno file

2 participants