<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><span class="vcard"><a class="email" href="mailto:dan433584@gmail.com" title="Dan Gohman <dan433584@gmail.com>"> <span class="fn">Dan Gohman</span></a>
</span> changed
          <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - Stack get and set use wrong global id"
   href="https://bugs.llvm.org/show_bug.cgi?id=32771">bug 32771</a>
          <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>---
           </td>
           <td>FIXED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>NEW
           </td>
           <td>RESOLVED
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - Stack get and set use wrong global id"
   href="https://bugs.llvm.org/show_bug.cgi?id=32771#c3">Comment # 3</a>
              on <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - Stack get and set use wrong global id"
   href="https://bugs.llvm.org/show_bug.cgi?id=32771">bug 32771</a>
              from <span class="vcard"><a class="email" href="mailto:dan433584@gmail.com" title="Dan Gohman <dan433584@gmail.com>"> <span class="fn">Dan Gohman</span></a>
</span></b>
        <pre>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)))</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>