[lld] [Coverage][WebAssembly] Remove InstrProf sections if object not live (PR #172023)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 12 20:01:03 PST 2025
https://github.com/Spxg updated https://github.com/llvm/llvm-project/pull/172023
>From cba9c10a4d79ba6abf07523c43691c8871a7cb7d Mon Sep 17 00:00:00 2001
From: Spxg <unsafe at outlook.es>
Date: Sat, 13 Dec 2025 10:39:01 +0800
Subject: [PATCH] [Coverage][WebAssembly] Discard InstrProf sections if object
not live
---
lld/wasm/Writer.cpp | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp
index 9a5b56fc52e2f..c229917a1ecb5 100644
--- a/lld/wasm/Writer.cpp
+++ b/lld/wasm/Writer.cpp
@@ -26,6 +26,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/BinaryFormat/Wasm.h"
+#include "llvm/ProfileData/InstrProf.h"
#include "llvm/Support/FileOutputBuffer.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/Parallel.h"
@@ -153,6 +154,12 @@ void Writer::calculateCustomSections() {
// Strip debug section in that option was specified.
if (stripDebug && name.starts_with(".debug_"))
continue;
+ // If the object is not live, discard `__llvm_covfun` and `__llvm_covmap`
+ // sections since `__llvm_prf_*` segments have already been discarded.
+ if (!file->isLive() &&
+ (name == getInstrProfSectionName(IPSK_covfun, Triple::Wasm) ||
+ name == getInstrProfSectionName(IPSK_covmap, Triple::Wasm)))
+ continue;
// Otherwise include custom sections by default and concatenate their
// contents.
customSectionMapping[name].push_back(section);
More information about the llvm-commits
mailing list