<p dir="ltr">Thanks for the pointer! </p>
<br><div class="gmail_quote"><div dir="ltr">On Wed 29 Nov, 2017, 18:50 Philip Reames, <<a href="mailto:listmail@philipreames.com">listmail@philipreames.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <p>There are no existing attributes for this in upstream, but you
      can hook isAllocLikeFunction to get the effect you're looking for.</p>
    <p>Philip<br>
    </p></div><div text="#000000" bgcolor="#FFFFFF">
    <br>
    <div class="m_4170291636054243901moz-cite-prefix">On 11/17/2017 05:17 AM, Siddharth Bhat
      via llvm-dev wrote:<br>
    </div>
    </div><div text="#000000" bgcolor="#FFFFFF"><blockquote type="cite">
      <div dir="ltr">
        <div>Hello all,</div>
        <div>I have a custom allocator, and would like to teach LLVM
          about its semantics. In particular, I would like LLVM to kill
          allocations that are "dead", similar to dead <span style="font-family:monospace">new in</span> C++.<br>
        </div>
        <div><br>
        </div>
        <div>Consider this example:</div>
        <div><br>
        </div>
        <div><span style="font-family:monospace">; ModuleID =
            '<stdin>'<br>
            source_filename = "Module"<br>
            <br>
            ; Function Attrs: inaccessiblememonly noinline norecurse
            nounwind<br>
            declare i8* @alloc(i64) local_unnamed_addr #0<br>
            <br>
            ; Function Attrs: inaccessiblememonly noinline norecurse
            nounwind<br>
            declare void @useClosure(i8*) local_unnamed_addr #1<br>
            <br>
            ; Function Attrs: alwaysinline norecurse nounwind<br>
            define void @main() #1 {<br>
            entry:<br>
              %closure.raw = tail call noalias i8* @alloc(i64 8)<br>
              %fn_slot = bitcast i8* %closure.raw to void ()**<br>
              store void ()* @"case_ackerman(atom-3 atom-10)_alts", void
            ()** %fn_slot, align 8, !invariant.group !0<br>
              tail call void @useClosure(i8* %closure.raw)<br>
              ;========<br>
              ; dead<br>
              %closure.raw.i = tail call noalias i8* @alloc(i64 24)<br>
              %fn_slot.i = bitcast i8* %closure.raw.i to void ()**<br>
              store void ()* @"case_aint()_alts", void ()** %fn_slot.i,
            align 8, !invariant.group !0<br>
              ;========<br>
              ret void<br>
            }<br>
            <br>
            ; Function Attrs: alwaysinline<br>
            declare void @"case_aint()_alts"() #2<br>
            <br>
            ; Function Attrs: alwaysinline<br>
            declare void @"case_ackerman(atom-3 atom-10)_alts"() #2<br>
            <br>
            attributes #0 = { inaccessiblememonly noinline norecurse
            nounwind writeonly }<br>
            attributes #1 = { alwaysinline norecurse nounwind }<br>
            attributes #2 = { alwaysinline }<br>
            <br>
            !0 = distinct !{!0, !"closure_invariant_group"}</span><br>
          -----</div>
        <div><br>
        </div>
        <div>In my view, <span style="font-family:monospace">%closure.raw.i
          </span>is a dead allocation<span style="font-family:monospace"><font face="sans-serif">, because the memory returned by it is
              not used anywhere. How do I communicate this fact to LLVM?</font></span></div>
        <div><span style="font-family:monospace"><font face="sans-serif"><br>
            </font></span></div>
        <div><span style="font-family:monospace"><font face="sans-serif">I
              tried seeing how clang does it, but I'm not sure - it
              doesn't seem to have any attribute that would help, except
              perhaps </font>builtin<font face="sans-serif">. Does LLVM
              know about the special semantics of new?<br>
            </font></span></div>
        <div><span style="font-family:monospace"><font face="sans-serif"><br>
            </font></span></div>
        <div><span style="font-family:monospace"><font face="sans-serif">Cheers,</font></span></div>
        <div><span style="font-family:monospace"><font face="sans-serif">~Siddharth.</font><br>
          </span></div>
      </div>
      <div dir="ltr">-- <br>
      </div>
      <div class="m_4170291636054243901gmail_signature" data-smartmail="gmail_signature">
        <div dir="ltr">Sending this from my phone, please excuse any
          typos!</div>
      </div>
      <br>
      <fieldset class="m_4170291636054243901mimeAttachmentHeader"></fieldset>
      <br>
      </blockquote></div><div text="#000000" bgcolor="#FFFFFF"><blockquote type="cite"><pre>_______________________________________________
LLVM Developers mailing list
<a class="m_4170291636054243901moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>
<a class="m_4170291636054243901moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
    </blockquote>
    <br>
  </div>

</blockquote></div><div dir="ltr">-- <br></div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Sending this from my phone, please excuse any typos!</div></div>