Skip to content

Commit a894cc9

Browse files
sys-igcigcbot
authored andcommitted
[Autobackout][FunctionalRegression]Revert of change: 7e12ced: Minor fixes and refactors
- replace dyn_cast with cast where no null-check. - null init structs - const auto & if possible - std::move if var goes out of scope - cast u32 to u64 to prevent overflow - emplace_back instead of ctor + push_back
1 parent 402f74e commit a894cc9

File tree

13 files changed

+41
-40
lines changed

13 files changed

+41
-40
lines changed

IGC/AdaptorOCL/preprocess_spvir/PromoteSubByte.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ Value *PromoteSubByte::convertI1ToI8(Value *value, IRBuilder<> &builder) {
125125

126126
auto zext = builder.CreateZExt(value, getOrCreatePromotedType(value->getType()));
127127
if (isa<Instruction>(zext) && isa<Instruction>(value)) {
128-
cast<Instruction>(zext)->setDebugLoc(cast<Instruction>(value)->getDebugLoc());
128+
dyn_cast<Instruction>(zext)->setDebugLoc(dyn_cast<Instruction>(value)->getDebugLoc());
129129
}
130130
return zext;
131131
}
@@ -142,16 +142,17 @@ Value *PromoteSubByte::convertI8ToI1(Value *value, IRBuilder<> &builder) {
142142

143143
auto trunc = builder.CreateTrunc(value, createDemotedType(value->getType()));
144144
if (isa<Instruction>(trunc) && isa<Instruction>(value)) {
145-
cast<Instruction>(trunc)->setDebugLoc(cast<Instruction>(value)->getDebugLoc());
145+
dyn_cast<Instruction>(trunc)->setDebugLoc(dyn_cast<Instruction>(value)->getDebugLoc());
146146
}
147147
return trunc;
148148
}
149149

150150
Value *PromoteSubByte::castAggregate(Value *value, Type *desiredType, IRBuilder<> &builder) {
151151

152152
if (auto *srcST = dyn_cast<StructType>(value->getType())) {
153-
auto *dstST = cast<StructType>(desiredType);
153+
auto *dstST = dyn_cast<StructType>(desiredType);
154154

155+
IGC_ASSERT(srcST && dstST);
155156
IGC_ASSERT(srcST->getNumElements() == dstST->getNumElements());
156157

157158
Value *Accum = PoisonValue::get(dstST);
@@ -168,8 +169,9 @@ Value *PromoteSubByte::castAggregate(Value *value, Type *desiredType, IRBuilder<
168169
}
169170

170171
if (auto *srcAT = dyn_cast<ArrayType>(value->getType())) {
171-
auto *dstAT = cast<ArrayType>(desiredType);
172+
auto *dstAT = dyn_cast<ArrayType>(desiredType);
172173

174+
IGC_ASSERT(srcAT && dstAT);
173175
IGC_ASSERT(srcAT->getNumElements() == dstAT->getNumElements());
174176

175177
auto *dstElType = dstAT->getElementType();
@@ -527,7 +529,7 @@ Function *PromoteSubByte::promoteFunction(Function *function) {
527529
}
528530
#endif
529531

530-
auto newFunction = Function::Create(cast<FunctionType>(getOrCreatePromotedType(function->getFunctionType())),
532+
auto newFunction = Function::Create(dyn_cast<FunctionType>(getOrCreatePromotedType(function->getFunctionType())),
531533
function->getLinkage(), function->getName() + ".promoted", function->getParent());
532534

533535
newFunction->setCallingConv(function->getCallingConv());
@@ -673,7 +675,7 @@ Constant *PromoteSubByte::promoteConstant(Constant *constant) {
673675
}
674676

675677
auto newType = getOrCreatePromotedType(constantArray->getType());
676-
return ConstantArray::get(cast<ArrayType>(newType), values);
678+
return ConstantArray::get(dyn_cast<ArrayType>(newType), values);
677679
} else if (auto constantStruct = dyn_cast<ConstantStruct>(constant)) {
678680
if (!typeNeedsPromotion(constantStruct->getType())) {
679681
return constant;
@@ -685,11 +687,11 @@ Constant *PromoteSubByte::promoteConstant(Constant *constant) {
685687
}
686688

687689
auto newType = getOrCreatePromotedType(constantStruct->getType());
688-
return ConstantStruct::get(cast<StructType>(newType), values);
690+
return ConstantStruct::get(dyn_cast<StructType>(newType), values);
689691
} else if (auto constantExpr = dyn_cast<ConstantExpr>(constant)) {
690692
if (constantExpr->isCast() && isa<GlobalValue>(constantExpr->getOperand(0))) {
691693
return ConstantExpr::getCast(constantExpr->getOpcode(),
692-
cast<Constant>(getOrCreatePromotedValue(constantExpr->getOperand(0))),
694+
dyn_cast<Constant>(getOrCreatePromotedValue(constantExpr->getOperand(0))),
693695
constantExpr->getType());
694696
}
695697
return constantExpr;
@@ -868,7 +870,7 @@ InlineAsm *PromoteSubByte::promoteInlineAsm(InlineAsm *inlineAsm) {
868870
return inlineAsm;
869871
}
870872

871-
return InlineAsm::get(cast<FunctionType>(getOrCreatePromotedType(inlineAsm->getFunctionType())),
873+
return InlineAsm::get(dyn_cast<FunctionType>(getOrCreatePromotedType(inlineAsm->getFunctionType())),
872874
inlineAsm->getAsmString(), inlineAsm->getConstraintString(), inlineAsm->hasSideEffects(),
873875
inlineAsm->isAlignStack(), inlineAsm->getDialect());
874876
}

IGC/Compiler/CISACodeGen/CISABuilder.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3283,19 +3283,19 @@ void CEncoder::AddVISASymbol(std::string &symName, CVariable *cvar) {
32833283
}
32843284

32853285
void CEncoder::SaveOption(vISAOptions option, bool val) {
3286-
OptionValue entry{};
3286+
OptionValue entry;
32873287
entry.type = OpType::ET_BOOL;
32883288
entry.vBool = val;
32893289
m_visaUserOptions.push_back(std::make_pair(option, entry));
32903290
}
32913291
void CEncoder::SaveOption(vISAOptions option, uint32_t val) {
3292-
OptionValue entry{};
3292+
OptionValue entry;
32933293
entry.type = OpType::ET_INT32;
32943294
entry.vInt32 = val;
32953295
m_visaUserOptions.push_back(std::make_pair(option, entry));
32963296
}
32973297
void CEncoder::SaveOption(vISAOptions option, const char *val) {
3298-
OptionValue entry{};
3298+
OptionValue entry;
32993299
entry.type = OpType::ET_CSTR;
33003300
entry.vCstr = val;
33013301
m_visaUserOptions.push_back(std::make_pair(option, entry));

IGC/Compiler/CISACodeGen/SinkCommonOffsetFromGEP.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ static std::vector<DivergentPointer> findDivergentPointers(BasicBlock *BB) {
209209
if (DP.Phi == nullptr)
210210
continue;
211211

212-
DivergentPointers.push_back(std::move(DP));
212+
DivergentPointers.push_back(DP);
213213
}
214214
return DivergentPointers;
215215
}
@@ -286,7 +286,7 @@ bool DivergentPointersGroups::createAddNewGroups(const DivergentPointer &DP) {
286286
Group.Casts[BB] = ASC;
287287
}
288288
Group.Successor = DP.Phi->getParent();
289-
PointerGroups.push_back(std::move(Group));
289+
PointerGroups.push_back(Group);
290290
return true;
291291
}
292292

IGC/Compiler/CodeGenContext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,8 @@ static bool isEntryPoint(const CodeGenContext *ctx, const llvm::Function *F) {
606606
return false;
607607
}
608608

609-
const auto &FuncMD = ctx->getModuleMetaData()->FuncMD;
610-
const auto &FuncInfo = FuncMD.find(const_cast<llvm::Function *>(F));
609+
auto &FuncMD = ctx->getModuleMetaData()->FuncMD;
610+
auto FuncInfo = FuncMD.find(const_cast<llvm::Function *>(F));
611611
if (FuncInfo == FuncMD.end()) {
612612
return false;
613613
}

IGC/Compiler/Optimizer/OpenCLPasses/GenericAddressResolution/GASRetValuePropagator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ void GASRetValuePropagator::updateMetadata(Function *oldFunc, Function *newFunc)
260260
if (loc != FuncMD.end()) {
261261
auto funcInfo = loc->second;
262262
FuncMD.erase(oldFunc);
263-
FuncMD[newFunc] = std::move(funcInfo);
263+
FuncMD[newFunc] = funcInfo;
264264
}
265265

266266
m_mdUtils->save(m_module->getContext());

IGC/DebugInfo/VISADebugDecoder.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -291,15 +291,15 @@ class DbgDecoder {
291291
for (unsigned int j = 0; j != count; j++) {
292292
uint32_t cisaOffset = read<uint32_t>(dbg);
293293
uint32_t genOffset = read<uint32_t>(dbg);
294-
f.CISAOffsetMap.emplace_back(cisaOffset, f.relocOffset + genOffset);
294+
f.CISAOffsetMap.push_back(std::make_pair(cisaOffset, f.relocOffset + genOffset));
295295
}
296296

297297
// cisa index map
298298
count = read<uint32_t>(dbg);
299299
for (unsigned int j = 0; j != count; j++) {
300300
uint32_t cisaIndex = read<uint32_t>(dbg);
301301
uint32_t genOffset = read<uint32_t>(dbg);
302-
f.CISAIndexMap.emplace_back(cisaIndex, f.relocOffset + genOffset);
302+
f.CISAIndexMap.push_back(std::make_pair(cisaIndex, f.relocOffset + genOffset));
303303
}
304304

305305
// var info
@@ -314,10 +314,10 @@ class DbgDecoder {
314314
auto countLRs = read<uint16_t>(dbg);
315315
for (unsigned int k = 0; k != countLRs; k++) {
316316
LiveIntervalsVISA lv = readLiveIntervalsVISA();
317-
v.lrs.push_back(std::move(lv));
317+
v.lrs.push_back(lv);
318318
}
319319

320-
f.Vars.push_back(std::move(v));
320+
f.Vars.push_back(v);
321321
}
322322

323323
// subroutines
@@ -335,7 +335,7 @@ class DbgDecoder {
335335
LiveIntervalsVISA lv = readLiveIntervalsVISA();
336336
sub.retval.push_back(lv);
337337
}
338-
f.subs.push_back(std::move(sub));
338+
f.subs.push_back(sub);
339339
}
340340

341341
// call frame information
@@ -346,23 +346,23 @@ class DbgDecoder {
346346
for (unsigned int j = 0; j != count; j++) {
347347
LiveIntervalGenISA lv = readLiveIntervalGenISA();
348348
;
349-
f.cfi.befp.push_back(std::move(lv));
349+
f.cfi.befp.push_back(lv);
350350
}
351351
}
352352
f.cfi.callerbefpValid = (bool)read<uint8_t>(dbg);
353353
if (f.cfi.callerbefpValid) {
354354
count = read<uint16_t>(dbg);
355355
for (unsigned int j = 0; j != count; j++) {
356356
LiveIntervalGenISA lv = readLiveIntervalGenISA();
357-
f.cfi.callerbefp.push_back(std::move(lv));
357+
f.cfi.callerbefp.push_back(lv);
358358
}
359359
}
360360
f.cfi.retAddrValid = (bool)read<uint8_t>(dbg);
361361
if (f.cfi.retAddrValid) {
362362
count = read<uint16_t>(dbg);
363363
for (unsigned int j = 0; j != count; j++) {
364364
LiveIntervalGenISA lv = readLiveIntervalGenISA();
365-
f.cfi.retAddr.push_back(std::move(lv));
365+
f.cfi.retAddr.push_back(lv);
366366
}
367367
}
368368
f.cfi.CEOffsetFromFPOff = read<uint16_t>(dbg);
@@ -374,7 +374,7 @@ class DbgDecoder {
374374
phyRegSave.numEntries = read<uint16_t>(dbg);
375375
for (unsigned int k = 0; k != phyRegSave.numEntries; k++)
376376
phyRegSave.data.push_back(readRegInfoMapping());
377-
f.cfi.calleeSaveEntry.push_back(std::move(phyRegSave));
377+
f.cfi.calleeSaveEntry.push_back(phyRegSave);
378378
}
379379

380380
f.cfi.numCallerSaveEntries = read<uint32_t>(dbg);
@@ -384,10 +384,10 @@ class DbgDecoder {
384384
phyRegSave.numEntries = read<uint16_t>(dbg);
385385
for (unsigned int k = 0; k != phyRegSave.numEntries; k++)
386386
phyRegSave.data.push_back(readRegInfoMapping());
387-
f.cfi.callerSaveEntry.push_back(std::move(phyRegSave));
387+
f.cfi.callerSaveEntry.push_back(phyRegSave);
388388
}
389389

390-
compiledObjs.push_back(std::move(f));
390+
compiledObjs.push_back(f);
391391
}
392392
}
393393

IGC/VISALinkerDriver/VLD.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ MoveEntryPointModuleToTheEnd(llvm::ArrayRef<IGC::VLD::SPVTranslationPair> InputM
189189
}
190190

191191
if (HasEntryPointModule) {
192-
RetPairs.push_back(std::move(EntryPointPair));
192+
RetPairs.push_back(EntryPointPair);
193193
}
194194

195195
return RetPairs;

IGC/common/IGCSPIRVParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ std::vector<std::string> SPIRVParser::getEntryPointNames(const StringRef binary)
3737
while (binary.data()[(offsetInWords + 3) * 4 + nameLength])
3838
nameLength++;
3939
std::string name = binary.substr((offsetInWords + 3) * 4, nameLength).str();
40-
entryPointNames.push_back(std::move(name));
40+
entryPointNames.push_back(name);
4141
}
4242
offsetInWords += opWordsCount; // skip instruction
4343
}

