Skip to content

Commit aa9226e

Browse files
authored
[NFC] Use auto * for pointer types (#2115)
Change `auto` to `auto *` when the type is a pointer. This makes the code comply with the clang-tidy `llvm-qualified-auto` check. That check is already enabled, but the code base wasn't fully compliant yet.
1 parent dcd3052 commit aa9226e

15 files changed

+305
-305
lines changed

lib/SPIRV/LLVMToSPIRVDbgTran.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,7 @@ SPIRVEntry *LLVMToSPIRVDbgTran::transDbgFunction(const DISubprogram *Func) {
12021202
Ops[SourceIdx] = getSource(Func)->getId();
12031203
Ops[LineIdx] = Func->getLine();
12041204
Ops[ColumnIdx] = 0; // This version of DISubprogram has no column number
1205-
auto Scope = Func->getScope();
1205+
auto *Scope = Func->getScope();
12061206
if (Scope && !isa<DIFile>(Scope)) {
12071207
Ops[ParentIdx] = getScope(Scope)->getId();
12081208
} else {

lib/SPIRV/OCLToSPIRV.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ bool OCLToSPIRVBase::runOCLToSPIRV(Module &Module) {
192192
// there are functions fall into both categories.
193193
void OCLToSPIRVBase::visitCallInst(CallInst &CI) {
194194
LLVM_DEBUG(dbgs() << "[visistCallInst] " << CI << '\n');
195-
auto F = CI.getCalledFunction();
195+
auto *F = CI.getCalledFunction();
196196
if (!F)
197197
return;
198198

@@ -227,7 +227,7 @@ void OCLToSPIRVBase::visitCallInst(CallInst &CI) {
227227
isComputeAtomicOCLBuiltin(DemangledName))
228228
return;
229229

230-
auto PCI = &CI;
230+
auto *PCI = &CI;
231231
if (DemangledName == kOCLBuiltinName::AtomicInit) {
232232
visitCallAtomicInit(PCI);
233233
return;
@@ -493,7 +493,7 @@ CallInst *OCLToSPIRVBase::visitCallAtomicCmpXchg(CallInst *CI) {
493493
}
494494

495495
void OCLToSPIRVBase::visitCallAtomicInit(CallInst *CI) {
496-
auto ST = new StoreInst(CI->getArgOperand(1), CI->getArgOperand(0), CI);
496+
auto *ST = new StoreInst(CI->getArgOperand(1), CI->getArgOperand(0), CI);
497497
ST->takeName(CI);
498498
CI->dropAllReferences();
499499
CI->eraseFromParent();
@@ -506,7 +506,7 @@ void OCLToSPIRVBase::visitCallAllAny(spv::Op OC, CallInst *CI) {
506506
assert(Args.size() == 1);
507507

508508
auto *ArgTy = Args[0]->getType();
509-
auto Zero = Constant::getNullValue(Args[0]->getType());
509+
auto *Zero = Constant::getNullValue(Args[0]->getType());
510510

511511
auto *Cmp = CmpInst::Create(CmpInst::ICmp, CmpInst::ICMP_SLT, Args[0], Zero,
512512
"cast", CI);
@@ -724,8 +724,8 @@ void OCLToSPIRVBase::visitCallConvert(CallInst *CI, StringRef MangledName,
724724
if (eraseUselessConvert(CI, MangledName, DemangledName))
725725
return;
726726
Op OC = OpNop;
727-
auto TargetTy = CI->getType();
728-
auto SrcTy = CI->getArgOperand(0)->getType();
727+
auto *TargetTy = CI->getType();
728+
auto *SrcTy = CI->getArgOperand(0)->getType();
729729
if (auto *VecTy = dyn_cast<VectorType>(TargetTy))
730730
TargetTy = VecTy->getElementType();
731731
if (auto *VecTy = dyn_cast<VectorType>(SrcTy))
@@ -768,7 +768,7 @@ void OCLToSPIRVBase::visitCallConvert(CallInst *CI, StringRef MangledName,
768768

769769
void OCLToSPIRVBase::visitCallGroupBuiltin(CallInst *CI,
770770
StringRef OrigDemangledName) {
771-
auto F = CI->getCalledFunction();
771+
auto *F = CI->getCalledFunction();
772772
std::vector<int> PreOps;
773773
std::string DemangledName{OrigDemangledName};
774774

@@ -811,7 +811,7 @@ void OCLToSPIRVBase::visitCallGroupBuiltin(CallInst *CI,
811811
(void)(GroupOp.consume_front("_")); // when op is two characters
812812
assert(!GroupOp.empty() && "Invalid OpenCL group builtin function");
813813
char OpTyC = 0;
814-
auto OpTy = F->getReturnType();
814+
auto *OpTy = F->getReturnType();
815815
if (OpTy->isFloatingPointTy())
816816
OpTyC = 'f';
817817
else if (OpTy->isIntegerTy()) {
@@ -1010,7 +1010,7 @@ void OCLToSPIRVBase::visitCallGetImageSize(CallInst *CI,
10101010
return NCI;
10111011
if (DemangledName == kOCLBuiltinName::GetImageDim) {
10121012
if (Desc.Dim == Dim3D) {
1013-
auto ZeroVec = ConstantVector::getSplat(
1013+
auto *ZeroVec = ConstantVector::getSplat(
10141014
ElementCount::getFixed(3),
10151015
Constant::getNullValue(
10161016
cast<VectorType>(NCI->getType())->getElementType()));
@@ -1040,8 +1040,8 @@ void OCLToSPIRVBase::visitCallGetImageSize(CallInst *CI,
10401040
/// Remove trivial conversion functions
10411041
bool OCLToSPIRVBase::eraseUselessConvert(CallInst *CI, StringRef MangledName,
10421042
StringRef DemangledName) {
1043-
auto TargetTy = CI->getType();
1044-
auto SrcTy = CI->getArgOperand(0)->getType();
1043+
auto *TargetTy = CI->getType();
1044+
auto *SrcTy = CI->getArgOperand(0)->getType();
10451045
if (auto *VecTy = dyn_cast<VectorType>(TargetTy))
10461046
TargetTy = VecTy->getElementType();
10471047
if (auto *VecTy = dyn_cast<VectorType>(SrcTy))
@@ -1109,7 +1109,7 @@ void OCLToSPIRVBase::visitCallToAddr(CallInst *CI, StringRef DemangledName) {
11091109
Info.UniqName = DemangledName.str();
11101110
Info.Postfix = std::string(kSPIRVPostfix::Divider) + "To" +
11111111
SPIRAddrSpaceCapitalizedNameMap::map(AddrSpace);
1112-
auto StorageClass = addInt32(SPIRSPIRVAddrSpaceMap::map(AddrSpace));
1112+
auto *StorageClass = addInt32(SPIRSPIRVAddrSpaceMap::map(AddrSpace));
11131113
Info.RetTy = getInt8PtrTy(cast<PointerType>(CI->getType()));
11141114
Info.PostProc = [=](BuiltinCallMutator &Mutator) {
11151115
Mutator
@@ -1537,7 +1537,7 @@ static const char *getSubgroupAVCIntelTyKind(StringRef MangledName) {
15371537
}
15381538

15391539
static Type *getSubgroupAVCIntelMCEType(Module *M, std::string &TName) {
1540-
auto Ty = StructType::getTypeByName(M->getContext(), TName);
1540+
auto *Ty = StructType::getTypeByName(M->getContext(), TName);
15411541
if (Ty)
15421542
return Ty;
15431543

lib/SPIRV/OCLTypeToSPIRV.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ void OCLTypeToSPIRVBase::adaptFunction(Function *F) {
141141
for (auto &U : I.uses()) {
142142
if (auto *CI = dyn_cast<CallInst>(U.getUser())) {
143143
auto ArgIndex = CI->getArgOperandNo(&U);
144-
auto CF = CI->getCalledFunction();
144+
auto *CF = CI->getCalledFunction();
145145
if (AdaptedTy.count(CF) == 0) {
146146
addAdaptedType(CF->getArg(ArgIndex), Ty);
147147
addWork(CF);
@@ -154,7 +154,7 @@ void OCLTypeToSPIRVBase::adaptFunction(Function *F) {
154154
if (!Changed)
155155
return;
156156

157-
auto FT = F->getFunctionType();
157+
auto *FT = F->getFunctionType();
158158
FT = FunctionType::get(FT->getReturnType(), ArgTys, FT->isVarArg());
159159
addAdaptedType(F, TypedPointerType::get(FT, 0));
160160
}
@@ -171,18 +171,18 @@ void OCLTypeToSPIRVBase::adaptArgumentsBySamplerUse(Module &M) {
171171
if (Processed.insert(F).second == false)
172172
return;
173173

174-
for (auto U : F->users()) {
174+
for (auto *U : F->users()) {
175175
auto *CI = dyn_cast<CallInst>(U);
176176
if (!CI)
177177
continue;
178178

179-
auto SamplerArg = CI->getArgOperand(Idx);
179+
auto *SamplerArg = CI->getArgOperand(Idx);
180180
if (!isa<Argument>(SamplerArg) ||
181181
AdaptedTy.count(SamplerArg) != 0) // Already traced this, move on.
182182
continue;
183183

184184
addAdaptedType(SamplerArg, getSPIRVType(OpTypeSampler));
185-
auto Caller = cast<Argument>(SamplerArg)->getParent();
185+
auto *Caller = cast<Argument>(SamplerArg)->getParent();
186186
addWork(Caller);
187187
TraceArg(Caller, cast<Argument>(SamplerArg)->getArgNo());
188188
}
@@ -203,11 +203,11 @@ void OCLTypeToSPIRVBase::adaptArgumentsBySamplerUse(Module &M) {
203203
}
204204

205205
void OCLTypeToSPIRVBase::adaptFunctionArguments(Function *F) {
206-
auto TypeMD = F->getMetadata(SPIR_MD_KERNEL_ARG_BASE_TYPE);
206+
auto *TypeMD = F->getMetadata(SPIR_MD_KERNEL_ARG_BASE_TYPE);
207207
if (TypeMD)
208208
return;
209209
bool Changed = false;
210-
auto Arg = F->arg_begin();
210+
auto *Arg = F->arg_begin();
211211
SmallVector<Type *, 4> ParamTys;
212212

213213
// If we couldn't get any information from demangling, there is nothing that
@@ -241,11 +241,11 @@ void OCLTypeToSPIRVBase::adaptFunctionArguments(Function *F) {
241241
/// types and use them to map the function arguments to the SPIR-V type.
242242
/// ToDo: Map other OpenCL opaque types to SPIR-V types.
243243
void OCLTypeToSPIRVBase::adaptArgumentsByMetadata(Function *F) {
244-
auto TypeMD = F->getMetadata(SPIR_MD_KERNEL_ARG_BASE_TYPE);
244+
auto *TypeMD = F->getMetadata(SPIR_MD_KERNEL_ARG_BASE_TYPE);
245245
if (!TypeMD)
246246
return;
247247
bool Changed = false;
248-
auto Arg = F->arg_begin();
248+
auto *Arg = F->arg_begin();
249249
for (unsigned I = 0, E = TypeMD->getNumOperands(); I != E; ++I, ++Arg) {
250250
auto OCLTyStr = getMDOperandAsString(TypeMD, I);
251251
if (OCLTyStr == OCL_TYPE_NAME_SAMPLER_T) {
@@ -256,7 +256,7 @@ void OCLTypeToSPIRVBase::adaptArgumentsByMetadata(Function *F) {
256256
if (auto *STy = StructType::getTypeByName(F->getContext(), Ty)) {
257257
auto *ImageTy = TypedPointerType::get(STy, SPIRAS_Global);
258258
auto Desc = getImageDescriptor(ImageTy);
259-
auto AccMD = F->getMetadata(SPIR_MD_KERNEL_ARG_ACCESS_QUAL);
259+
auto *AccMD = F->getMetadata(SPIR_MD_KERNEL_ARG_ACCESS_QUAL);
260260
assert(AccMD && "Invalid access qualifier metadata");
261261
auto Acc = SPIRSPIRVAccessQualifierMap::map(
262262
getMDOperandAsString(AccMD, I).str());

lib/SPIRV/OCLUtil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ unsigned getOCLVersion(Module *M, bool AllowMulti) {
791791
// If the module was linked with another module, there may be multiple
792792
// operands.
793793
auto GetVer = [=](unsigned I) {
794-
auto MD = NamedMD->getOperand(I);
794+
auto *MD = NamedMD->getOperand(I);
795795
return std::make_pair(getMDOperandAsInt(MD, 0), getMDOperandAsInt(MD, 1));
796796
};
797797
auto Ver = GetVer(0);

lib/SPIRV/SPIRVLowerBool.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,48 +59,48 @@ void SPIRVLowerBoolBase::replace(Instruction *I, Instruction *NewI) {
5959
bool SPIRVLowerBoolBase::isBoolType(Type *Ty) {
6060
if (Ty->isIntegerTy(1))
6161
return true;
62-
if (auto VT = dyn_cast<VectorType>(Ty))
62+
if (auto *VT = dyn_cast<VectorType>(Ty))
6363
return isBoolType(VT->getElementType());
6464
return false;
6565
}
6666

6767
void SPIRVLowerBoolBase::visitTruncInst(TruncInst &I) {
6868
if (isBoolType(I.getType())) {
69-
auto Op = I.getOperand(0);
70-
auto And = BinaryOperator::CreateAnd(
69+
auto *Op = I.getOperand(0);
70+
auto *And = BinaryOperator::CreateAnd(
7171
Op, getScalarOrVectorConstantInt(Op->getType(), 1, false), "", &I);
7272
And->setDebugLoc(I.getDebugLoc());
73-
auto Zero = getScalarOrVectorConstantInt(Op->getType(), 0, false);
74-
auto Cmp = new ICmpInst(&I, CmpInst::ICMP_NE, And, Zero);
73+
auto *Zero = getScalarOrVectorConstantInt(Op->getType(), 0, false);
74+
auto *Cmp = new ICmpInst(&I, CmpInst::ICMP_NE, And, Zero);
7575
replace(&I, Cmp);
7676
}
7777
}
7878

7979
void SPIRVLowerBoolBase::handleExtInstructions(Instruction &I) {
80-
auto Op = I.getOperand(0);
80+
auto *Op = I.getOperand(0);
8181
if (isBoolType(Op->getType())) {
8282
auto Opcode = I.getOpcode();
83-
auto Ty = I.getType();
84-
auto Zero = getScalarOrVectorConstantInt(Ty, 0, false);
85-
auto One = getScalarOrVectorConstantInt(
83+
auto *Ty = I.getType();
84+
auto *Zero = getScalarOrVectorConstantInt(Ty, 0, false);
85+
auto *One = getScalarOrVectorConstantInt(
8686
Ty, (Opcode == Instruction::SExt) ? ~0 : 1, false);
8787
assert(Zero && One && "Couldn't create constant int");
88-
auto Sel = SelectInst::Create(Op, One, Zero, "", &I);
88+
auto *Sel = SelectInst::Create(Op, One, Zero, "", &I);
8989
replace(&I, Sel);
9090
}
9191
}
9292

9393
void SPIRVLowerBoolBase::handleCastInstructions(Instruction &I) {
94-
auto Op = I.getOperand(0);
94+
auto *Op = I.getOperand(0);
9595
auto *OpTy = Op->getType();
9696
if (isBoolType(OpTy)) {
9797
Type *Ty = Type::getInt32Ty(*Context);
98-
if (auto VT = dyn_cast<FixedVectorType>(OpTy))
98+
if (auto *VT = dyn_cast<FixedVectorType>(OpTy))
9999
Ty = llvm::FixedVectorType::get(Ty, VT->getNumElements());
100-
auto Zero = getScalarOrVectorConstantInt(Ty, 0, false);
101-
auto One = getScalarOrVectorConstantInt(Ty, 1, false);
100+
auto *Zero = getScalarOrVectorConstantInt(Ty, 0, false);
101+
auto *One = getScalarOrVectorConstantInt(Ty, 1, false);
102102
assert(Zero && One && "Couldn't create constant int");
103-
auto Sel = SelectInst::Create(Op, One, Zero, "", &I);
103+
auto *Sel = SelectInst::Create(Op, One, Zero, "", &I);
104104
Sel->setDebugLoc(I.getDebugLoc());
105105
I.setOperand(0, Sel);
106106
}

lib/SPIRV/SPIRVLowerConstExpr.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,22 +115,22 @@ bool SPIRVLowerConstExprBase::visit(Module *M) {
115115
}
116116
auto FBegin = I.begin();
117117
while (!WorkList.empty()) {
118-
auto II = WorkList.front();
118+
auto *II = WorkList.front();
119119

120120
auto LowerOp = [&II, &FBegin, &I, &Changed](Value *V) -> Value * {
121121
if (isa<Function>(V))
122122
return V;
123123
auto *CE = cast<ConstantExpr>(V);
124124
SPIRVDBG(dbgs() << "[lowerConstantExpressions] " << *CE;)
125-
auto ReplInst = CE->getAsInstruction();
126-
auto InsPoint = II->getParent() == &*FBegin ? II : &FBegin->back();
125+
auto *ReplInst = CE->getAsInstruction();
126+
auto *InsPoint = II->getParent() == &*FBegin ? II : &FBegin->back();
127127
ReplInst->insertBefore(InsPoint);
128128
SPIRVDBG(dbgs() << " -> " << *ReplInst << '\n';)
129129
std::vector<Instruction *> Users;
130130
// Do not replace use during iteration of use. Do it in another loop
131-
for (auto U : CE->users()) {
131+
for (auto *U : CE->users()) {
132132
SPIRVDBG(dbgs() << "[lowerConstantExpressions] Use: " << *U << '\n';)
133-
if (auto InstUser = dyn_cast<Instruction>(U)) {
133+
if (auto *InstUser = dyn_cast<Instruction>(U)) {
134134
// Only replace users in scope of current function
135135
if (InstUser->getParent()->getParent() == &I)
136136
Users.push_back(InstUser);
@@ -152,9 +152,9 @@ bool SPIRVLowerConstExprBase::visit(Module *M) {
152152
auto *Op = II->getOperand(OI);
153153
if (auto *CE = dyn_cast<ConstantExpr>(Op)) {
154154
WorkList.push_front(cast<Instruction>(LowerOp(CE)));
155-
} else if (auto MDAsVal = dyn_cast<MetadataAsValue>(Op)) {
155+
} else if (auto *MDAsVal = dyn_cast<MetadataAsValue>(Op)) {
156156
Metadata *MD = MDAsVal->getMetadata();
157-
if (auto ConstMD = dyn_cast<ConstantAsMetadata>(MD)) {
157+
if (auto *ConstMD = dyn_cast<ConstantAsMetadata>(MD)) {
158158
Constant *C = ConstMD->getValue();
159159
Value *ReplInst = nullptr;
160160
if (auto *CE = dyn_cast<ConstantExpr>(C))

0 commit comments

Comments
 (0)