APIs such as PointerType::getUnqual/Type::getPointerTo() can result in
pointers being created in address space zero even though this is not
correct for all targets. We have been bitten by this issue many times our
CHERI fork: we use address space 200 for both globals and functions.
Creating a pointer in address space zero will generally result instruction
selection failures or in some cases code being generated that triggers
traps at run time. To avoid these problems, I've remove the many instances
of unsigned AS = 0 function parameters to ensure that pointers get created
in the right address space.
Keeping these changes out-of-tree results in compilation failures almost
every time I do an upstream merge. It would be very beneficial for us to
have these changes upstreamed, and should help targets such as AVR than
use a non-zero program address space.
I've seen some recent commits for AVR that fix the same AS=0 issues that
we have out-of-tree (e.g. 215dc2e203341f7d1edc4c4a191b048af4ace43d).
I think making such bugs a compilation failure should be beneficial for
everyone even if it means typing a few more characters to get a pointer type.
This change allows for gradual migration: we can add a single CMake line
to each directory that should no longer compile with implicit address
space zero: add_definitions(-DLLVM_NO_IMPLICIT_ADDRESS_SPACE=1). In this
patch I've added the definition to lib/IR and I will follow up with further
cleanups.
Depends on D70947.
clang-tidy: warning: invalid case style for parameter 'offset' [readability-identifier-naming]
not useful