IGC/common/MDFrameWork.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ template <typename T> void readNode(std::vector<T> &vec, MDNode *node) {
325325
for (unsigned k = 1; k < node->getNumOperands(); k++) {
326326
T vecEle;
327327
readNode(vecEle, cast<MDNode>(node->getOperand(k)));
328-
vec.push_back(std::move(vecEle));
328+
vec.push_back(vecEle);
329329
}
330330
return;
331331
}
@@ -380,7 +380,7 @@ template <typename Key, typename Value> void readNode(std::map<Key, Value> &keyM
380380
std::pair<Key, Value> p;
381381
readNode(p.first, cast<MDNode>(node->getOperand(k++)));
382382
readNode(p.second, cast<MDNode>(node->getOperand(k)));
383-
keyMD.insert(std::move(p));
383+
keyMD.insert(p);
384384
}
385385
return;
386386
}
@@ -390,7 +390,7 @@ template <typename Key, typename Value> void readNode(MapVector<Key, Value> &key
390390
std::pair<Key, Value> p;
391391
readNode(p.first, cast<MDNode>(node->getOperand(k++)));
392392
readNode(p.second, cast<MDNode>(node->getOperand(k)));
393-
keyMD.insert(std::move(p));
393+
keyMD.insert(p);
394394
}
395395
return;
396396
}
@@ -399,7 +399,7 @@ template <typename Key> void readNode(std::set<Key> &keyMD, MDNode *node) {
399399
for (unsigned k = 1; k < node->getNumOperands(); k++) {
400400
Key key;
401401
readNode(key, cast<MDNode>(node->getOperand(k)));
402-
keyMD.insert(std::move(key));
402+
keyMD.insert(key);
403403
}
404404
return;
405405
}
@@ -408,7 +408,7 @@ template <typename Key> void readNode(SetVector<Key> &keyMD, MDNode *node) {
408408
for (unsigned k = 1; k < node->getNumOperands(); k++) {
409409
Key key;
410410
readNode(key, cast<MDNode>(node->getOperand(k)));
411-
keyMD.insert(std::move(key));
411+
keyMD.insert(key);
412412
}
413413
return;
414414
}

IGC/common/igc_regkeys.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ static void ParseEntryPoint(llvm::StringRef line, std::vector<EntryPoint> &entry
667667
auto [token, RHS] = vString.split(',');
668668
EntryPoint entry_point{};
669669
entry_point.entry_point_name = token.str();
670-
entry_points.push_back(std::move(entry_point));
670+
entry_points.push_back(entry_point);
671671
vString = RHS;
672672
} while (!vString.empty());
673673
}

0 commit comments

Comments
 (0)