hanchenye-llvm-project/clang/lib
Matt Arsenault c65f966d76 Try to make builtin address space declarations not useless
The way address space declarations for builtins currently work
is nearly useless. The code assumes the address spaces used for
builtins is a confusingly named "target address space" from user
code using __attribute__((address_space(N))) that matches
the builtin declaration. There's no way to use this to declare
a builtin that returns a language specific address space.
The terminology used is highly cofusing since it has nothing
to do with the the address space selected by the target to use
for a language address space.

This feature is essentially unused as-is. AMDGPU and NVPTX
are the only in-tree targets attempting to use this. The AMDGPU
builtins certainly do not behave as intended (i.e. all of the
builtins returning pointers can never compile because the numbered
address space never matches the expected named address space).

The NVPTX builtins are missing tests for some, and the others
seem to rely on an implicit addrspacecast.

Change the used address space for builtins based on a target
hook to allow using a language address space for a builtin.
This allows the same builtin declaration to be used for multiple
languages with similarly purposed address spaces (e.g. the same
AMDGPU builtin can be used in OpenCL and CUDA even though the
constant address spaces are arbitarily different).

This breaks the possibility of using arbitrary numbered
address spaces alongside the named address spaces for builtins.
If this is an issue we probably need to introduce another builtin
declaration character to distinguish language address spaces from
so-called "target address spaces".

llvm-svn: 338707
2018-08-02 12:14:28 +00:00
..
ARCMigrate Remove trailing space 2018-07-30 19:24:48 +00:00
AST Try to make builtin address space declarations not useless 2018-08-02 12:14:28 +00:00
ASTMatchers [ASTMatchers] Introduce a matcher for `ObjCIvarExpr`, support getting it's declaration. 2018-07-27 17:26:11 +00:00
Analysis [CFG] [analyzer] NFC: Enumerate construction context layer kinds. 2018-07-31 21:12:42 +00:00
Basic Try to make builtin address space declarations not useless 2018-08-02 12:14:28 +00:00
CodeGen Try to make builtin address space declarations not useless 2018-08-02 12:14:28 +00:00
CrossTU
Driver Revert r337635 "[Driver] Sanitizer support based on runtime library presence" 2018-07-31 21:57:35 +00:00
Edit Remove trailing space 2018-07-30 19:24:48 +00:00
Format clang-format: fix a crash in comment wraps. 2018-08-02 11:52:08 +00:00
Frontend Remove trailing space 2018-07-30 19:24:48 +00:00
FrontendTool Remove trailing space 2018-07-30 19:24:48 +00:00
Headers Remove trailing space 2018-07-30 19:24:48 +00:00
Index Remove trailing space 2018-07-30 19:24:48 +00:00
Lex Remove trailing space 2018-07-30 19:24:48 +00:00
Parse [UnrollAndJam] Add unroll_and_jam pragma handling 2018-08-01 14:36:12 +00:00
Rewrite Remove trailing space 2018-07-30 19:24:48 +00:00
Sema Try to make builtin address space declarations not useless 2018-08-02 12:14:28 +00:00
Serialization Serialize DoesNotEscape. 2018-08-01 23:51:53 +00:00
StaticAnalyzer [analyzer] Extend NoStoreFuncVisitor to follow fields. 2018-08-02 02:02:40 +00:00
Tooling [Tooling] Use UniqueStringSaver. NFC 2018-07-23 11:25:25 +00:00
CMakeLists.txt