diff options
Diffstat (limited to 'src/ir')
-rw-r--r-- | src/ir/ExpressionAnalyzer.cpp | 80 | ||||
-rw-r--r-- | src/ir/ExpressionManipulator.cpp | 6 | ||||
-rw-r--r-- | src/ir/LocalGraph.cpp | 12 | ||||
-rw-r--r-- | src/ir/ReFinalize.cpp | 3 | ||||
-rw-r--r-- | src/ir/bits.h | 12 | ||||
-rw-r--r-- | src/ir/branch-utils.h | 41 | ||||
-rw-r--r-- | src/ir/cost.h | 9 | ||||
-rw-r--r-- | src/ir/effects.h | 60 | ||||
-rw-r--r-- | src/ir/equivalent_sets.h | 3 | ||||
-rw-r--r-- | src/ir/function-utils.h | 15 | ||||
-rw-r--r-- | src/ir/global-utils.h | 3 | ||||
-rw-r--r-- | src/ir/hashed.h | 3 | ||||
-rw-r--r-- | src/ir/load-utils.h | 3 | ||||
-rw-r--r-- | src/ir/memory-utils.h | 21 | ||||
-rw-r--r-- | src/ir/type-updating.h | 9 | ||||
-rw-r--r-- | src/ir/utils.h | 9 |
16 files changed, 192 insertions, 97 deletions
diff --git a/src/ir/ExpressionAnalyzer.cpp b/src/ir/ExpressionAnalyzer.cpp index aaab9050c..de37cd08b 100644 --- a/src/ir/ExpressionAnalyzer.cpp +++ b/src/ir/ExpressionAnalyzer.cpp @@ -35,22 +35,26 @@ bool ExpressionAnalyzer::isResultUsed(ExpressionStack& stack, Function* func) { if (curr->is<Block>()) { auto* block = curr->cast<Block>(); for (size_t j = 0; j < block->list.size() - 1; j++) { - if (block->list[j] == above) + if (block->list[j] == above) { return false; + } } assert(block->list.back() == above); // continue down } else if (curr->is<If>()) { auto* iff = curr->cast<If>(); - if (above == iff->condition) + if (above == iff->condition) { return true; - if (!iff->ifFalse) + } + if (!iff->ifFalse) { return false; + } assert(above == iff->ifTrue || above == iff->ifFalse); // continue down } else { - if (curr->is<Drop>()) + if (curr->is<Drop>()) { return false; + } return true; // all other node types use the result } } @@ -66,23 +70,27 @@ bool ExpressionAnalyzer::isResultDropped(ExpressionStack& stack) { if (curr->is<Block>()) { auto* block = curr->cast<Block>(); for (size_t j = 0; j < block->list.size() - 1; j++) { - if (block->list[j] == above) + if (block->list[j] == above) { return false; + } } assert(block->list.back() == above); // continue down } else if (curr->is<If>()) { auto* iff = curr->cast<If>(); - if (above == iff->condition) + if (above == iff->condition) { return false; - if (!iff->ifFalse) + } + if (!iff->ifFalse) { return false; + } assert(above == iff->ifTrue || above == iff->ifFalse); // continue down } else { - if (curr->is<Drop>()) + if (curr->is<Drop>()) { return true; // dropped - return false; // all other node types use the result + } + return false; // all other node types use the result } } return false; @@ -238,8 +246,9 @@ bool ExpressionAnalyzer::flexibleEqual(Expression* left, // Comparison is by value, except for names, which must match. bool operator==(const Immediates& other) { - if (scopeNames.size() != other.scopeNames.size()) + if (scopeNames.size() != other.scopeNames.size()) { return false; + } for (Index i = 0; i < scopeNames.size(); i++) { auto leftName = scopeNames[i]; auto rightName = other.scopeNames[i]; @@ -254,18 +263,24 @@ bool ExpressionAnalyzer::flexibleEqual(Expression* left, return false; } } - if (nonScopeNames != other.nonScopeNames) + if (nonScopeNames != other.nonScopeNames) { return false; - if (ints != other.ints) + } + if (ints != other.ints) { return false; - if (literals != other.literals) + } + if (literals != other.literals) { return false; - if (types != other.types) + } + if (types != other.types) { return false; - if (indexes != other.indexes) + } + if (indexes != other.indexes) { return false; - if (addresses != other.addresses) + } + if (addresses != other.addresses) { return false; + } return true; } @@ -283,8 +298,9 @@ bool ExpressionAnalyzer::flexibleEqual(Expression* left, }; bool noteNames(Name left, Name right) { - if (left.is() != right.is()) + if (left.is() != right.is()) { return false; + } if (left.is()) { assert(rightNames.find(left) == rightNames.end()); rightNames[left] = right; @@ -306,28 +322,35 @@ bool ExpressionAnalyzer::flexibleEqual(Expression* left, leftStack.pop_back(); right = rightStack.back(); rightStack.pop_back(); - if (!left != !right) + if (!left != !right) { return false; - if (!left) + } + if (!left) { continue; - if (comparer(left, right)) + } + if (comparer(left, right)) { continue; // comparison hook, before all the rest + } // continue with normal structural comparison - if (left->_id != right->_id) + if (left->_id != right->_id) { return false; + } // Blocks and loops introduce scoping. if (auto* block = left->dynCast<Block>()) { - if (!noteNames(block->name, right->cast<Block>()->name)) + if (!noteNames(block->name, right->cast<Block>()->name)) { return false; + } } else if (auto* loop = left->dynCast<Loop>()) { - if (!noteNames(loop->name, right->cast<Loop>()->name)) + if (!noteNames(loop->name, right->cast<Loop>()->name)) { return false; + } } else { // For all other nodes, compare their immediate values visitImmediates(left, leftImmediates); visitImmediates(right, rightImmediates); - if (leftImmediates != rightImmediates) + if (leftImmediates != rightImmediates) { return false; + } leftImmediates.clear(); rightImmediates.clear(); } @@ -343,11 +366,13 @@ bool ExpressionAnalyzer::flexibleEqual(Expression* left, } // The number of child nodes must match (e.g. return has an optional // one). - if (counter != 0) + if (counter != 0) { return false; + } } - if (leftStack.size() > 0 || rightStack.size() > 0) + if (leftStack.size() > 0 || rightStack.size() > 0) { return false; + } return true; } }; @@ -377,8 +402,9 @@ HashType ExpressionAnalyzer::hash(Expression* curr) { while (stack.size() > 0) { curr = stack.back(); stack.pop_back(); - if (!curr) + if (!curr) { continue; + } hash(curr->_id); // we often don't need to hash the type, as it is tied to other values // we are hashing anyhow, but there are exceptions: for example, a diff --git a/src/ir/ExpressionManipulator.cpp b/src/ir/ExpressionManipulator.cpp index 6d35ef97f..fcdfdf152 100644 --- a/src/ir/ExpressionManipulator.cpp +++ b/src/ir/ExpressionManipulator.cpp @@ -34,11 +34,13 @@ flexibleCopy(Expression* original, Module& wasm, CustomCopier custom) { : wasm(wasm), custom(custom), builder(wasm) {} Expression* copy(Expression* curr) { - if (!curr) + if (!curr) { return nullptr; + } auto* ret = custom(curr); - if (ret) + if (ret) { return ret; + } return Visitor<Copier, Expression*>::visit(curr); } diff --git a/src/ir/LocalGraph.cpp b/src/ir/LocalGraph.cpp index 1a2ccc0a2..a66009ec2 100644 --- a/src/ir/LocalGraph.cpp +++ b/src/ir/LocalGraph.cpp @@ -58,8 +58,9 @@ struct Flower : public CFGWalker<Flower, Visitor<Flower>, Info> { static void doVisitGetLocal(Flower* self, Expression** currp) { auto* curr = (*currp)->cast<GetLocal>(); // if in unreachable code, skip - if (!self->currBasicBlock) + if (!self->currBasicBlock) { return; + } self->currBasicBlock->contents.actions.emplace_back(curr); self->locations[curr] = currp; } @@ -67,8 +68,9 @@ struct Flower : public CFGWalker<Flower, Visitor<Flower>, Info> { static void doVisitSetLocal(Flower* self, Expression** currp) { auto* curr = (*currp)->cast<SetLocal>(); // if in unreachable code, skip - if (!self->currBasicBlock) + if (!self->currBasicBlock) { return; + } self->currBasicBlock->contents.actions.emplace_back(curr); self->currBasicBlock->contents.lastSets[curr->index] = curr; self->locations[curr] = currp; @@ -119,8 +121,9 @@ struct Flower : public CFGWalker<Flower, Visitor<Flower>, Info> { auto& block = basicBlocks[i]; auto& flowBlock = flowBlocks[i]; // Get the equivalent block to entry in the flow list - if (block.get() == entry) + if (block.get() == entry) { entryFlowBlock = &flowBlock; + } flowBlock.lastTraversedIteration = NULL_ITERATION; flowBlock.actions.swap(block->contents.actions); // Map in block to flow blocks @@ -171,8 +174,9 @@ struct Flower : public CFGWalker<Flower, Visitor<Flower>, Info> { // can do that for all gets as a whole, they will get the same results. for (Index index = 0; index < numLocals; index++) { auto& gets = allGets[index]; - if (gets.empty()) + if (gets.empty()) { continue; + } work.push_back(&block); // Note that we may need to revisit the later parts of this initial // block, if we are in a loop, so don't mark it as seen. diff --git a/src/ir/ReFinalize.cpp b/src/ir/ReFinalize.cpp index 2bf68970d..ca058e2be 100644 --- a/src/ir/ReFinalize.cpp +++ b/src/ir/ReFinalize.cpp @@ -91,8 +91,9 @@ void ReFinalize::visitBlock(Block* curr) { return; } } - if (curr->type == unreachable) + if (curr->type == unreachable) { return; + } // type is none, but we might be unreachable if (curr->type == none) { for (auto* child : curr->list) { diff --git a/src/ir/bits.h b/src/ir/bits.h index a2b8fcde4..faae4c723 100644 --- a/src/ir/bits.h +++ b/src/ir/bits.h @@ -27,8 +27,9 @@ struct Bits { // get a mask to keep only the low # of bits static int32_t lowBitMask(int32_t bits) { uint32_t ret = -1; - if (bits >= 32) + if (bits >= 32) { return ret; + } return ret >> (32 - bits); } @@ -36,14 +37,17 @@ struct Bits { // bit, and all zeros from there. returns the number of masked bits, or 0 if // this is not such a mask static uint32_t getMaskedBits(uint32_t mask) { - if (mask == uint32_t(-1)) + if (mask == uint32_t(-1)) { return 32; // all the bits - if (mask == 0) + } + if (mask == 0) { return 0; // trivially not a mask + } // otherwise, see if adding one turns this into a 1-bit thing, 00011111 + 1 // => 00100000 - if (PopCount(mask + 1) != 1) + if (PopCount(mask + 1) != 1) { return 0; + } // this is indeed a mask return 32 - CountLeadingZeroes(mask); } diff --git a/src/ir/branch-utils.h b/src/ir/branch-utils.h index f62941e15..ce7d7b0f6 100644 --- a/src/ir/branch-utils.h +++ b/src/ir/branch-utils.h @@ -155,47 +155,57 @@ struct BranchSeeker : public PostWalker<BranchSeeker> { void noteFound(Expression* value) { found++; - if (found == 1) + if (found == 1) { valueType = unreachable; - if (!value) + } + if (!value) { valueType = none; - else if (value->type != unreachable) + } else if (value->type != unreachable) { valueType = value->type; + } } void visitBreak(Break* curr) { if (!named) { // ignore an unreachable break - if (curr->condition && curr->condition->type == unreachable) + if (curr->condition && curr->condition->type == unreachable) { return; - if (curr->value && curr->value->type == unreachable) + } + if (curr->value && curr->value->type == unreachable) { return; + } } // check the break - if (curr->name == target) + if (curr->name == target) { noteFound(curr->value); + } } void visitSwitch(Switch* curr) { if (!named) { // ignore an unreachable switch - if (curr->condition->type == unreachable) + if (curr->condition->type == unreachable) { return; - if (curr->value && curr->value->type == unreachable) + } + if (curr->value && curr->value->type == unreachable) { return; + } } // check the switch for (auto name : curr->targets) { - if (name == target) + if (name == target) { noteFound(curr->value); + } } - if (curr->default_ == target) + if (curr->default_ == target) { noteFound(curr->value); + } } static bool hasReachable(Expression* tree, Name target) { - if (!target.is()) + if (!target.is()) { return false; + } BranchSeeker seeker(target); seeker.named = false; seeker.walk(tree); @@ -203,8 +213,9 @@ struct BranchSeeker : public PostWalker<BranchSeeker> { } static Index countReachable(Expression* tree, Name target) { - if (!target.is()) + if (!target.is()) { return 0; + } BranchSeeker seeker(target); seeker.named = false; seeker.walk(tree); @@ -212,16 +223,18 @@ struct BranchSeeker : public PostWalker<BranchSeeker> { } static bool hasNamed(Expression* tree, Name target) { - if (!target.is()) + if (!target.is()) { return false; + } BranchSeeker seeker(target); seeker.walk(tree); return seeker.found > 0; } static Index countNamed(Expression* tree, Name target) { - if (!target.is()) + if (!target.is()) { return 0; + } BranchSeeker seeker(target); seeker.walk(tree); return seeker.found; diff --git a/src/ir/cost.h b/src/ir/cost.h index 95c2178d9..5e09ee90e 100644 --- a/src/ir/cost.h +++ b/src/ir/cost.h @@ -33,8 +33,9 @@ struct CostAnalyzer : public Visitor<CostAnalyzer, Index> { Index visitBlock(Block* curr) { Index ret = 0; - for (auto* child : curr->list) + for (auto* child : curr->list) { ret += visit(child); + } return ret; } Index visitIf(If* curr) { @@ -52,14 +53,16 @@ struct CostAnalyzer : public Visitor<CostAnalyzer, Index> { // XXX this does not take into account if the call is to an import, which // may be costlier in general Index ret = 4; - for (auto* child : curr->operands) + for (auto* child : curr->operands) { ret += visit(child); + } return ret; } Index visitCallIndirect(CallIndirect* curr) { Index ret = 6 + visit(curr->target); - for (auto* child : curr->operands) + for (auto* child : curr->operands) { ret += visit(child); + } return ret; } Index visitGetLocal(GetLocal* curr) { return 0; } diff --git a/src/ir/effects.h b/src/ir/effects.h index 9a3f29d8a..bbcce07de 100644 --- a/src/ir/effects.h +++ b/src/ir/effects.h @@ -30,8 +30,9 @@ struct EffectAnalyzer EffectAnalyzer(PassOptions& passOptions, Expression* ast = nullptr) { ignoreImplicitTraps = passOptions.ignoreImplicitTraps; debugInfo = passOptions.debugInfo; - if (ast) + if (ast) { analyze(ast); + } } bool ignoreImplicitTraps; @@ -41,8 +42,9 @@ struct EffectAnalyzer breakNames.clear(); walk(ast); // if we are left with breaks, they are external - if (breakNames.size() > 0) + if (breakNames.size() > 0) { branches = true; + } } // Core effect tracking @@ -115,8 +117,9 @@ struct EffectAnalyzer } } for (auto local : localsRead) { - if (other.localsWritten.count(local)) + if (other.localsWritten.count(local)) { return true; + } } if ((accessesGlobal() && other.calls) || (other.accessesGlobal() && calls)) { @@ -129,8 +132,9 @@ struct EffectAnalyzer } } for (auto global : globalsRead) { - if (other.globalsWritten.count(global)) + if (other.globalsWritten.count(global)) { return true; + } } // we are ok to reorder implicit traps, but not conditionalize them if ((implicitTrap && other.branches) || (other.implicitTrap && branches)) { @@ -151,14 +155,18 @@ struct EffectAnalyzer writesMemory = writesMemory || other.writesMemory; implicitTrap = implicitTrap || other.implicitTrap; isAtomic = isAtomic || other.isAtomic; - for (auto i : other.localsRead) + for (auto i : other.localsRead) { localsRead.insert(i); - for (auto i : other.localsWritten) + } + for (auto i : other.localsWritten) { localsWritten.insert(i); - for (auto i : other.globalsRead) + } + for (auto i : other.globalsRead) { globalsRead.insert(i); - for (auto i : other.globalsWritten) + } + for (auto i : other.globalsWritten) { globalsWritten.insert(i); + } } // the checks above happen after the node's children were processed, in the @@ -183,13 +191,15 @@ struct EffectAnalyzer std::set<Name> breakNames; void visitBlock(Block* curr) { - if (curr->name.is()) + if (curr->name.is()) { breakNames.erase(curr->name); // these were internal breaks + } } void visitIf(If* curr) {} void visitLoop(Loop* curr) { - if (curr->name.is()) + if (curr->name.is()) { breakNames.erase(curr->name); // these were internal breaks + } // if the loop is unreachable, then there is branching control flow: // (1) if the body is unreachable because of a (return), uncaught (br) // etc., then we already noted branching, so it is ok to mark it again @@ -228,28 +238,32 @@ struct EffectAnalyzer void visitLoad(Load* curr) { readsMemory = true; isAtomic |= curr->isAtomic; - if (!ignoreImplicitTraps) + if (!ignoreImplicitTraps) { implicitTrap = true; + } } void visitStore(Store* curr) { writesMemory = true; isAtomic |= curr->isAtomic; - if (!ignoreImplicitTraps) + if (!ignoreImplicitTraps) { implicitTrap = true; + } } void visitAtomicRMW(AtomicRMW* curr) { readsMemory = true; writesMemory = true; isAtomic = true; - if (!ignoreImplicitTraps) + if (!ignoreImplicitTraps) { implicitTrap = true; + } } void visitAtomicCmpxchg(AtomicCmpxchg* curr) { readsMemory = true; writesMemory = true; isAtomic = true; - if (!ignoreImplicitTraps) + if (!ignoreImplicitTraps) { implicitTrap = true; + } } void visitAtomicWait(AtomicWait* curr) { readsMemory = true; @@ -258,8 +272,9 @@ struct EffectAnalyzer // write. writesMemory = true; isAtomic = true; - if (!ignoreImplicitTraps) + if (!ignoreImplicitTraps) { implicitTrap = true; + } } void visitAtomicNotify(AtomicNotify* curr) { // AtomicNotify doesn't strictly write memory, but it does modify the @@ -268,8 +283,9 @@ struct EffectAnalyzer readsMemory = true; writesMemory = true; isAtomic = true; - if (!ignoreImplicitTraps) + if (!ignoreImplicitTraps) { implicitTrap = true; + } }; void visitSIMDExtract(SIMDExtract* curr) {} void visitSIMDReplace(SIMDReplace* curr) {} @@ -278,25 +294,29 @@ struct EffectAnalyzer void visitSIMDShift(SIMDShift* curr) {} void visitMemoryInit(MemoryInit* curr) { writesMemory = true; - if (!ignoreImplicitTraps) + if (!ignoreImplicitTraps) { implicitTrap = true; + } } void visitDataDrop(DataDrop* curr) { // prevent reordering with memory.init readsMemory = true; - if (!ignoreImplicitTraps) + if (!ignoreImplicitTraps) { implicitTrap = true; + } } void visitMemoryCopy(MemoryCopy* curr) { readsMemory = true; writesMemory = true; - if (!ignoreImplicitTraps) + if (!ignoreImplicitTraps) { implicitTrap = true; + } } void visitMemoryFill(MemoryFill* curr) { writesMemory = true; - if (!ignoreImplicitTraps) + if (!ignoreImplicitTraps) { implicitTrap = true; + } } void visitConst(Const* curr) {} void visitUnary(Unary* curr) { diff --git a/src/ir/equivalent_sets.h b/src/ir/equivalent_sets.h index fc4b1db3d..657ff9894 100644 --- a/src/ir/equivalent_sets.h +++ b/src/ir/equivalent_sets.h @@ -67,8 +67,9 @@ struct EquivalentSets { // Checks whether two indexes contain the same data. bool check(Index a, Index b) { - if (a == b) + if (a == b) { return true; + } if (auto* set = getEquivalents(a)) { if (set->find(b) != set->end()) { return true; diff --git a/src/ir/function-utils.h b/src/ir/function-utils.h index 446bcc8bb..61af153a0 100644 --- a/src/ir/function-utils.h +++ b/src/ir/function-utils.h @@ -28,18 +28,23 @@ namespace FunctionUtils { // everything but their name (which can't be the same, in the same // module!) - same params, vars, body, result, etc. inline bool equal(Function* left, Function* right) { - if (left->getNumParams() != right->getNumParams()) + if (left->getNumParams() != right->getNumParams()) { return false; - if (left->getNumVars() != right->getNumVars()) + } + if (left->getNumVars() != right->getNumVars()) { return false; + } for (Index i = 0; i < left->getNumLocals(); i++) { - if (left->getLocalType(i) != right->getLocalType(i)) + if (left->getLocalType(i) != right->getLocalType(i)) { return false; + } } - if (left->result != right->result) + if (left->result != right->result) { return false; - if (left->type != right->type) + } + if (left->type != right->type) { return false; + } if (!left->imported() && !right->imported()) { return ExpressionAnalyzer::equal(left->body, right->body); } diff --git a/src/ir/global-utils.h b/src/ir/global-utils.h index b32605805..113a37f31 100644 --- a/src/ir/global-utils.h +++ b/src/ir/global-utils.h @@ -38,8 +38,9 @@ getGlobalInitializedToImport(Module& wasm, Name module, Name base) { imported = import->name; } }); - if (imported.isNull()) + if (imported.isNull()) { return nullptr; + } // find a global inited to it Global* ret = nullptr; ModuleUtils::iterDefinedGlobals(wasm, [&](Global* defined) { diff --git a/src/ir/hashed.h b/src/ir/hashed.h index 676b82cb4..a3d285cf5 100644 --- a/src/ir/hashed.h +++ b/src/ir/hashed.h @@ -44,8 +44,9 @@ struct ExpressionHasher { struct ExpressionComparer { bool operator()(const HashedExpression a, const HashedExpression b) const { - if (a.hash != b.hash) + if (a.hash != b.hash) { return false; + } return ExpressionAnalyzer::equal(a.expr, b.expr); } }; diff --git a/src/ir/load-utils.h b/src/ir/load-utils.h index 36e94d0af..c7e9bad99 100644 --- a/src/ir/load-utils.h +++ b/src/ir/load-utils.h @@ -28,8 +28,9 @@ namespace LoadUtils { // fill in bits either signed or unsigned wise) inline bool isSignRelevant(Load* load) { auto type = load->type; - if (load->type == unreachable) + if (load->type == unreachable) { return false; + } return !isFloatType(type) && load->bytes < getTypeSize(type); } diff --git a/src/ir/memory-utils.h b/src/ir/memory-utils.h index c1edc8ce9..fd4b865f4 100644 --- a/src/ir/memory-utils.h +++ b/src/ir/memory-utils.h @@ -29,16 +29,18 @@ namespace wasm { namespace MemoryUtils { // flattens memory into a single data segment. returns true if successful inline bool flatten(Memory& memory) { - if (memory.segments.size() == 0) + if (memory.segments.size() == 0) { return true; + } std::vector<char> data; for (auto& segment : memory.segments) { if (segment.isPassive) { return false; } auto* offset = segment.offset->dynCast<Const>(); - if (!offset) + if (!offset) { return false; + } } for (auto& segment : memory.segments) { auto* offset = segment.offset->dynCast<Const>(); @@ -121,10 +123,12 @@ inline bool ensureLimitedSegments(Module& module) { // drop empty segments and pass through dynamic-offset segments for (auto& segment : memory.segments) { - if (isEmpty(segment)) + if (isEmpty(segment)) { continue; - if (isConstantOffset(segment)) + } + if (isConstantOffset(segment)) { continue; + } mergedSegments.push_back(segment); } @@ -135,8 +139,9 @@ inline bool ensureLimitedSegments(Module& module) { }; for (Index i = 0; i < memory.segments.size(); i++) { auto& segment = memory.segments[i]; - if (!isRelevant(segment)) + if (!isRelevant(segment)) { continue; + } if (mergedSegments.size() + 2 < WebLimitations::MaxDataSegments) { mergedSegments.push_back(segment); continue; @@ -146,8 +151,9 @@ inline bool ensureLimitedSegments(Module& module) { auto start = segment.offset->cast<Const>()->value.getInteger(); for (Index j = i + 1; j < memory.segments.size(); j++) { auto& segment = memory.segments[j]; - if (!isRelevant(segment)) + if (!isRelevant(segment)) { continue; + } auto offset = segment.offset->cast<Const>()->value.getInteger(); start = std::min(start, offset); } @@ -159,8 +165,9 @@ inline bool ensureLimitedSegments(Module& module) { Memory::Segment combined(c); for (Index j = i; j < memory.segments.size(); j++) { auto& segment = memory.segments[j]; - if (!isRelevant(segment)) + if (!isRelevant(segment)) { continue; + } auto offset = segment.offset->cast<Const>()->value.getInteger(); auto needed = offset + segment.data.size() - start; if (combined.data.size() < needed) { diff --git a/src/ir/type-updating.h b/src/ir/type-updating.h index e387483ee..ef9fe78e9 100644 --- a/src/ir/type-updating.h +++ b/src/ir/type-updating.h @@ -194,8 +194,9 @@ struct TypeUpdater // alters the type of a node to a new type. // this propagates the type change through all the parents. void changeTypeTo(Expression* curr, Type newType) { - if (curr->type == newType) + if (curr->type == newType) { return; // nothing to do + } curr->type = newType; propagateTypesUp(curr); } @@ -208,13 +209,15 @@ struct TypeUpdater // the one thing we need to do here is propagate unreachability, // no other change is possible void propagateTypesUp(Expression* curr) { - if (curr->type != unreachable) + if (curr->type != unreachable) { return; + } while (1) { auto* child = curr; curr = parents[child]; - if (!curr) + if (!curr) { return; + } // get ready to apply unreachability to this node if (curr->type == unreachable) { return; // already unreachable, stop here diff --git a/src/ir/utils.h b/src/ir/utils.h index 9be8947a1..4e941b8d0 100644 --- a/src/ir/utils.h +++ b/src/ir/utils.h @@ -248,8 +248,9 @@ struct AutoDrop : public WalkerPass<ExpressionStackWalker<AutoDrop>> { void reFinalize() { ReFinalizeNode::updateStack(expressionStack); } void visitBlock(Block* curr) { - if (curr->list.size() == 0) + if (curr->list.size() == 0) { return; + } for (Index i = 0; i < curr->list.size() - 1; i++) { auto* child = curr->list[i]; if (isConcreteType(child->type)) { @@ -264,11 +265,13 @@ struct AutoDrop : public WalkerPass<ExpressionStackWalker<AutoDrop>> { void visitIf(If* curr) { bool acted = false; - if (maybeDrop(curr->ifTrue)) + if (maybeDrop(curr->ifTrue)) { acted = true; + } if (curr->ifFalse) { - if (maybeDrop(curr->ifFalse)) + if (maybeDrop(curr->ifFalse)) { acted = true; + } } if (acted) { reFinalize(); |