Skip to content

Commit ac0fc8e

Browse files
authored
Prevent unnecessary copies. (#2859)
1 parent 6768532 commit ac0fc8e

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

lib/SPIRV/SPIRVReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3220,7 +3220,7 @@ Function *SPIRVToLLVM::transFunction(SPIRVFunction *BF, unsigned AS) {
32203220
// search for a previous function with the same name
32213221
// upgrade it to a kernel and drop this if it's found
32223222
for (auto &I : FuncMap) {
3223-
auto BFName = I.getFirst()->getName();
3223+
const auto &BFName = I.getFirst()->getName();
32243224
if (BF->getName() == BFName) {
32253225
auto *F = I.getSecond();
32263226
F->setCallingConv(CallingConv::SPIR_KERNEL);

lib/SPIRV/SPIRVWriter.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,8 @@ SPIRVValue *LLVMToSPIRVBase::transConstantUse(Constant *C,
13381338
Ops = getVec(PtrTy->getId(), Ops);
13391339
}
13401340
}
1341-
return BM->addPtrAccessChainInst(ExpectedType, Ops, nullptr, true);
1341+
return BM->addPtrAccessChainInst(ExpectedType, std::move(Ops), nullptr,
1342+
true);
13421343
}
13431344
}
13441345

@@ -1470,7 +1471,7 @@ SPIRVValue *LLVMToSPIRVBase::transConstant(Value *V) {
14701471
Ops = getVec(PtrTy->getId(), Ops);
14711472
}
14721473
}
1473-
return BM->addPtrAccessChainInst(TranslatedTy, Ops, nullptr,
1474+
return BM->addPtrAccessChainInst(TranslatedTy, std::move(Ops), nullptr,
14741475
GEP->isInBounds());
14751476
}
14761477
auto *Inst = ConstUE->getAsInstruction();
@@ -2569,8 +2570,8 @@ LLVMToSPIRVBase::transValueWithoutDecoration(Value *V, SPIRVBasicBlock *BB,
25692570
// access chain instructions. Replace return type to do that.
25702571
TranslatedTy = SPVPointerOperand->getType();
25712572

2572-
return mapValue(
2573-
V, BM->addPtrAccessChainInst(TranslatedTy, Ops, BB, GEP->isInBounds()));
2573+
return mapValue(V, BM->addPtrAccessChainInst(TranslatedTy, std::move(Ops),
2574+
BB, GEP->isInBounds()));
25742575
}
25752576

25762577
if (auto *Ext = dyn_cast<ExtractElementInst>(V)) {
@@ -4320,7 +4321,7 @@ SPIRVValue *LLVMToSPIRVBase::transIntrinsicInst(IntrinsicInst *II,
43204321
Zero = BM->addConstant(ResTy, 0);
43214322
APInt MinusOneValue(ResTy->getIntegerBitWidth(), 0, 1);
43224323
MinusOneValue.setAllBits();
4323-
MinusOne = BM->addConstant(ResTy, MinusOneValue);
4324+
MinusOne = BM->addConstant(ResTy, std::move(MinusOneValue));
43244325
}
43254326

43264327
Op OC1 = (IID == Intrinsic::scmp) ? OpSLessThanEqual : OpULessThanEqual;

0 commit comments

Comments
 (0)