Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lld/wasm/Writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. I wonder if we can just add if (!file->isLive()) continue to the outer loop here. At least there are no failing tests when I do this locally.

It seem pretty odd to be including any custom sections form object files that are not live.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. I wonder if we can just add if (!file->isLive()) continue to the outer loop here.

LGTM, but it's not only calculateCustomSections that is used in this way, also populateProducers etc.. It might be necessary to determine whether it's a non-live object at an earlier stage and exit.

Anyway, I'm not really in favor of doing it in this PR (because the cov issue is clear, it should be given priority consideration), it might cause the problem to escalate.

// Otherwise include custom sections by default and concatenate their
// contents.
customSectionMapping[name].push_back(section);
Expand Down