[llvm] fix(gcov): write current_working_directory to .gcno file (PR #121369)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 30 20:09:03 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: PikachuHy (PikachuHyA)
<details>
<summary>Changes</summary>
fix https://github.com/llvm/llvm-project/issues/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
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/121369
More information about the llvm-commits
mailing list