Skip to content

Wrong code with spill-pointers #5455

@merlinsun

Description

@merlinsun

Hi,
wasm-opt seems to produce wrong code for the following program with --spill-pointers pass.

$ emcc -W small.c -o small.js; node small.js
5
$ wasm-opt small.wasm --spill-pointers -o small.wasm; node small.js
0
$ cat small.c
#include "stdio.h"

int a = 5;
int main() { printf("%d\n", a); }

Version:

$ emcc -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.30 (cfe2bdfe2692457cb5f5770672f6e5ccb3ffc2f2)
clang version 16.0.0 (https://github.com/llvm/llvm-project 800f0f1546b2352ba42a4777149afb13cb874fcd)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /home/emsdk/upstream/bin
$ wasm-opt --version
wasm-opt version 111 (version_111-98-ga803a0830)

OS: Ubuntu 22.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions