[cfe-commits] r162787 - in /cfe/trunk: lib/CodeGen/CGDecl.cpp test/CodeGenCUDA/address-spaces.cu
Peter Collingbourne
peter at pcc.me.uk
Tue Aug 28 13:37:10 PDT 2012
Author: pcc
Date: Tue Aug 28 15:37:10 2012
New Revision: 162787
URL: http://llvm.org/viewvc/llvm-project?rev=162787&view=rev
Log:
CUDA: give correct address space to globals declared in functions
Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/test/CodeGenCUDA/address-spaces.cu
Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=162787&r1=162786&r2=162787&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Tue Aug 28 15:37:10 2012
@@ -184,12 +184,14 @@
Name = GetStaticDeclName(*this, D, Separator);
llvm::Type *LTy = CGM.getTypes().ConvertTypeForMem(Ty);
+ unsigned AddrSpace =
+ CGM.GetGlobalVarAddressSpace(&D, CGM.getContext().getTargetAddressSpace(Ty));
llvm::GlobalVariable *GV =
new llvm::GlobalVariable(CGM.getModule(), LTy,
Ty.isConstant(getContext()), Linkage,
CGM.EmitNullConstant(D.getType()), Name, 0,
llvm::GlobalVariable::NotThreadLocal,
- CGM.getContext().getTargetAddressSpace(Ty));
+ AddrSpace);
GV->setAlignment(getContext().getDeclAlign(&D).getQuantity());
if (Linkage != llvm::GlobalValue::InternalLinkage)
GV->setVisibility(CurFn->getVisibility());
Modified: cfe/trunk/test/CodeGenCUDA/address-spaces.cu
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/address-spaces.cu?rev=162787&r1=162786&r2=162787&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCUDA/address-spaces.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/address-spaces.cu Tue Aug 28 15:37:10 2012
@@ -20,5 +20,9 @@
// CHECK: load i32* bitcast (i32 addrspace(3)* @k to i32*)
k++;
+
+ static int li;
+ // CHECK: load i32 addrspace(1)* @_ZZ3foovE2li
+ li++;
}
More information about the cfe-commits
mailing list