From fd15ea4e8cdadcaadebbf9be1e4c4f554e7a678d Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 22 Sep 2020 17:00:48 -0700 Subject: Remove unused stack-pointer and emscripten-sbrk-ptr pass args from PostEmscripten (#3161) These were removed completely from the emscripten side in #12057 --- src/passes/PostEmscripten.cpp | 52 ------------------------------------------- 1 file changed, 52 deletions(-) (limited to 'src/passes/PostEmscripten.cpp') diff --git a/src/passes/PostEmscripten.cpp b/src/passes/PostEmscripten.cpp index aa6c90977..0c7521afc 100644 --- a/src/passes/PostEmscripten.cpp +++ b/src/passes/PostEmscripten.cpp @@ -78,58 +78,6 @@ struct OptimizeCalls : public WalkerPass> { struct PostEmscripten : public Pass { void run(PassRunner* runner, Module* module) override { - // Apply the stack pointer, if it was provided. This is needed here - // because the emscripten JS compiler can add static data allocations that - // come before the stack. - auto stackPtrStr = - runner->options.getArgumentOrDefault("stack-pointer", ""); - if (stackPtrStr != "") { - Global* stackPointer = getStackPointerGlobal(*module); - BYN_TRACE("stack_pointer: " << stackPtrStr << "\n"); - if (stackPointer && !stackPointer->imported()) { - auto stackPtr = std::stoi(stackPtrStr); - auto oldValue = stackPointer->init->cast()->value; - BYN_TRACE("updating __stack_pointer: " << oldValue.geti32() << " -> " - << stackPtr << "\n"); - stackPointer->init = Builder(*module).makeConst(int32_t(stackPtr)); - } - } - - // Apply the sbrk ptr, if it was provided. - auto sbrkPtrStr = - runner->options.getArgumentOrDefault("emscripten-sbrk-ptr", ""); - if (sbrkPtrStr != "") { - auto sbrkPtr = std::stoi(sbrkPtrStr); - ImportInfo imports(*module); - auto* func = imports.getImportedFunction(ENV, "emscripten_get_sbrk_ptr"); - if (func) { - Builder builder(*module); - func->body = builder.makeConst(int32_t(sbrkPtr)); - func->module = func->base = Name(); - } - // Apply the sbrk ptr value, if it was provided. This lets emscripten set - // up sbrk entirely in wasm, without depending on the JS side to init - // anything; this is necessary for standalone wasm mode, in which we do - // not have any JS. Otherwise, the JS would set this value during - // startup. - auto sbrkValStr = - runner->options.getArgumentOrDefault("emscripten-sbrk-val", ""); - if (sbrkValStr != "") { - uint32_t sbrkVal = std::stoi(sbrkValStr); - auto end = sbrkPtr + sizeof(sbrkVal); - // Flatten memory to make it simple to write to. Later passes can - // re-optimize it. - MemoryUtils::ensureExists(module->memory); - if (!MemoryUtils::flatten(module->memory, end, module)) { - Fatal() << "cannot apply sbrk-val since memory is not flattenable\n"; - } - auto& segment = module->memory.segments[0]; - assert(segment.offset->cast()->value.geti32() == 0); - assert(end <= segment.data.size()); - memcpy(segment.data.data() + sbrkPtr, &sbrkVal, sizeof(sbrkVal)); - } - } - // Optimize imports optimizeImports(runner, module); -- cgit v1.2.3