<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Please see my previous email re: rematerialization.  This code
      appears correct and as expected.<br>
    </p>
    <p>Philip<br>
    </p>
    <div class="moz-cite-prefix">On 7/20/21 11:22 AM, Kavindu Gimhan
      Zoysa wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CALoJghUzjbM8CCdAgX2C4E1eksoZVTzxody7Bomi2OcdmW8=cg@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">Hi Philip,
        <div><br>
        </div>
        <div>It is the same output I got that make sense. But as
          explained in this example <a
            href="https://llvm.org/docs/Statepoints.html#base-derived-pointers"
            moz-do-not-send="true">https://llvm.org/docs/Statepoints.html#base-derived-pointers</a>
          (the example available in this section), I thought <b>%gep </b>should
          be included in gc-live operand bundle. Isn't that correct? </div>
        <div><br clear="all">
          <div>
            <div dir="ltr" class="gmail_signature"
              data-smartmail="gmail_signature">
              <div dir="ltr">
                <div dir="ltr">
                  <div dir="ltr">
                    <div dir="ltr">
                      <div>Kavindu Gimhan Zoysa,</div>
                      <div>BSc(Hons) | ENTC | UoM,<br>
                      </div>
                      <div dir="ltr">ATL | WSO2
                        <div><br>
                        </div>
                        <div><a href="https://github.com/KavinduZoysa"
                            target="_blank" moz-do-not-send="true">GitHub</a> <a
href="https://www.linkedin.com/in/kavindu-gimhan-zoysa-85939a122/"
                            target="_blank" moz-do-not-send="true">LinkedIn</a> <a
href="https://medium.com/@kavindugimhanzoysa" target="_blank"
                            moz-do-not-send="true">Medium</a></div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <br>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Tue, 20 Jul 2021 at 22:53,
          Philip Reames <<a href="mailto:listmail@philipreames.com"
            moz-do-not-send="true">listmail@philipreames.com</a>>
          wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px
          0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div>
            <p>$ ./opt -S llvm-dev.ll -rewrite-statepoints-for-gc<br>
              ; ModuleID = 'llvm-dev.ll'<br>
              source_filename = "llvm-dev.ll"<br>
              <br>
              define void @dummy_func() {<br>
                ret void<br>
              }<br>
              <br>
              define i8 addrspace(1)* @test1(i8 addrspace(1)* %obj) gc
              "statepoint-example" {<br>
                %gep = getelementptr i8, i8 addrspace(1)* %obj, i64
              20000<br>
                %statepoint_token = call token (i64, i32, void ()*, i32,
              i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64
              2882400000, i32 0, void ()* @dummy_func, i32 0, i32 0, i32
              0, i32 0) [ "gc-live"(i8 addrspace(1)* %obj) ]<br>
                <b>%obj.relocated = call coldcc i8 addrspace(1)*
                @llvm.experimental.gc.relocate.p1i8(token
                %statepoint_token, i32 0, i32 0) ; (%obj, %obj)</b><br>
                <b>%gep.remat = getelementptr i8, i8 addrspace(1)*
                %obj.relocated, i64 20000</b><br>
                %p = getelementptr i8, i8 addrspace(1)* %gep.remat, i64
              -20000<br>
                store i8 2, i8 addrspace(1)* %gep.remat, align 1<br>
                ret i8 addrspace(1)* %p<br>
              }<br>
            </p>
            <p>Works for me.  This output is entirely correct as we
              relocated the base pointer and then rematerialized the
              derived pointer afterwards.  This is almost always
              profitable over directly relocating both obj and derived
              pointers.</p>
            <p>Philip<br>
            </p>
            <div>On 7/20/21 7:45 AM, Kavindu Gimhan Zoysa via llvm-dev
              wrote:<br>
            </div>
            <blockquote type="cite">
              <div><br>
              </div>
              <blockquote class="gmail_quote" style="margin:0px 0px 0px
                0.8ex;border-left:1px solid
                rgb(204,204,204);padding-left:1ex">define void
                @dummy_func() {<br>
                  ret void<br>
                }<br>
                define i8 addrspace(1)* @test1(i8 addrspace(1)* %obj) gc
                "statepoint-example" {<br>
                  %gep = getelementptr i8, i8 addrspace(1)* %obj, i64
                20000<br>
                  call void @dummy_func()<br>
                  %p = getelementptr i8, i8 addrspace(1)* %gep, i64
                -20000<br>
                  store i8 2, i8 addrspace(1)* %gep<br>
                  ret i8 addrspace(1)* %p<br>
                }</blockquote>
            </blockquote>
          </div>
        </blockquote>
      </div>
    </blockquote>
  </body>
</html>