CodeGen: Fix address space of global variable
authorYaxun Liu <Yaxun.Liu@amd.com>
Sat, 8 Jul 2017 13:24:52 +0000 (13:24 +0000)
committerYaxun Liu <Yaxun.Liu@amd.com>
Sat, 8 Jul 2017 13:24:52 +0000 (13:24 +0000)
commitcbf647cc3a712ada34fcd78f7d39756193f323d2
tree7122745644a399b3aa8ac176c4fea1c9064462d5
parentaffab3047e777ab69e09d18d23e8e7748b86b728
CodeGen: Fix address space of global variable

Certain targets (e.g. amdgcn) require global variable to stay in global or constant address
space. In C or C++ global variables are emitted in the default (generic) address space.
This patch introduces virtual functions TargetCodeGenInfo::getGlobalVarAddressSpace
and TargetInfo::getConstantAddressSpace to handle this in a general approach.

It only affects IR generated for amdgcn target.

Differential Revision: https://reviews.llvm.org/D33842

llvm-svn: 307470
13 files changed:
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/Targets.cpp
clang/lib/CodeGen/CGBlocks.cpp
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/CodeGen/TargetInfo.h
clang/test/CodeGen/address-space.c
clang/test/CodeGen/default-address-space.c
clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp