Skip to content

[WebAssembly] Fix feature coalescing #110647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 15, 2024
Merged
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
12 changes: 4 additions & 8 deletions llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ class CoalesceFeaturesAndStripAtomics final : public ModulePass {
bool runOnModule(Module &M) override {
FeatureBitset Features = coalesceFeatures(M);

std::string FeatureStr =
getFeatureString(Features, WasmTM->getTargetFeatureString());
std::string FeatureStr = getFeatureString(Features);
WasmTM->setTargetFeatureString(FeatureStr);
for (auto &F : M)
replaceFeatures(F, FeatureStr);
Expand Down Expand Up @@ -241,17 +240,14 @@ class CoalesceFeaturesAndStripAtomics final : public ModulePass {
return Features;
}

static std::string getFeatureString(const FeatureBitset &Features,
StringRef TargetFS) {
static std::string getFeatureString(const FeatureBitset &Features) {
std::string Ret;
for (const SubtargetFeatureKV &KV : WebAssemblyFeatureKV) {
if (Features[KV.Value])
Ret += (StringRef("+") + KV.Key + ",").str();
else
Ret += (StringRef("-") + KV.Key + ",").str();
}
SubtargetFeatures TF{TargetFS};
for (std::string const &F : TF.getFeatures())
if (!SubtargetFeatures::isEnabled(F))
Ret += F + ",";
return Ret;
}

Expand Down
Loading