[PATCH] D26196: Add support for non-zero null pointers

John McCall via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 10 13:50:25 PST 2016


rjmccall added inline comments.


================
Comment at: lib/CodeGen/TargetInfo.cpp:7040
+ auto AS = PT->getAddressSpace();
+ return AS != Ctx.getTargetAddressSpace(LangAS::opencl_local) && AS != 0;
+}
----------------
yaxunl wrote:
> rjmccall wrote:
> > This check is definitely not correct; this function needs to return true when AS == 0, right?
> > 
> > Also, you should really just be checking QT.getAddressSpace().
> The null pointer of amdgpu target in addr space 0 does not have zero value.
> 
> I will change it use QT.getAddressSpace() though.
Oh, if the *default* address space — the address space of the stack — has a non-zero null pointer value, that will definitely change a lot of things, and LLVM will probably be deeply unhappy with you.  I feel like that's a much bigger and more problematic change.  This is still the right approach for working around it in Clang, but... it's concerning.

And that does mean you'll have to fix a bunch of the other languages that in principle you could otherwise have avoided.


https://reviews.llvm.org/D26196





More information about the cfe-commits mailing list