<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 12/05/2017 01:47 PM, Lei Huang via
      cfe-dev wrote:<br>
    </div>
    <blockquote
cite="mid:OFB022F28E.4057B6DB-ON002581ED.006C5D8F-002581ED.006CC1F5@notes.na.collabserv.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <div class="socmaildefaultfont" dir="ltr"
        style="font-family:Arial, Helvetica,
        sans-serif;font-size:10.5pt">
        <div class="socmaildefaultfont" dir="ltr"
          style="font-family:Arial, Helvetica,
          sans-serif;font-size:10.5pt">
          <div dir="ltr"> </div>
          <div dir="ltr"><font style="outline: none;" size="3"
              face="Arial">Hello,</font><br style="outline: none;
              font-family: "Helvetica Neue", Helvetica, Arial,
              "Lucida Grande", sans-serif; font-size: 12px;">
            <font style="outline: none;" size="3" face="Arial"> </font><br
              style="outline: none; font-family: "Helvetica
              Neue", Helvetica, Arial, "Lucida Grande",
              sans-serif; font-size: 12px;">
            <font style="outline: none;" size="3" face="Arial">In the
              discussion on bugzilla 30729, it is mentioned that the <span
                style="outline: none; font-family: "Courier
                New", Courier, monospace;">'</span></font><span
              style="outline: none; font-family: "Courier
              New", Courier, monospace;"><font style="outline:
                none;" size="3">this'</font></span><font style="outline:
              none;" size="3" face="Arial"> pointer needs to be valid
              upon entry to a non-static method.  Does the standard
              guarantee </font><font style="outline: none;" size="3"
              face="Courier">this</font><font style="outline: none;"
              size="3" face="Arial"> is non-null on entry?</font></div>
        </div>
      </div>
    </blockquote>
    <br>
    Yes. You have to call a non-static member function on a valid
    object.<br>
    <br>
    <blockquote
cite="mid:OFB022F28E.4057B6DB-ON002581ED.006C5D8F-002581ED.006CC1F5@notes.na.collabserv.com"
      type="cite">
      <div class="socmaildefaultfont" dir="ltr"
        style="font-family:Arial, Helvetica,
        sans-serif;font-size:10.5pt">
        <div class="socmaildefaultfont" dir="ltr"
          style="font-family:Arial, Helvetica,
          sans-serif;font-size:10.5pt">
          <div dir="ltr"><font style="outline: none;" size="3"
              face="Arial">  If so, is there a reason we can't use that
              fact to mark '</font><font style="outline: none;" size="3"
              face="Courier New">this'</font><font style="outline:
              none;" size="3" face="Arial"> as '</font><font
              style="outline: none;" size="3" face="Courier New">dereferenceable(sizeof(*this))'</font><font
              style="outline: none;" size="3" face="Arial">?</font><br
              style="outline: none; font-family: "Helvetica
              Neue", Helvetica, Arial, "Lucida Grande",
              sans-serif; font-size: 12px;">
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    Yes, this seems like a good idea.<br>
    <br>
     -Hal<br>
    <br>
    <blockquote
