<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 7, 2015 at 12:10 PM, Philip Reames <span dir="ltr"><<a href="mailto:listmail@philipreames.com" target="_blank">listmail@philipreames.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000"><span class="">
    <br>
    <div>On 01/07/2015 12:05 PM, Matt Arsenault
      wrote:<br>
    </div>
    <blockquote type="cite">
      
      <br>
      <div>
        <blockquote type="cite">
          <div>On Jan 7, 2015, at 2:55 PM, Philip Reames <<a href="mailto:listmail@philipreames.com" target="_blank">listmail@philipreames.com</a>>
            wrote:</div>
          <br>
          <div>
            
            <div bgcolor="#FFFFFF" text="#000000"> <br>
              <div>On 01/07/2015 11:52 AM, Matt
                Arsenault wrote:<br>
              </div>
              <blockquote type="cite">
                
                <br>
                <div>
                  <blockquote type="cite">
                    <div>On Jan 7, 2015, at 2:25 PM, Owen
                      Anderson <<a href="mailto:resistor@mac.com" target="_blank">resistor@mac.com</a>>
                      wrote:</div>
                    <br>
                    <div>
                      
                      <div dir="auto">
                        <div>I'm not aware of any such
                          restriction, and I know of several LLVM based
                          systems that use address space 1 for something
                          other than that.<br>
                          <br>
                          -Owen</div>
                      </div>
                    </div>
                  </blockquote>
                  <div><br>
                  </div>
                  <div>Yes, this would be a problem for us. We
                    use 1 for a normal address space where 0 is invalid.
                    However, we also have a problem where some other
                    address spaces do want 0 to be a valid address,
                    which just sort of don’t work correctly now.</div>
                </div>
              </blockquote>
              If you have an example with a null in a non-0 address
              space being mishandled, please file a bug.  We'll fix them
              as we find them.  <br>
            </div>
          </div>
        </blockquote>
        <div><br>
        </div>
        <div>I think the problems aren’t so much that accessing 0
          doesn’t work (although I imagine there are problems with
          that), but expectations of comparison with null. The main
          problem I’m aware of is comparisons with null pointers. The
          first global object in addrspace(3) will have the address of
          0, so if a user does if (x != NULL), it will not behave as
          expected. For C I think this is supposed to be fixed by
          changing the value of NULL to -1, but I don’t think that is
          currently supported. That is also complicated because the null
          value is different for different address spaces, and I think
          the actual null pointer value must be 0 for C++. It doesn’t
          really turn up often in real code so I don’t think anybody has
          really spent time thinking about how to properly solve this.</div>
      </div>
    </blockquote></span>
    Just to make sure I'm interpreting this right: the problem is
    essentially that we hard code "null" to mean address 0 in all
    address spaces?  If we allowed the numeric value of null to be
    configurable per address space, would that resolve the issue at the
    LLVM IR level?<br>
    <br>
    Solving the frontend/language spec problem seems out of scope for
    LLVM, though probably not for clang.  Can you point me to a usage of
    C++ with non-zero address spaces?  I'd be curious to know what's
    happening in this space.  <br></div></blockquote><div><br></div><div>I know of GPU-targeting compilers that use C++ as a frontend language. I unfortunately don't have anything to point you to though.</div><div><br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><span class="">
    <br>
    <blockquote type="cite">
      <div>
        <div><br>
        </div>
        <div>-Matt</div>
        <div><br>
        </div>
        <br>
        <blockquote type="cite">
          <div>
            <div bgcolor="#FFFFFF" text="#000000">
              <blockquote type="cite">
                <div>
                  <div><br>
                  </div>
                  <div>-Matt</div>
                  <div><br>
                  </div>
                  <div><br>
                  </div>
                  <br>
                  <blockquote type="cite">
                    <div>
                      <div dir="auto">
                        <div><br>
                          On Jan 7, 2015, at 1:18 PM, Philip Reames <<a href="mailto:listmail@philipreames.com" target="_blank">listmail@philipreames.com</a>>
                          wrote:<br>
                          <br>
                        </div>
                        <blockquote type="cite">
                          <div>
                            
                            On the review for <a href="http://reviews.llvm.org/D6808" target="_blank">http://reviews.llvm.org/D6808</a>,
                            <a href="http://reviews.llvm.org/p/majnemer/" target="_blank">majnemer</a>
                            commented that:<br>
                            <span>"Address space 1 has a
                              special meaning in LLVM, it's identical to
                              address space 0 except for the fact that
                              "null" may be dereferenced. You might want
                              to consider a different address space."<br>
                              <br>
                              This is the first I've heard of this and I
                              can't find any documentation about it
                              being reserved, either in general, or
                              specifically for x86.  Can anyone clarify?<br>
                              <br>
                              The only address spaces with special
                              meanings I know of are:<br>
                              - 0 (the normal address space, null is not
                              dereferencable)<br>
                              - 256 - TLS, GS relative addressing<br>
                              - 257 - FS relative addressing<br>
                              <br>
                              Philip<br>
                            </span> </div>
                        </blockquote>
                        <blockquote type="cite">
                          <div><span>_______________________________________________</span><br>
                            <span>LLVM Developers mailing list</span><br>
                            <span><a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>
                                      <a href="http://llvm.cs.uiuc.edu/" target="_blank">http://llvm.cs.uiuc.edu</a></span><br>
                            <span><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a></span><br>
                          </div>
                        </blockquote>
                      </div>
                      _______________________________________________<br>
                      LLVM Developers mailing list<br>
                      <a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>
                              <a href="http://llvm.cs.uiuc.edu/" target="_blank">http://llvm.cs.uiuc.edu</a><br>
                      <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
                    </div>
                  </blockquote>
                </div>
                <br>
              </blockquote>
              <br>
            </div>
          </div>
        </blockquote>
      </div>
      <br>
    </blockquote>
    <br>
  </span></div>

<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div></div>