Gracefully skipping noaccess constant loads.

This commit is contained in:
Ben Vanik 2015-06-06 22:56:53 -07:00
parent 6f4049ac0f
commit 6edf4f898f

View file

@ -188,18 +188,19 @@ bool ConstantPropagationPass::Run(HIRBuilder* builder) {
auto heap = memory->LookupHeap(address); auto heap = memory->LookupHeap(address);
uint32_t protect; uint32_t protect;
if (heap->QueryProtect(address, &protect) && if (heap->QueryProtect(address, &protect) &&
!(protect & kMemoryProtectWrite)) { !(protect & kMemoryProtectWrite) &&
(protect & kMemoryProtectRead)) {
// Memory is readonly - can just return the value. // Memory is readonly - can just return the value.
switch (v->type) { switch (v->type) {
case INT32_TYPE: case INT32_TYPE:
v->set_constant(xe::load_and_swap<uint32_t>( v->set_constant(xe::load_and_swap<uint32_t>(
memory->TranslateVirtual(address))); memory->TranslateVirtual(address)));
i->Remove();
break; break;
default: default:
assert_unhandled_case(v->type); assert_unhandled_case(v->type);
break; break;
} }
i->Remove();
} }
} }
} }