diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -613,9 +613,6 @@ std::unique_ptr ABI; CXXABI *createCXXABI(const TargetInfo &T); - /// The logical -> physical address space map. - const LangASMap *AddrSpaceMap = nullptr; - /// Address space map mangling must be used with language specific /// address spaces (e.g. OpenCL/CUDA) bool AddrSpaceMapMangling; diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -930,39 +930,6 @@ return *ParentMapCtx.get(); } -static const LangASMap *getAddressSpaceMap(const TargetInfo &T, - const LangOptions &LOpts) { - if (LOpts.FakeAddressSpaceMap) { - // The fake address space map must have a distinct entry for each - // language-specific address space. - static const unsigned FakeAddrSpaceMap[] = { - 0, // Default - 1, // opencl_global - 3, // opencl_local - 2, // opencl_constant - 0, // opencl_private - 4, // opencl_generic - 5, // opencl_global_device - 6, // opencl_global_host - 7, // cuda_device - 8, // cuda_constant - 9, // cuda_shared - 1, // sycl_global - 5, // sycl_global_device - 6, // sycl_global_host - 3, // sycl_local - 0, // sycl_private - 10, // ptr32_sptr - 11, // ptr32_uptr - 12, // ptr64 - 13, // hlsl_groupshared - }; - return &FakeAddrSpaceMap; - } else { - return &T.getAddressSpaceMap(); - } -} - static bool isAddrSpaceMapManglingEnabled(const TargetInfo &TI, const LangOptions &LangOpts) { switch (LangOpts.getAddressSpaceMapMangling()) { @@ -1293,7 +1260,6 @@ this->AuxTarget = AuxTarget; ABI.reset(createCXXABI(Target)); - AddrSpaceMap = getAddressSpaceMap(Target, LangOpts); AddrSpaceMapMangling = isAddrSpaceMapManglingEnabled(Target, LangOpts); // C99 6.2.5p19. @@ -12244,10 +12210,7 @@ } unsigned ASTContext::getTargetAddressSpace(LangAS AS) const { - if (isTargetAddressSpace(AS)) - return toTargetAddressSpace(AS); - else - return (*AddrSpaceMap)[(unsigned)AS]; + return getTargetInfo().getTargetAddressSpace(AS); } bool ASTContext::hasSameExpr(const Expr *X, const Expr *Y) const { diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp --- a/clang/lib/Basic/TargetInfo.cpp +++ b/clang/lib/Basic/TargetInfo.cpp @@ -24,6 +24,30 @@ using namespace clang; static const LangASMap DefaultAddrSpaceMap = {0}; +// The fake address space map must have a distinct entry for each +// language-specific address space. +static const LangASMap FakeAddrSpaceMap = { + 0, // Default + 1, // opencl_global + 3, // opencl_local + 2, // opencl_constant + 0, // opencl_private + 4, // opencl_generic + 5, // opencl_global_device + 6, // opencl_global_host + 7, // cuda_device + 8, // cuda_constant + 9, // cuda_shared + 1, // sycl_global + 5, // sycl_global_device + 6, // sycl_global_host + 3, // sycl_local + 0, // sycl_private + 10, // ptr32_sptr + 11, // ptr32_uptr + 12, // ptr64 + 13, // hlsl_groupshared +}; // TargetInfo Constructor. TargetInfo::TargetInfo(const llvm::Triple &T) : Triple(T) { @@ -487,6 +511,9 @@ if (Opts.MaxBitIntWidth) MaxBitIntWidth = Opts.MaxBitIntWidth; + + if (Opts.FakeAddressSpaceMap) + AddrSpaceMap = &FakeAddrSpaceMap; } bool TargetInfo::initFeatureMap(