From db2ae40be2c52c0821da355285384aa0db8fc948 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 1 Jun 2016 12:33:55 -0700 Subject: if we use the zero-init value of a local, we cannot coalesce it with a param (#556) --- src/passes/CoalesceLocals.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/passes/CoalesceLocals.cpp') diff --git a/src/passes/CoalesceLocals.cpp b/src/passes/CoalesceLocals.cpp index 39c480107..c36371ec0 100644 --- a/src/passes/CoalesceLocals.cpp +++ b/src/passes/CoalesceLocals.cpp @@ -183,7 +183,7 @@ struct CoalesceLocals : public WalkerPass> hasher; std::cout << getFunction()->name << ": interference hash: " << hasher(*(std::vector*)&interferences) << "\n"; @@ -347,9 +345,17 @@ void CoalesceLocals::calculateInterferences() { } } } + // Params have a value on entry, so mark them as live, as variables + // live at the entry expect their zero-init value. + LocalSet start = entry->contents.start; + auto numParams = getFunction()->getNumParams(); + for (Index i = 0; i < numParams; i++) { + start.insert(i); + } + calculateInterferences(start); } -void CoalesceLocals::calculateInterferences(LocalSet& locals) { +void CoalesceLocals::calculateInterferences(const LocalSet& locals) { size_t size = locals.size(); for (size_t i = 0; i < size; i++) { for (size_t j = i + 1; j < size; j++) { -- cgit v1.2.3