<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/15/2017 01:34 AM, Sean Silva
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAHnXoam6Ds-JiQtBgE8A3CZVANLFBx+DmACU3DZ_gdUC+U2W_g@mail.gmail.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <div dir="auto">
        <div><br>
          <div class="gmail_extra"><br>
            <div class="gmail_quote">On Dec 14, 2017 10:21 PM, "Hal
              Finkel via llvm-dev" <<a moz-do-not-send="true"
                href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>>
              wrote:<br type="attribution">
              <blockquote class="quote" style="margin:0 0 0
                .8ex;border-left:1px #ccc solid;padding-left:1ex">
                <div bgcolor="#FFFFFF" text="#000000">
                  <div class="elided-text">
                    <p><br>
                    </p>
                    <div class="m_8717365914017720711moz-cite-prefix">On
                      12/14/2017 11:14 PM, Matt Arsenault wrote:<br>
                    </div>
                    <blockquote type="cite"> <br>
                      <div><br>
                        <blockquote type="cite">
                          <div>On Dec 14, 2017, at 20:28, Hal Finkel via
                            llvm-dev <<a moz-do-not-send="true"
                              href="mailto:llvm-dev@lists.llvm.org"
                              target="_blank">llvm-dev@lists.llvm.org</a>>
                            wrote:</div>
                          <br
                            class="m_8717365914017720711Apple-interchange-newline">
                          <div><span
style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);float:none;display:inline!important">Would
                              that address your use case? Or can you
                              have null dereferenceable pointers in that
                              address space, just not ones from alloca?</span><br
style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255)">
                          </div>
                        </blockquote>
                      </div>
                      <div><br>
                      </div>
                      I would like to clarify what “null” means exactly.
                      One related thing I would like in the future is
                      for the DataLayout to specify what numeric value
                      is the invalid, non-dereferencalbe pointer. i.e.
                      the invalid pointer does is a some non-0 bit
                      pattern like -1.</blockquote>
                    <br>
                  </div>
                  Okay. That's certainly a separate discussion. For the
                  purpose of this question I mean null as zero. Can you
                  have dereferenceable pointers, with a value of zero
                  when converted to an integer, in that address space?
                  Or are you interested only in saying that alloca never
                  produces pointers with a value of zero when converted
                  to an integer?<br>
                </div>
              </blockquote>
            </div>
          </div>
        </div>
        <div dir="auto"><br>
        </div>
        <div dir="auto">FWIW on Pixel Visual Core, we have on-chip
          memories for which the pointer with numerical value zero is a
          valid location (and it is natural to model these as allocas).</div>
        <div dir="auto"><br>
        </div>
        <div dir="auto">As I've come to learn, it's actually difficult
          for the hardware folks to make 0 *not* be valid since the
          address decoders selecting which word from a memory should be
          read out naturally take 0 to N as input. (I.e. at the end of
          the day everything is actually a natural 0-based index into an
          array)</div>
        <div dir="auto"><br>
        </div>
        <div dir="auto">The only case I can think of where it is
          convenient to make 0 be invalid is when you are dealing with a
          relatively sparsely populated memory map (either virtual or
          hardcoded as in a microcontroller) and you can simply avoid
          putting something at 0. But that's more about the logic that
          looks at the high bits of the address to determine which
          mapping in the memory map is being accessed.</div>
        <div dir="auto"><br>
        </div>
        <div dir="auto">So I assume that it most of the time when you
          have explicitly addressed memories that are not part of a
          larger linear memory map, the numerically 0 pointer will
          actually be valid. On-chip scratchpad memories on accelerators
          are probably going to be a common case of this (such as the
          AMDGPU LDS in this thread I presume).</div>
      </div>
    </blockquote>
    <br>
    Certainly. I can imagine, however, cases where zero is a valid
    address in general, but will never be a stack-allocated address
    (e.g., because your stack grows down, so 0 is the very last byte of
    the possible stack in that address space, and the stack just can't
    grow that far because there's other data there).<br>
    <br>
     -Hal<br>
    <br>
    <blockquote
cite="mid:CAHnXoam6Ds-JiQtBgE8A3CZVANLFBx+DmACU3DZ_gdUC+U2W_g@mail.gmail.com"
      type="cite">
      <div dir="auto">
        <div dir="auto"><br>
        </div>
        <div dir="auto">-- Sean Silva</div>
        <div dir="auto"><br>
        </div>
        <div dir="auto">
          <div class="gmail_extra">
            <div class="gmail_quote">
              <blockquote class="quote" style="margin:0 0 0
                .8ex;border-left:1px #ccc solid;padding-left:1ex">
                <div bgcolor="#FFFFFF" text="#000000"> <br>
                  Thanks again,<br>
                  Hal<br>
                  <br>
                  <blockquote type="cite">
                    <div><br>
                    </div>
                    <div>-Matt</div>
                  </blockquote>
                  <div class="quoted-text"> <br>
                    <pre class="m_8717365914017720711moz-signature" cols="72">-- 
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
                  </div>
                </div>
                <br>
                ______________________________<wbr>_________________<br>
                LLVM Developers mailing list<br>
                <a moz-do-not-send="true"
                  href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
                <a moz-do-not-send="true"
                  href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev"
                  rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
                <br>
              </blockquote>
            </div>
            <br>
          </div>
        </div>
      </div>
    </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>