<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 1/6/22 7:45 AM, Augie Fackler via
      llvm-dev wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAHcr6Hbs7ts8PkhFK4jGFdwbngzUs4juZsuXcNGEC46EVpwM7Q@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div dir="ltr"><br>
        </div>
        <br>
        <div class="gmail_quote">
          <div dir="ltr" class="gmail_attr">On Wed, Jan 5, 2022 at 7:58
            PM Jessica Clarke <<a href="mailto:jrtc27@jrtc27.com"
              moz-do-not-send="true">jrtc27@jrtc27.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">On 5 Jan 2022, at 22:32,
            Augie Fackler 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>
            > Proposal<br>
            > =======<br>
            > We add two attributes to LLVM IR:<br>
            > <br>
            >  * `allocator(FAMILY)`: Marks a function as part of an
            allocator family, named by the “primary” allocation function
            (e.g. `allocator(“malloc”)`, `allocator(“_Znwm”)`, or
            `allocator(“__rust_alloc”)`).<br>
            <br>
            Why do you need a family? What’s insufficient about just
            using allocsize(idx), as used by
            __attribute__((alloc_size(...)) in GNU C? (Which you
            acknowledge the existence of, but don’t justify why you need
            your own attribute.) What to use as the allocator “family”
            string for C++ operator new seems pretty unclear too, so I’m
            not sure how good an idea this free-form string argument is
            in your proposal.<br>
          </blockquote>
          <div><br>
          </div>
          <div>For C++ new we'd use the mangled form of ::operator::new,
            aka _Znwm. The reason for the family is so that we can track
            which allocations are related, so that incorrect code like</div>
          <div><br>
          </div>
          <div>{</div>
          <div>  auto *foo = new Foo();</div>
          <div>  free(foo);</div>
          <div>}</div>
          <div><br>
          </div>
          <div>doesn't get optimized away. I believe others I talked to
            while designing this might have had more interesting ideas
            for how the family could be used, but it's easy to put in
            today, and roughly impossible to add via an IR upgrade if we
            don't put it in, so it seems sensible to try and track the
            family now. I actually initially argued against the family
            argument, but was won over by the limitation that we'd be
            unable to upgrade it in the future.</div>
        </div>
      </div>
    </blockquote>
    JFYI, this example does not provide the motivation you seem to think
    it does.  This example is to my knowledge, immediate UB.  As such,
    there's no need to "avoid" the optimization.  If anything, we should
    be more aggressive and convert this to an unreachable.  <br>
    <blockquote type="cite"
cite="mid:CAHcr6Hbs7ts8PkhFK4jGFdwbngzUs4juZsuXcNGEC46EVpwM7Q@mail.gmail.com">
      <div dir="ltr">
        <div class="gmail_quote">
          <div> </div>
          <blockquote class="gmail_quote" style="margin:0px 0px 0px
            0.8ex;border-left:1px solid
            rgb(204,204,204);padding-left:1ex">
            >  * `releaseptr(idx)`: Indicates that the function
            releases the pointer that is its Nth argument.<br>
            <br>
            This should probably just be
            free(idx)/frees(idx)/willfree(idx) (we already have nofree
            as an attribute for arguments), or an attribute on the
            argument itself. Talking about releasing makes it sound like
            reference counting semantics.<br>
          </blockquote>
          <div><br>
          </div>
          <div>Sure, that seems reasonable. I'll update my prototype to
            use that name instead. Thanks!</div>
          <div> </div>
          <blockquote class="gmail_quote" style="margin:0px 0px 0px
            0.8ex;border-left:1px solid
            rgb(204,204,204);padding-left:1ex">
            <br>
            Jess<br>
            <br>
          </blockquote>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
    </blockquote>
  </body>
</html>