@@ -1019,16 +1019,14 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
10191019 const DataLayout &DL = getDataLayout ();
10201020
10211021 // GlobalVariables are always constant pointers themselves.
1022+ PointerType *PTy = GVar->getType ();
10221023 Type *ETy = GVar->getValueType ();
10231024
10241025 if (GVar->hasExternalLinkage ()) {
10251026 if (GVar->hasInitializer ())
10261027 O << " .visible " ;
10271028 else
10281029 O << " .extern " ;
1029- } else if (GVar->hasCommonLinkage () &&
1030- GVar->getAddressSpace () == ADDRESS_SPACE_GLOBAL) {
1031- O << " .common " ;
10321030 } else if (GVar->hasLinkOnceLinkage () || GVar->hasWeakLinkage () ||
10331031 GVar->hasAvailableExternallyLinkage () ||
10341032 GVar->hasCommonLinkage ()) {
@@ -1140,7 +1138,7 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
11401138 }
11411139
11421140 O << " ." ;
1143- emitPTXAddressSpace (GVar ->getAddressSpace (), O);
1141+ emitPTXAddressSpace (PTy ->getAddressSpace (), O);
11441142
11451143 if (isManaged (*GVar)) {
11461144 if (STI.getPTXVersion () < 40 || STI.getSmVersion () < 30 ) {
@@ -1169,8 +1167,8 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
11691167 // Ptx allows variable initilization only for constant and global state
11701168 // spaces.
11711169 if (GVar->hasInitializer ()) {
1172- if ((GVar ->getAddressSpace () == ADDRESS_SPACE_GLOBAL) ||
1173- (GVar ->getAddressSpace () == ADDRESS_SPACE_CONST)) {
1170+ if ((PTy ->getAddressSpace () == ADDRESS_SPACE_GLOBAL) ||
1171+ (PTy ->getAddressSpace () == ADDRESS_SPACE_CONST)) {
11741172 const Constant *Initializer = GVar->getInitializer ();
11751173 // 'undef' is treated as there is no value specified.
11761174 if (!Initializer->isNullValue () && !isa<UndefValue>(Initializer)) {
@@ -1185,7 +1183,7 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
11851183 !isa<UndefValue>(GVar->getInitializer ())) {
11861184 report_fatal_error (" initial value of '" + GVar->getName () +
11871185 " ' is not allowed in addrspace(" +
1188- Twine (GVar ->getAddressSpace ()) + " )" );
1186+ Twine (PTy ->getAddressSpace ()) + " )" );
11891187 }
11901188 }
11911189 }
@@ -1204,8 +1202,8 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
12041202 ElementSize = DL.getTypeStoreSize (ETy);
12051203 // Ptx allows variable initilization only for constant and
12061204 // global state spaces.
1207- if (((GVar ->getAddressSpace () == ADDRESS_SPACE_GLOBAL) ||
1208- (GVar ->getAddressSpace () == ADDRESS_SPACE_CONST)) &&
1205+ if (((PTy ->getAddressSpace () == ADDRESS_SPACE_GLOBAL) ||
1206+ (PTy ->getAddressSpace () == ADDRESS_SPACE_CONST)) &&
12091207 GVar->hasInitializer ()) {
12101208 const Constant *Initializer = GVar->getInitializer ();
12111209 if (!isa<UndefValue>(Initializer) && !Initializer->isNullValue ()) {
0 commit comments