cite="mid:OFB022F28E.4057B6DB-ON002581ED.006C5D8F-002581ED.006CC1F5@notes.na.collabserv.com"
      type="cite">
      <div class="socmaildefaultfont" dir="ltr"
        style="font-family:Arial, Helvetica,
        sans-serif;font-size:10.5pt">
        <div class="socmaildefaultfont" dir="ltr"
          style="font-family:Arial, Helvetica,
          sans-serif;font-size:10.5pt">
          <div dir="ltr"><font style="outline: none;" size="3"
              face="Arial"> </font><br style="outline: none;
              font-family: "Helvetica Neue", Helvetica, Arial,
              "Lucida Grande", sans-serif; font-size: 12px;">
            <font style="outline: none;" size="3" face="Arial">There are
              LICM optimizations we can do based on the knowledge that '</font><font
              style="outline: none;" size="3" face="Courier New">this' </font><font
              style="outline: none;" size="3" face="Arial">is non-null
              on entry to a non-static member function. </font><br
              style="outline: none; font-family: "Helvetica
              Neue", Helvetica, Arial, "Lucida Grande",
              sans-serif; font-size: 12px;">
            <font style="outline: none;" size="3" face="Arial"> </font><br
              style="outline: none; font-family: "Helvetica
              Neue", Helvetica, Arial, "Lucida Grande",
              sans-serif; font-size: 12px;">
            <font style="outline: none;" size="3" face="Arial">eg.  For
              the following IR,  the two highlighted loads are not being
              hoisted out of the for loop because we are not able to
              guarantee that the pointer is non-null.  If the '</font><font
              style="outline: none;" size="3" face="Courier New">this</font><font
              style="outline: none;" size="3" face="Arial">' pointer is
              guaranteed to be non-null on entry and we mark it thus,
               then the 2 loads within the for-loop body can then be
              hoisted out into the loop preheader.</font><br
              style="outline: none; font-family: "Helvetica
              Neue", Helvetica, Arial, "Lucida Grande",
              sans-serif; font-size: 12px;">
            <font style="outline: none;" size="3" face="Arial"> </font><br
              style="outline: none; font-family: "Helvetica
              Neue", Helvetica, Arial, "Lucida Grande",
              sans-serif; font-size: 12px;">
            <font style="outline: none;" size="3" face="Arial">This is
              of course just one example of an optimization we could
              perform based on this knowledge, but there are probably a
              number of others (i.e. anything that relies on a pointer
              being '</font><font style="outline: none;" size="3"
              face="Courier New">dereferenceable(N)'</font><font
              style="outline: none;" size="3" face="Arial">).</font><br
              style="outline: none; font-family: "Helvetica
              Neue", Helvetica, Arial, "Lucida Grande",
              sans-serif; font-size: 12px;">
            <font style="outline: none;" size="3" face="Arial"> </font><br
              style="outline: none; font-family: "Helvetica
              Neue", Helvetica, Arial, "Lucida Grande",
              sans-serif; font-size: 12px;">
            <b style="outline: none; font-family: "Helvetica
              Neue", Helvetica, Arial, "Lucida Grande",
              sans-serif; font-size: 12px;"><font style="outline: none;"
                size="3" face="Courier New">$ cat a.ll</font></b><br
              style="outline: none; font-family: "Helvetica
              Neue", Helvetica, Arial, "Lucida Grande",
              sans-serif; font-size: 12px;">
            <font style="outline: none;" size="3" face="Courier New">target
              datalayout = "e-m:e-i64:64-n32:64"<br style="outline:
                none;">
              target triple = "powerpc64le-unknown-linux-gnu"</font><br
              style="outline: none; font-family: "Helvetica
              Neue", Helvetica, Arial, "Lucida Grande",
              sans-serif; font-size: 12px;">
            <font style="outline: none;" size="3" face="Courier New">%struct.S
              = type { <4 x i32>, <4 x i32> }</font><br
              style="outline: none; font-family: "Helvetica
              Neue", Helvetica, Arial, "Lucida Grande",
              sans-serif; font-size: 12px;">
            <font style="outline: none;" size="3" face="Courier New">;
              Function Attrs: norecurse nounwind readonly<br
                style="outline: none;">
              define <4 x i32>
              @_ZNK1S20constShouldBeHoistedEmDv4_i(%struct.S* nocapture
              readonly %this, i64 %n, <4 x<br style="outline: none;">
              i32> %x) align 2 {<br style="outline: none;">
              entry:<br style="outline: none;">
               %tobool9 = icmp eq i64 %n, 0<br style="outline: none;">
               br i1 %tobool9, label %for.end, label %for.body.lr.ph</font><br
              style="outline: none; font-family: "Helvetica
              Neue", Helvetica, Arial, "Lucida Grande",
              sans-serif; font-size: 12px;">
            <font style="outline: none;" size="3" face="Courier New">for.body.lr.ph:
                                                ; preds = %entry<br
                style="outline: none;">
               %k1 = getelementptr inbounds %struct.S, %struct.S* %this,
              i64 0, i32 0<br style="outline: none;">
               %k2 = getelementptr inbounds %struct.S, %struct.S* %this,
              i64 0, i32 1<br style="outline: none;">
               br label %for.body</font><br style="outline: none;
              font-family: "Helvetica Neue", Helvetica, Arial,
              "Lucida Grande", sans-serif; font-size: 12px;">
            <font style="outline: none;" size="3" face="Courier New">for.body:
                                                      ; preds =
              %for.body.lr.ph, %if.end<br style="outline: none;">
               %n.addr.011 = phi i64 [ %n, %for.body.lr.ph ], [ %div,
              %if.end ]<br style="outline: none;">
               %x.addr.010 = phi <4 x i32> [ %x, %for.body.lr.ph
              ], [ %x.addr.1, %if.end ]<br style="outline: none;">
               %rem = and i64 %n.addr.011, 15<br style="outline: none;">
               %cmp = icmp eq i64 %rem, 0<br style="outline: none;">
               br i1 %cmp, label %if.end, label %if.then</font><br
              style="outline: none; font-family: "Helvetica
              Neue", Helvetica, Arial, "Lucida Grande",
              sans-serif; font-size: 12px;">
            <font style="outline: none;" size="3" face="Courier New">if.then:
                                                       ; preds =
              %for.body<br style="outline: none;">
               </font><b style="outline: none; font-family:
              "Helvetica Neue", Helvetica, Arial, "Lucida
              Grande", sans-serif; font-size: 12px;"><font
                style="outline: none;" size="3" face="Courier New">%0 =
                load <4 x i32>, <4 x i32>* %k1, align 16</font></b><br
              style="outline: none;">
            <font style="outline: none;" size="3" face="Courier New"> %add
              = add <4 x i32> %0, %x.addr.010<br style="outline:
                none;">
               </font><b style="outline: none; font-family:
              "Helvetica Neue", Helvetica, Arial, "Lucida
              Grande", sans-serif; font-size: 12px;"><font
                style="outline: none;" size="3" face="Courier New">%1 =
                load <4 x i32>, <4 x i32>* %k2, align 16</font></b><br
              style="outline: none;">
            <font style="outline: none;" size="3" face="Courier New"> %xor
              = xor <4 x i32> %add, %1<br style="outline: none;">
               br label %if.end</font><br style="outline: none;
              font-family: "Helvetica Neue", Helvetica, Arial,
              "Lucida Grande", sans-serif; font-size: 12px;">
            <font style="outline: none;" size="3" face="Courier New">if.end:
                                                        ; preds =
              %for.body, %if.then<br style="outline: none;">
               %x.addr.1 = phi <4 x i32> [ %xor, %if.then ], [
              %x.addr.010, %for.body ]<br style="outline: none;">
               %div = lshr i64 %n.addr.011, 4<br style="outline: none;">
               %tobool = icmp eq i64 %div, 0<br style="outline: none;">
               br i1 %tobool, label %for.end, label %for.body</font><br
              style="outline: none; font-family: "Helvetica
              Neue", Helvetica, Arial, "Lucida Grande",
              sans-serif; font-size: 12px;">
            <font style="outline: none;" size="3" face="Courier New">for.end:
                                                       ; preds =
              %if.end, %entry<br style="outline: none;">
               %x.addr.0.lcssa = phi <4 x i32> [ %x, %entry ], [
              %x.addr.1, %if.end ]<br style="outline: none;">
               ret <4 x i32> %x.addr.0.lcssa<br style="outline:
                none;">
              }</font><br style="outline: none; font-family:
              "Helvetica Neue", Helvetica, Arial, "Lucida
              Grande", sans-serif; font-size: 12px;">
            <font style="outline: none;" size="3" face="Arial"> </font></div>
          <div dir="ltr"> </div>
          <div dir="ltr">
            <div class="socmaildefaultfont" dir="ltr"
              style="font-family:Arial, Helvetica,
              sans-serif;font-size:10.5pt">
              <div class="socmaildefaultfont" dir="ltr"
                style="font-family:Arial, Helvetica,
                sans-serif;font-size:10.5pt">
                <div class="socmaildefaultfont" dir="ltr"
                  style="font-family:Arial, Helvetica,
                  sans-serif;font-size:10.5pt">
                  <div dir="ltr"><br>
                    Regards,<br>
                    Lei Huang</div>
                  <div dir="ltr"> </div>
                  <div dir="ltr"> </div>
                  <div dir="ltr">LLVM Development on POWER</div>
                  <div dir="ltr">Internal mail: C2/YGK/8200/MKM<br>
                    Phone: (905) 413-4419<br>
                    TieLine: 969-4419<br>
                    E-mail: <a class="moz-txt-link-abbreviated" href="mailto:lei@ca.ibm.com">lei@ca.ibm.com</a></div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
cfe-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a>
</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
  </body>
</html>