Make llvm-16.0 Chromium build warning free Fix compiler warnings that occur in Chromium build when llvm-16.0 is used. Change-Id: If2e06cea852883d1c33dac6b3ddf31fda5da0ad9 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/75928 Kokoro-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@google.com> Reviewed-by: Geoff Lang <geofflang@google.com> Tested-by: Shahbaz Youssefi <syoussefi@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@google.com>
diff --git a/third_party/llvm-16.0/llvm/lib/Analysis/CallGraph.cpp b/third_party/llvm-16.0/llvm/lib/Analysis/CallGraph.cpp index 58ccf2b..a8134b7 100644 --- a/third_party/llvm-16.0/llvm/lib/Analysis/CallGraph.cpp +++ b/third_party/llvm-16.0/llvm/lib/Analysis/CallGraph.cpp
@@ -105,7 +105,7 @@ Node->addCalledFunction(Call, getOrInsertFunction(Callee)); // Add reference to callback functions. - forEachCallbackFunction(*Call, [=](Function *CB) { + forEachCallbackFunction(*Call, [=, this](Function *CB) { Node->addCalledFunction(nullptr, getOrInsertFunction(CB)); }); } @@ -215,7 +215,7 @@ CalledFunctions.pop_back(); // Remove all references to callback functions if there are any. - forEachCallbackFunction(Call, [=](Function *CB) { + forEachCallbackFunction(Call, [=, this](Function *CB) { removeOneAbstractEdgeTo(CG->getOrInsertFunction(CB)); }); return;
diff --git a/third_party/llvm-16.0/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp b/third_party/llvm-16.0/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp index af4bb16..0562d71 100644 --- a/third_party/llvm-16.0/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp +++ b/third_party/llvm-16.0/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
@@ -2223,7 +2223,7 @@ if (!mi_match(Src, MRI, m_GFNeg(m_Reg(NegSrc)))) return false; - MatchInfo = [=, &MI](MachineIRBuilder &B) { + MatchInfo = [=, this, &MI](MachineIRBuilder &B) { Observer.changingInstr(MI); MI.getOperand(1).setReg(NegSrc); Observer.changedInstr(MI); @@ -2863,7 +2863,7 @@ m_GAnd(m_GAnd(m_Reg(R), m_ICst(C1)), m_ICst(C2)))) return false; - MatchInfo = [=](MachineIRBuilder &B) { + MatchInfo = [=, this](MachineIRBuilder &B) { if (C1 & C2) { B.buildAnd(Dst, R, B.buildConstant(Ty, C1 & C2)); return; @@ -3602,7 +3602,7 @@ !Fast) return false; - MatchInfo = [=](MachineIRBuilder &MIB) { + MatchInfo = [=, this](MachineIRBuilder &MIB) { MIB.setInstrAndDebugLoc(*LatestLoad); Register LoadDst = NeedsBSwap ? MRI.cloneVirtualRegister(Dst) : Dst; MIB.buildLoad(LoadDst, Ptr, *NewMMO); @@ -4327,7 +4327,7 @@ if (AndMaskBits & OrMaskBits) return false; - MatchInfo = [=, &MI](MachineIRBuilder &B) { + MatchInfo = [=, this, &MI](MachineIRBuilder &B) { Observer.changingInstr(MI); // Canonicalize the result to have the constant on the RHS. if (MI.getOperand(1).getReg() == AndMaskReg) @@ -4590,7 +4590,7 @@ if (!C2) return false; - MatchInfo = [=, &MI](MachineIRBuilder &B) { + MatchInfo = [=, this, &MI](MachineIRBuilder &B) { LLT PtrTy = MRI.getType(MI.getOperand(0).getReg()); auto NewBase = @@ -4616,7 +4616,7 @@ return false; auto *LHSPtrAdd = cast<GPtrAdd>(LHS); - MatchInfo = [=, &MI](MachineIRBuilder &B) { + MatchInfo = [=, this, &MI](MachineIRBuilder &B) { // When we change LHSPtrAdd's offset register we might cause it to use a reg // before its def. Sink the instruction so the outer PTR_ADD to ensure this // doesn't happen. @@ -4653,7 +4653,7 @@ if (!C2) return false; - MatchInfo = [=, &MI](MachineIRBuilder &B) { + MatchInfo = [=, this, &MI](MachineIRBuilder &B) { auto NewCst = B.buildConstant(MRI.getType(Src2Reg), *C1 + *C2); Observer.changingInstr(MI); MI.getOperand(1).setReg(LHSSrc1); @@ -4784,7 +4784,7 @@ return false; Register BinOpLHS = LHSInst->getOperand(1).getReg(); Register BinOpRHS = LHSInst->getOperand(2).getReg(); - MatchInfo = [=, &MI](MachineIRBuilder &B) { + MatchInfo = [=, this, &MI](MachineIRBuilder &B) { auto NarrowLHS = Builder.buildTrunc(NarrowTy, BinOpLHS); auto NarrowRHS = Builder.buildTrunc(NarrowTy, BinOpRHS); auto NarrowBinOp = @@ -4804,7 +4804,7 @@ if (!mi_match(MI.getOperand(3).getReg(), MRI, m_SpecificICstOrSplat(2))) return false; - MatchInfo = [=, &MI](MachineIRBuilder &B) { + MatchInfo = [=, this, &MI](MachineIRBuilder &B) { Observer.changingInstr(MI); unsigned NewOpc = Opc == TargetOpcode::G_UMULO ? TargetOpcode::G_UADDO : TargetOpcode::G_SADDO; @@ -4918,7 +4918,7 @@ mi_match(Y, MRI, m_SpecificICstOrSplat(CstX)))) ReplaceReg = Z; if (ReplaceReg) { - MatchInfo = [=](MachineIRBuilder &B) { + MatchInfo = [=, this](MachineIRBuilder &B) { auto Zero = B.buildConstant(MRI.getType(Dst), 0); B.buildSub(Dst, Zero, ReplaceReg); }; @@ -5252,7 +5252,7 @@ } else return false; - MatchInfo = [=, &MI](MachineIRBuilder &B) { + MatchInfo = [=, this, &MI](MachineIRBuilder &B) { Observer.changingInstr(MI); MI.setDesc(B.getTII().get(Opc)); MI.getOperand(1).setReg(X); @@ -5503,7 +5503,7 @@ Register U = FMulMI->getOperand(1).getReg(); Register V = FMulMI->getOperand(2).getReg(); - MatchInfo = [=, &MI](MachineIRBuilder &B) { + MatchInfo = [=, this, &MI](MachineIRBuilder &B) { Register InnerFMA = MRI.createGenericVirtualRegister(DstTy); B.buildInstr(PreferredFusedOpcode, {InnerFMA}, {U, V, Z}); B.buildInstr(PreferredFusedOpcode, {MI.getOperand(0).getReg()}, @@ -5824,7 +5824,7 @@ isContractableFMul(*FMulMI, AllowFusionGlobally) && TLI.isFPExtFoldable(MI, PreferredFusedOpcode, DstTy, MRI.getType(FMulMI->getOperand(0).getReg()))) { - MatchInfo = [=, &MI](MachineIRBuilder &B) { + MatchInfo = [=, this, &MI](MachineIRBuilder &B) { Register FMAReg = MRI.createGenericVirtualRegister(DstTy); buildMatchInfo(FMAReg, FMulMI->getOperand(1).getReg(), FMulMI->getOperand(2).getReg(), RHSReg, B); @@ -6178,7 +6178,7 @@ return false; Y = X == OpLHS ? OpRHS : X == OpRHS ? OpLHS : Register(); } - MatchInfo = [=](MachineIRBuilder &B) { + MatchInfo = [=, this](MachineIRBuilder &B) { auto Zero = B.buildConstant(MRI.getType(Y), 0); B.buildICmp(Pred, Dst, Y, Zero); };
diff --git a/third_party/llvm-16.0/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp b/third_party/llvm-16.0/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp index f780050..d172a08 100644 --- a/third_party/llvm-16.0/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp +++ b/third_party/llvm-16.0/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
@@ -91,7 +91,7 @@ InstructionSelector *ISel = MF.getSubtarget().getInstructionSelector(); CodeGenOpt::Level OldOptLevel = OptLevel; - auto RestoreOptLevel = make_scope_exit([=]() { OptLevel = OldOptLevel; }); + auto RestoreOptLevel = make_scope_exit([=, this]() { OptLevel = OldOptLevel; }); OptLevel = MF.getFunction().hasOptNone() ? CodeGenOpt::None : MF.getTarget().getOptLevel();
diff --git a/third_party/llvm-16.0/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp b/third_party/llvm-16.0/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp index 8a1fce2..515455a 100644 --- a/third_party/llvm-16.0/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp +++ b/third_party/llvm-16.0/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
@@ -4080,7 +4080,7 @@ // handled. bool isBigEndian = MIRBuilder.getDataLayout().isBigEndian(); auto MMO = LdStMI.getMMO(); - auto splitTypePieces = [=](LLT PartTy, SmallVectorImpl<Register> &ValRegs, + auto splitTypePieces = [=, this](LLT PartTy, SmallVectorImpl<Register> &ValRegs, unsigned NumParts, unsigned Offset) -> unsigned { MachineFunction &MF = MIRBuilder.getMF(); unsigned PartSize = PartTy.getSizeInBits();
diff --git a/third_party/llvm-16.0/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/third_party/llvm-16.0/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp index c199e01..2df572e 100644 --- a/third_party/llvm-16.0/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp +++ b/third_party/llvm-16.0/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -71,7 +71,7 @@ DWARFDataExtractor Data(Obj, Section, LE, 0); // Lazy initialization of Parser, now that we have all section info. if (!Parser) { - Parser = [=, &Context, &Obj, &Section, &SOS, + Parser = [=, this, &Context, &Obj, &Section, &SOS, &LS](uint64_t Offset, DWARFSectionKind SectionKind, const DWARFSection *CurSection, const DWARFUnitIndex::Entry *IndexEntry)
diff --git a/third_party/llvm-16.0/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/third_party/llvm-16.0/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp index 8a4ed30..a93a821 100644 --- a/third_party/llvm-16.0/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp +++ b/third_party/llvm-16.0/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -1023,7 +1023,7 @@ } OutlineInfo OI; - OI.PostOutlineCB = [=](Function &OutlinedFn) { + OI.PostOutlineCB = [=, this](Function &OutlinedFn) { // Add some known attributes. OutlinedFn.addParamAttr(0, Attribute::NoAlias); OutlinedFn.addParamAttr(1, Attribute::NoAlias); @@ -2088,7 +2088,7 @@ Value *TripCount = Builder.CreateSelect(ZeroCmp, Zero, CountIfLooping, "omp_" + Name + ".tripcount"); - auto BodyGen = [=](InsertPointTy CodeGenIP, Value *IV) { + auto BodyGen = [=, this](InsertPointTy CodeGenIP, Value *IV) { Builder.restoreIP(CodeGenIP); Value *Span = Builder.CreateMul(IV, Step); Value *IndVar = Builder.CreateAdd(Span, Start);
diff --git a/third_party/llvm-16.0/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/third_party/llvm-16.0/llvm/lib/Transforms/IPO/AttributorAttributes.cpp index 42158e4..13919cc 100644 --- a/third_party/llvm-16.0/llvm/lib/Transforms/IPO/AttributorAttributes.cpp +++ b/third_party/llvm-16.0/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -7500,7 +7500,7 @@ // beginning and initialized with the values passed through arguments. The // new alloca replaces the use of the old pointer argument. Attributor::ArgumentReplacementInfo::CalleeRepairCBTy FnRepairCB = - [=](const Attributor::ArgumentReplacementInfo &ARI, + [=, this](const Attributor::ArgumentReplacementInfo &ARI, Function &ReplacementFn, Function::arg_iterator ArgIt) { BasicBlock &EntryBB = ReplacementFn.getEntryBlock(); Instruction *IP = &*EntryBB.getFirstInsertionPt(); @@ -7524,7 +7524,7 @@ // of the privatizable type are loaded prior to the call and passed to the // new function version. Attributor::ArgumentReplacementInfo::ACSRepairCBTy ACSRepairCB = - [=, &AlignAA](const Attributor::ArgumentReplacementInfo &ARI, + [=, this, &AlignAA](const Attributor::ArgumentReplacementInfo &ARI, AbstractCallSite ACS, SmallVectorImpl<Value *> &NewArgOperands) { // When no alignment is specified for the load instruction,
diff --git a/third_party/llvm-16.0/llvm/lib/Transforms/Scalar/GVNSink.cpp b/third_party/llvm-16.0/llvm/lib/Transforms/Scalar/GVNSink.cpp index 5fb8a77..d1967d2 100644 --- a/third_party/llvm-16.0/llvm/lib/Transforms/Scalar/GVNSink.cpp +++ b/third_party/llvm-16.0/llvm/lib/Transforms/Scalar/GVNSink.cpp
@@ -504,7 +504,7 @@ uint32_t e = ExpressionNumbering[exp]; if (!e) { - hash_code H = exp->getHashValue([=](Value *V) { return lookupOrAdd(V); }); + hash_code H = exp->getHashValue([=, this](Value *V) { return lookupOrAdd(V); }); auto I = HashNumbering.find(H); if (I != HashNumbering.end()) { e = I->second;
diff --git a/third_party/llvm-16.0/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/third_party/llvm-16.0/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 148f2c5..a874b05 100644 --- a/third_party/llvm-16.0/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/third_party/llvm-16.0/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -8262,7 +8262,7 @@ // can be optimized. auto isOptimizableIVTruncate = [&](Instruction *K) -> std::function<bool(ElementCount)> { - return [=](ElementCount VF) -> bool { + return [=, this](ElementCount VF) -> bool { return CM.isOptimizableIVTruncate(K, VF); }; };
diff --git a/third_party/llvm-16.0/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/third_party/llvm-16.0/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index e3eb6b1..6cb58f4 100644 --- a/third_party/llvm-16.0/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/third_party/llvm-16.0/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -6615,7 +6615,7 @@ bool NeedToShuffleReuses = !E->ReuseShuffleIndices.empty(); // FIXME: it tries to fix a problem with MSVC buildbots. TargetTransformInfo *TTI = this->TTI; - auto AdjustExtractsCost = [=](InstructionCost &Cost) { + auto AdjustExtractsCost = [=, this](InstructionCost &Cost) { // If the resulting type is scalarized, do not adjust the cost. unsigned VecNumParts = TTI->getNumberOfParts(VecTy); if (VecNumParts == VecTy->getNumElements()) @@ -6930,7 +6930,7 @@ E->isAltShuffle() ? (unsigned)Instruction::ShuffleVector : E->getOpcode(); const unsigned Sz = VL.size(); auto GetCostDiff = - [=](function_ref<InstructionCost(unsigned)> ScalarEltCost, + [=, this](function_ref<InstructionCost(unsigned)> ScalarEltCost, function_ref<InstructionCost(InstructionCost)> VectorCost) { // Calculate the cost of this instruction. InstructionCost ScalarCost = 0; @@ -7179,7 +7179,7 @@ VI->getOperand(0)->getType(), TTI::getCastContextHint(VI), CostKind, VI); }; - auto GetVectorCost = [=](InstructionCost CommonCost) { + auto GetVectorCost = [=, this](InstructionCost CommonCost) { Type *SrcTy = VL0->getOperand(0)->getType(); auto *SrcVecTy = FixedVectorType::get(SrcTy, VL.size()); InstructionCost VecCost = CommonCost; @@ -7275,7 +7275,7 @@ return TTI->getArithmeticInstrCost(ShuffleOrOp, ScalarTy, CostKind, Op1Info, Op2Info, Operands, VI); }; - auto GetVectorCost = [=](InstructionCost CommonCost) { + auto GetVectorCost = [=, this](InstructionCost CommonCost) { unsigned OpIdx = isa<UnaryOperator>(VL0) ? 0 : 1; TTI::OperandValueInfo Op1Info = getOperandInfo(VL, 0); TTI::OperandValueInfo Op2Info = getOperandInfo(VL, OpIdx); @@ -7329,7 +7329,7 @@ } case Instruction::Store: { bool IsReorder = !E->ReorderIndices.empty(); - auto GetScalarCost = [=](unsigned Idx) { + auto GetScalarCost = [=, this](unsigned Idx) { auto *VI = cast<StoreInst>(VL[Idx]); TTI::OperandValueInfo OpInfo = getOperandInfo(VI, 0); return TTI->getMemoryOpCost(Instruction::Store, ScalarTy, VI->getAlign(), @@ -7338,7 +7338,7 @@ }; auto *BaseSI = cast<StoreInst>(IsReorder ? VL[E->ReorderIndices.front()] : VL0); - auto GetVectorCost = [=](InstructionCost CommonCost) { + auto GetVectorCost = [=, this](InstructionCost CommonCost) { // We know that we can merge the stores. Calculate the cost. TTI::OperandValueInfo OpInfo = getOperandInfo(VL, 0); return TTI->getMemoryOpCost(Instruction::Store, VecTy, BaseSI->getAlign(), @@ -7356,7 +7356,7 @@ GetGEPCostDiff(PointerOps, BaseSI->getPointerOperand()); } case Instruction::Call: { - auto GetScalarCost = [=](unsigned Idx) { + auto GetScalarCost = [=, this](unsigned Idx) { auto *CI = cast<CallInst>(VL[Idx]); Intrinsic::ID ID = getVectorIntrinsicIDForCall(CI, TLI); if (ID != Intrinsic::not_intrinsic) { @@ -7367,7 +7367,7 @@ CI->getFunctionType()->getReturnType(), CI->getFunctionType()->params(), CostKind); }; - auto GetVectorCost = [=](InstructionCost CommonCost) { + auto GetVectorCost = [=, this](InstructionCost CommonCost) { auto *CI = cast<CallInst>(VL0); auto VecCallCosts = getVectorCallCosts(CI, VecTy, TTI, TLI); return std::min(VecCallCosts.first, VecCallCosts.second) + CommonCost; @@ -7384,7 +7384,7 @@ "Invalid Shuffle Vector Operand"); // Try to find the previous shuffle node with the same operands and same // main/alternate ops. - auto TryFindNodeWithEqualOperands = [=]() { + auto TryFindNodeWithEqualOperands = [=, this]() { for (const std::unique_ptr<TreeEntry> &TE : VectorizableTree) { if (TE.get() == E) break; @@ -8335,7 +8335,7 @@ // We suppose it is better to ignore instruction, which do not form splats, // are not vectorized/not extractelements (these instructions will be handled // by extractelements processing) or may form vector node in future. - auto MightBeIgnored = [=](Value *V) { + auto MightBeIgnored = [=, this](Value *V) { auto *I = dyn_cast<Instruction>(V); SmallVector<Value *> IgnoredVals; if (UserIgnoreList)