mirror of https://github.com/inolen/redream.git
fix broken ContextPromotionPass, had accidentally used vector::resize instead of vector::reserve and fundamentally broke the pass
This commit is contained in:
parent
f2ea7c134f
commit
7ba4d9feb8
|
@ -385,8 +385,10 @@ const Xbyak::Operand &X64Emitter::CopyOperand(const Xbyak::Operand &from,
|
|||
LOG(FATAL) << "Unsupported copy";
|
||||
}
|
||||
} else if (to.isMEM() && from.isMEM()) {
|
||||
c_.mov(c_.r8, from);
|
||||
c_.mov(to, c_.r8);
|
||||
const Xbyak::Reg &tmp = GetTmpRegister(nullptr, from.getBit() >> 3);
|
||||
c_.mov(tmp, from);
|
||||
c_.mov(to, tmp);
|
||||
// FIXME could release tmp register now
|
||||
} else {
|
||||
c_.mov(to, from);
|
||||
}
|
||||
|
|
|
@ -8,11 +8,17 @@ using namespace dreavm::cpu::ir::passes;
|
|||
void ContextPromotionPass::Run(IRBuilder &builder) {
|
||||
PROFILER_SCOPE("runtime", "ContextPromotionPass::Run");
|
||||
|
||||
ResetState();
|
||||
|
||||
for (auto block : builder.blocks()) {
|
||||
ProcessBlock(block);
|
||||
}
|
||||
}
|
||||
|
||||
void ContextPromotionPass::ResetState() {
|
||||
ClearAvailable();
|
||||
}
|
||||
|
||||
void ContextPromotionPass::ProcessBlock(Block *block) {
|
||||
// eliminate redundant loads
|
||||
{
|
||||
|
@ -79,14 +85,30 @@ void ContextPromotionPass::ProcessBlock(Block *block) {
|
|||
}
|
||||
}
|
||||
|
||||
void ContextPromotionPass::ClearAvailable() { available_.clear(); }
|
||||
void ContextPromotionPass::ClearAvailable() {
|
||||
available_marker_++;
|
||||
}
|
||||
|
||||
void ContextPromotionPass::ReserveAvailable(int offset) {
|
||||
if (offset >= (int)available_.size()) {
|
||||
available_.resize(offset + 1);
|
||||
available_values_.resize(offset + 1);
|
||||
}
|
||||
}
|
||||
|
||||
Value *ContextPromotionPass::GetAvailable(int offset) {
|
||||
available_.resize(offset + 1);
|
||||
return available_.at(offset);
|
||||
ReserveAvailable(offset);
|
||||
|
||||
if (available_[offset] < available_marker_) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return available_values_[offset];
|
||||
}
|
||||
|
||||
void ContextPromotionPass::SetAvailable(int offset, Value *v) {
|
||||
available_.resize(offset + 1);
|
||||
available_.at(offset) = v;
|
||||
ReserveAvailable(offset);
|
||||
|
||||
available_[offset] = available_marker_;
|
||||
available_values_[offset] = v;
|
||||
}
|
||||
|
|
|
@ -14,13 +14,16 @@ class ContextPromotionPass : public Pass {
|
|||
void Run(IRBuilder &builder);
|
||||
|
||||
private:
|
||||
void ResetState();
|
||||
void ProcessBlock(Block *block);
|
||||
|
||||
void ClearAvailable();
|
||||
void ReserveAvailable(int offset);
|
||||
Value *GetAvailable(int offset);
|
||||
void SetAvailable(int offset, Value *v);
|
||||
|
||||
std::vector<Value *> available_;
|
||||
uint64_t available_marker_;
|
||||
std::vector<uint64_t> available_;
|
||||
std::vector<Value *> available_values_;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue