<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">Thanks for looking at this. Just so
      you're aware I see that @ychen has just posted some further
      comments on the review which I'll be addressing shortly.</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">The TargetPassConfig::insertPass
      (after) function would work in theory except that the
      TargetPassConfig objects only have transitory lifetimes within,
      e.g., LLVMTargetMachine::addPassesToEmitFile. I couldn't find any
      existing way to access the TargetPassConfig objects from
      out-of-tree code in order to manipulate them. The solution with
      TargetPassConfig::<span class="nf">addExtension</span><span
        class="p"> is to register callback(s) in a global which get
        passed the TargetPassConfig object during execution of
        TargetPassConfig::addMachinePasses.</span></div>
    <div class="moz-cite-prefix"><span class="p"><br>
      </span></div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">On 17/06/2021 00:31, Craig Topper
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAF7ks-OR+PWuhZOiHfmPXNpGspeoyG11eZALYiCJt__TuPEbRQ@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">I just got back from vacation so I haven't had much
        time to look at your patch yet. My first question is going to
        be, is this something that can already be done with the existing
        TargetPassConfig::insertPassAfter mechanism? I don't know the
        history of that mechanism just that it exists.
        <div><br>
        </div>
        <div>
          <div>
            <div dir="ltr" class="gmail_signature"
              data-smartmail="gmail_signature">~Craig</div>
          </div>
          <br>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Wed, Jun 16, 2021 at 12:59
          PM Raoul Gough <<a href="mailto:github.drti@gmail.com"
            moz-do-not-send="true">github.drti@gmail.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>
            <div>Hi Craig, I see you listed as the code owner for the
              x86 backend and I was wondering if you'd have time to
              comment on my review at <a
                href="https://reviews.llvm.org/D98591" target="_blank"
                moz-do-not-send="true">https://reviews.llvm.org/D98591</a>
              ? This adds an extension mechanism to <span>TargetPassConfig
                to allow out-of-tree code to provide machine passes for
                an existing target.<br>
              </span></div>
            <div><br>
            </div>
            <div>Arthur has raised the question of whether it's
              appropriate to have such an extension mechanism so it
              might help if I explain my motivating example. I'm working
              on a way to do runtime inlining of functions referenced
              via pointers, including C++ virtual function calls. This
              works using ahead-of-time compiled code that has been
              annotated to derive call-tree information at runtime and
              potentially recompile parts of the code using bitcode
              embedded as data in the executable. To build the call tree
              I install a context pointer in a callee-saved register at
              the relevant call sites and retrieve it at function entry,
              both of which I do via a machine pass that runs just
              before the register allocator. There are actually several
              other complications but that's the starting point for
              wanting to inject a custom machine pass for an existing
              target. What do you think?</div>
            <div><br>
            </div>
            <div>There are some more details on my github page <a
                href="https://github.com/drti/drti" target="_blank"
                moz-do-not-send="true">https://github.com/drti/drti</a>
              if you're interested.<br>
            </div>
            <div><br>
            </div>
            <div>Regards,</div>
            <div>Raoul.<br>
            </div>
            <div><br>
            </div>
            <div>On 15/06/2021 23:22, Arthur Eubanks wrote:<br>
            </div>
            <blockquote type="cite">
              <div dir="ltr">I'm not super familiar with the codegen
                pipeline, perhaps some backend people can take a look?
                <div><br>
                </div>
                <div>A question is, do we want extensions like in the
                  middle-end optimization pipeline? I don't see why not,
                  this mirrors the existing extensions for the
                  optimization pipeline. But it'd be good to get some
                  more opinions from people more knowledgeable.</div>
              </div>
              <br>
              <div class="gmail_quote">
                <div dir="ltr" class="gmail_attr">On Mon, Jun 14, 2021
                  at 8:04 AM David Blaikie <<a
                    href="mailto:dblaikie@gmail.com" target="_blank"
                    moz-do-not-send="true">dblaikie@gmail.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 dir="ltr">Arthur - any idea who might be good to
                    review this?</div>
                  <br>
                  <div class="gmail_quote">
                    <div dir="ltr" class="gmail_attr">On Mon, Jun 7,
                      2021 at 6:20 AM Raoul Gough via llvm-dev <<a
                        href="mailto:llvm-dev@lists.llvm.org"
                        target="_blank" moz-do-not-send="true">llvm-dev@lists.llvm.org</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">Hello llvm-dev,
                      I have a code contribution for the legacy pass
                      manager <br>
                      and I'm having trouble finding anyone to finish
                      reviewing it. I've made <br>
                      some improvements based on earlier feedback from
                      @ychen on Phabricator <br>
                      but since then nobody has given final approval.
                      Can anyone help with <br>
                      this or point me in the right direction?<br>
                      <br>
                      I couldn't see anyone listed in the
                      CODE_OWNERS.txt for this area of the <br>
                      code base. From what I understand the new pass
                      manager still doesn't <br>
                      handle the target-specific code, so I think the
                      code is in the right <br>
                      place for now at least. I'd be happy to move it to
                      the new pass manager <br>
                      if that's currently possible, of course.<br>
                      <br>
                      This is related to my (out of tree) runtime
                      inlining project and adds <br>
                      minimal support for target-level extensions in a
                      similar way to <br>
                      addGlobalExtension in the legacy IR
                      PassManagerBuilder... <br>
                      <a href="https://reviews.llvm.org/D98591"
                        rel="noreferrer" target="_blank"
                        moz-do-not-send="true">https://reviews.llvm.org/D98591</a><br>
                      <br>
                      Regards,<br>
                      Raoul Gough.<br>
                      <br>
                      _______________________________________________<br>
                      LLVM Developers mailing list<br>
                      <a href="mailto:llvm-dev@lists.llvm.org"
                        target="_blank" moz-do-not-send="true">llvm-dev@lists.llvm.org</a><br>
                      <a
                        href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev"
                        rel="noreferrer" target="_blank"
                        moz-do-not-send="true">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
                    </blockquote>
                  </div>
                </blockquote>
              </div>
            </blockquote>
            <p><br>
            </p>
          </div>
        </blockquote>
      </div>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>