Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion src/cfg/cfg-traversal.h
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,9 @@ struct CFGWalker : public PostWalker<SubType, VisitorType> {
auto handlerBlocks = BranchUtils::getUniqueTargets(*currp);
// Add branches to the targets.
for (auto target : handlerBlocks) {
self->branches[target].push_back(self->currBasicBlock);
if (target) {
self->branches[target].push_back(self->currBasicBlock);
}
}
}

Expand Down
19 changes: 18 additions & 1 deletion src/passes/DeadArgumentElimination2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include "ir/type-updating.h"
#include "pass.h"
#include "support/index.h"
#include "support/mixed_arena.h"
#include "support/utilities.h"
#include "wasm-builder.h"
#include "wasm-traversal.h"
Expand Down Expand Up @@ -354,9 +355,25 @@ struct GraphBuilder : public WalkerPass<ExpressionStackWalker<GraphBuilder>> {
}
}

void visitResume(Resume* curr) { noteContinuation(curr->cont->type); }
void visitResumeHandlers(const ArenaVector<Name>& labels) {
for (Index i = 0; i < labels.size(); ++i) {
if (labels[i]) {
auto* target = findBreakTarget(labels[i]);
assert(target->type.size() >= 1);
auto newContType = target->type[target->type.size() - 1];
assert(newContType.isContinuation());
noteContinuation(newContType);
}
}
}

void visitResume(Resume* curr) {
noteContinuation(curr->cont->type);
visitResumeHandlers(curr->handlerBlocks);
}
void visitResumeThrow(ResumeThrow* curr) {
noteContinuation(curr->cont->type);
visitResumeHandlers(curr->handlerBlocks);
}
void visitStackSwitch(StackSwitch* curr) {
noteContinuation(curr->cont->type);
Expand Down
6 changes: 6 additions & 0 deletions src/wasm/wasm-ir-builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1974,6 +1974,9 @@ Result<> IRBuilder::makeRefTest(Type type) {
}

Result<> IRBuilder::makeRefCast(Type type, bool isDesc) {
if (!type.isCastable()) {
return Err{"ref.cast cannot cast to invalid type"};
}
std::optional<HeapType> descriptor;
if (isDesc) {
assert(type.isRef());
Expand Down Expand Up @@ -2027,6 +2030,9 @@ Result<> IRBuilder::makeBrOn(Index label,
curr.op = op;
curr.castType = out;
curr.desc = nullptr;
if (op != BrOnNull && op != BrOnNonNull && !out.isCastable()) {
return Err{"br_on cannot cast to invalid type"};
}
CHECK_ERR(visitBrOn(&curr));

// Validate type immediates before we forget them.
Expand Down
Loading
Loading