<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 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 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 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 href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a 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>