Skip to content

Commit f7be370

Browse files
committed
address comments
1 parent 2779670 commit f7be370

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -635,23 +635,23 @@ static bool usedInGlobalVarDef(const Constant *C) {
635635
return false;
636636
}
637637

638-
static bool usedInOneFunc(const User *U, Function const *&oneFunc) {
639-
if (const GlobalVariable *othergv = dyn_cast<GlobalVariable>(U))
640-
if (othergv->getName() == "llvm.used")
638+
static bool usedInOneFunc(const User *U, Function const *&OneFunc) {
639+
if (const GlobalVariable *OtherGV = dyn_cast<GlobalVariable>(U))
640+
if (OtherGV->getName() == "llvm.used")
641641
return true;
642642

643643
if (const Instruction *I = dyn_cast<Instruction>(U)) {
644644
if (const Function *CurFunc = I->getFunction()) {
645-
if (oneFunc && (CurFunc != oneFunc))
645+
if (OneFunc && (CurFunc != OneFunc))
646646
return false;
647-
oneFunc = CurFunc;
647+
OneFunc = CurFunc;
648648
return true;
649649
}
650650
return false;
651651
}
652652

653653
for (const User *UU : U->users())
654-
if (!usedInOneFunc(UU, oneFunc))
654+
if (!usedInOneFunc(UU, OneFunc))
655655
return false;
656656

657657
return true;
@@ -806,7 +806,7 @@ void NVPTXAsmPrinter::emitGlobals(const Module &M) {
806806

807807
// Print out module-level global variables in proper order
808808
for (const GlobalVariable *GV : Globals)
809-
printModuleLevelGV(GV, OS2, /*processDemoted=*/false, STI);
809+
printModuleLevelGV(GV, OS2, /*ProcessDemoted=*/false, STI);
810810

811811
OS2 << '\n';
812812

@@ -827,15 +827,14 @@ void NVPTXAsmPrinter::emitGlobalAlias(const Module &M, const GlobalAlias &GA) {
827827

828828
void NVPTXAsmPrinter::emitHeader(Module &M, raw_ostream &O,
829829
const NVPTXSubtarget &STI) {
830-
O << "//\n"
831-
<< "// Generated by LLVM NVPTX Back-End\n"
832-
<< "//\n"
833-
<< "\n";
830+
const unsigned PTXVersion = STI.getPTXVersion();
834831

835-
unsigned PTXVersion = STI.getPTXVersion();
836-
O << ".version " << (PTXVersion / 10) << "." << (PTXVersion % 10) << "\n";
837-
838-
O << ".target " << STI.getTargetName();
832+
O << "//\n"
833+
"// Generated by LLVM NVPTX Back-End\n"
834+
"//\n"
835+
"\n"
836+
<< ".version " << (PTXVersion / 10) << "." << (PTXVersion % 10) << "\n"
837+
<< ".target " << STI.getTargetName();
839838

840839
const NVPTXTargetMachine &NTM = static_cast<const NVPTXTargetMachine &>(TM);
841840
if (NTM.getDrvInterface() == NVPTX::NVCL)
@@ -860,7 +859,6 @@ void NVPTXAsmPrinter::emitHeader(Module &M, raw_ostream &O,
860859

861860
O << "\n"
862861
<< ".address_size " << (NTM.is64Bit() ? "64" : "32") << "\n"
863-
864862
<< "\n";
865863
}
866864

@@ -910,9 +908,7 @@ void NVPTXAsmPrinter::emitLinkageDirective(const GlobalValue *V,
910908
if (static_cast<NVPTXTargetMachine &>(TM).getDrvInterface() == NVPTX::CUDA) {
911909
if (V->hasExternalLinkage()) {
912910
if (const auto *GVar = dyn_cast<GlobalVariable>(V))
913-
914911
O << (GVar->hasInitializer() ? ".visible " : ".extern ");
915-
916912
else if (V->isDeclaration())
917913
O << ".extern ";
918914
else
@@ -927,7 +923,7 @@ void NVPTXAsmPrinter::emitLinkageDirective(const GlobalValue *V,
927923
}
928924

929925
void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
930-
raw_ostream &O, bool processDemoted,
926+
raw_ostream &O, bool ProcessDemoted,
931927
const NVPTXSubtarget &STI) {
932928
// Skip meta data
933929
if (GVar->hasSection())
@@ -1050,7 +1046,7 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
10501046
}
10511047

10521048
const Function *DemotedFunc = nullptr;
1053-
if (!processDemoted && canDemoteGlobalVar(GVar, DemotedFunc)) {
1049+
if (!ProcessDemoted && canDemoteGlobalVar(GVar, DemotedFunc)) {
10541050
O << "// " << GVar->getName() << " has been demoted\n";
10551051
localDecls[DemotedFunc].push_back(GVar);
10561052
return;
@@ -1536,15 +1532,15 @@ void NVPTXAsmPrinter::emitFunctionParamList(const Function *F, raw_ostream &O) {
15361532
}
15371533
// Non-kernel function, just print .param .b<size> for ABI
15381534
// and .reg .b<size> for non-ABI
1539-
unsigned sz;
1535+
unsigned Size;
15401536
if (auto *ITy = dyn_cast<IntegerType>(Ty)) {
1541-
sz = promoteScalarArgumentSize(ITy->getBitWidth());
1537+
Size = promoteScalarArgumentSize(ITy->getBitWidth());
15421538
} else if (PTy) {
15431539
assert(PTySizeInBits && "Invalid pointer size");
1544-
sz = PTySizeInBits;
1540+
Size = PTySizeInBits;
15451541
} else
1546-
sz = Ty->getPrimitiveSizeInBits();
1547-
O << "\t.param .b" << sz << " " << ParamSym;
1542+
Size = Ty->getPrimitiveSizeInBits();
1543+
O << "\t.param .b" << Size << " " << ParamSym;
15481544
}
15491545

15501546
if (F->isVarArg()) {

0 commit comments

Comments
 (0)