@@ -1019,16 +1019,14 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
1019
1019
const DataLayout &DL = getDataLayout ();
1020
1020
1021
1021
// GlobalVariables are always constant pointers themselves.
1022
+ PointerType *PTy = GVar->getType ();
1022
1023
Type *ETy = GVar->getValueType ();
1023
1024
1024
1025
if (GVar->hasExternalLinkage ()) {
1025
1026
if (GVar->hasInitializer ())
1026
1027
O << " .visible " ;
1027
1028
else
1028
1029
O << " .extern " ;
1029
- } else if (GVar->hasCommonLinkage () &&
1030
- GVar->getAddressSpace () == ADDRESS_SPACE_GLOBAL) {
1031
- O << " .common " ;
1032
1030
} else if (GVar->hasLinkOnceLinkage () || GVar->hasWeakLinkage () ||
1033
1031
GVar->hasAvailableExternallyLinkage () ||
1034
1032
GVar->hasCommonLinkage ()) {
@@ -1140,7 +1138,7 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
1140
1138
}
1141
1139
1142
1140
O << " ." ;
1143
- emitPTXAddressSpace (GVar ->getAddressSpace (), O);
1141
+ emitPTXAddressSpace (PTy ->getAddressSpace (), O);
1144
1142
1145
1143
if (isManaged (*GVar)) {
1146
1144
if (STI.getPTXVersion () < 40 || STI.getSmVersion () < 30 ) {
@@ -1169,8 +1167,8 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
1169
1167
// Ptx allows variable initilization only for constant and global state
1170
1168
// spaces.
1171
1169
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)) {
1174
1172
const Constant *Initializer = GVar->getInitializer ();
1175
1173
// 'undef' is treated as there is no value specified.
1176
1174
if (!Initializer->isNullValue () && !isa<UndefValue>(Initializer)) {
@@ -1185,7 +1183,7 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
1185
1183
!isa<UndefValue>(GVar->getInitializer ())) {
1186
1184
report_fatal_error (" initial value of '" + GVar->getName () +
1187
1185
" ' is not allowed in addrspace(" +
1188
- Twine (GVar ->getAddressSpace ()) + " )" );
1186
+ Twine (PTy ->getAddressSpace ()) + " )" );
1189
1187
}
1190
1188
}
1191
1189
}
@@ -1204,8 +1202,8 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
1204
1202
ElementSize = DL.getTypeStoreSize (ETy);
1205
1203
// Ptx allows variable initilization only for constant and
1206
1204
// 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)) &&
1209
1207
GVar->hasInitializer ()) {
1210
1208
const Constant *Initializer = GVar->getInitializer ();
1211
1209
if (!isa<UndefValue>(Initializer) && !Initializer->isNullValue ()) {
0 commit comments