[llvm-bugs] [Bug 32771] Stack get and set use wrong global id

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Nov 13 15:15:20 PST 2017


https://bugs.llvm.org/show_bug.cgi?id=32771

Dan Gohman <dan433584 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #3 from Dan Gohman <dan433584 at gmail.com> ---
This is now fixed; running llc on the input file produces a wasm module that
imports the stack pointer as global 0, but even with a testcase that imports it
as a non-zero index, stack pointer references now use the correct index.

For example, this C code:

extern int xyz;
extern int uvw;

int* return_xyz(void) { return &xyz; }
int* return_uvw(void) { return &uvw; }
void callee(int*);
void qux(void) { int i; callee(&i); }

compiled to a .o file which wasm2wat translates to this:

(module
  (type (;0;) (func (result i32)))
  (type (;1;) (func))
  (type (;2;) (func (param i32)))
  (import "env" "xyz" (global (;0;) i32))
  (import "env" "uvw" (global (;1;) i32))
  (import "env" "__stack_pointer" (global (;2;) i32))
  (import "env" "callee" (func $callee (type 2)))
  (func $return_xyz (type 0) (result i32)
    i32.const -1)
  (func $return_uvw (type 0) (result i32)
    i32.const -1)
  (func $qux (type 1)
    (local i32)
    get_global 2
    i32.const 16
    i32.sub
    tee_local 0
    set_global 2
    get_local 0
    i32.const 12
    i32.add
    call $callee
    get_local 0
    i32.const 16
    i32.add
    set_global 2)
  (table (;0;) 0 anyfunc)
  (memory (;0;) 0)
  (export "return_xyz" (func $return_xyz))
  (export "return_uvw" (func $return_uvw))
  (export "qux" (func $qux)))

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171113/85d340ed/attachment.html>


More information about the llvm-bugs mailing list