Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix coverity issues #2680

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions third_party/intel/lib/Analysis/Allocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ getCvtOrder(Attribute srcLayout, Attribute dstLayout) {

// mma or dot layout does not have an order, so the order depends on the
// layout of the other operand.
auto inOrd = (srcMmaLayout || srcDotLayout) ? getOrder(dstLayout)
: getOrder(srcLayout);
auto outOrd = (dstMmaLayout || dstDotLayout) ? getOrder(srcLayout)
: getOrder(dstLayout);
const auto &inOrd = (srcMmaLayout || srcDotLayout) ? getOrder(dstLayout)
: getOrder(srcLayout);
const auto &outOrd = (dstMmaLayout || dstDotLayout) ? getOrder(srcLayout)
: getOrder(dstLayout);

return {inOrd, outOrd};
}
Expand Down Expand Up @@ -346,7 +346,7 @@ class AllocationAnalysis {
/// arguments are involved.
void resolveAliasBufferLiveness(
function_ref<Interval<size_t>(Value value)> getLiveness) {
for (auto aliasBufferIter : allocation->getAliasBuffer()) {
for (const auto &aliasBufferIter : allocation->getAliasBuffer()) {
auto value = aliasBufferIter.first;
auto buffers = aliasBufferIter.second;
auto range = getLiveness(value);
Expand Down Expand Up @@ -486,7 +486,7 @@ class AllocationAnalysis {
std::find_if(xBuffers.begin(), xBuffers.end(), [&](auto *buffer) {
auto xRange = bufferRange[buffer];
bool res = xRange.intersects(range);
for (auto val : tripleMap)
for (const auto &val : tripleMap)
res = res &&
!val.second.intersects(xRange); // only one buffer intersect
return res;
Expand Down
38 changes: 24 additions & 14 deletions third_party/intel/lib/Analysis/AxisInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ class BinaryOpVisitorImpl : public AxisInfoVisitorImpl<OpTy> {
divisibility.push_back(getDivisibility(op, lhsInfo, rhsInfo, d));
}
}
return AxisInfo(contiguity, divisibility, constancy, constantValue);
return AxisInfo(std::move(contiguity), std::move(divisibility),
std::move(constancy), constantValue);
}

protected:
Expand Down Expand Up @@ -543,7 +544,8 @@ class SplatOpAxisInfoVisitor final
divisibility.push_back(opInfo.getDivisibility(0));
constancy.push_back(retTy.getShape()[d]);
}
return AxisInfo(contiguity, divisibility, constancy,
return AxisInfo(std::move(contiguity), std::move(divisibility),
std::move(constancy),
operands[0]->getValue().getConstantValue());
}
};
Expand Down Expand Up @@ -574,7 +576,8 @@ class LoadOpAxisInfoVisitor final : public AxisInfoVisitorImpl<triton::LoadOp> {
maskInfo.has_value() ? maskInfo->getConstancy(d) : 0));
}

return AxisInfo(contiguity, divisibility, constancy);
return AxisInfo(std::move(contiguity), std::move(divisibility),
std::move(constancy));
}
};

Expand Down Expand Up @@ -608,7 +611,8 @@ class ExpandDimsOpAxisInfoVisitor final
contiguity.insert(contiguity.begin() + op.getAxis(), 1);
divisibility.insert(divisibility.begin() + op.getAxis(), newDivisibility);
constancy.insert(constancy.begin() + op.getAxis(), 1);
return AxisInfo(contiguity, divisibility, constancy,
return AxisInfo(std::move(contiguity), std::move(divisibility),
std::move(constancy),
operands[0]->getValue().getConstantValue());
}
};
Expand Down Expand Up @@ -637,7 +641,8 @@ class BroadcastOpAxisInfoVisitor final
constancy.push_back(opShape[d] == 1 ? retShape[d]
: opInfo.getConstancy(d));
}
return AxisInfo(contiguity, divisibility, constancy,
return AxisInfo(std::move(contiguity), std::move(divisibility),
std::move(constancy),
operands[0]->getValue().getConstantValue());
}
};
Expand Down Expand Up @@ -712,7 +717,8 @@ class CmpOpAxisInfoVisitor final : public AxisInfoVisitorImpl<OpTy> {
contiguity.push_back(1);
}

return AxisInfo(contiguity, divisibility, constancy, constantValue);
return AxisInfo(std::move(contiguity), std::move(divisibility),
std::move(constancy), constantValue);
}

private:
Expand Down Expand Up @@ -840,7 +846,8 @@ class SelectOpAxisInfoVisitor final : public AxisInfoVisitorImpl<OpTy> {
constantValue = lhsInfo.getConstantValue();
}

return AxisInfo(contiguity, divisibility, constancy, constantValue);
return AxisInfo(std::move(contiguity), std::move(divisibility),
std::move(constancy), constantValue);
}
};

Expand Down Expand Up @@ -993,7 +1000,8 @@ class MaxMinOpAxisInfoVisitor final : public AxisInfoVisitorImpl<OpTy> {
contiguity.push_back(
std::min(lhsInfo.getContiguity(d), rhsInfo.getContiguity(d)));
}
return AxisInfo(contiguity, divisibility, constancy, std::nullopt);
return AxisInfo(std::move(contiguity), std::move(divisibility),
std::move(constancy), std::nullopt);
}
}
};
Expand Down Expand Up @@ -1038,7 +1046,8 @@ class MakeTensorPtrOpAxisInfoVisitor final
constancy.push_back(1);
}

auto axisInfo = AxisInfo(contiguity, divisibility, constancy);
auto axisInfo = AxisInfo(std::move(contiguity), std::move(divisibility),
std::move(constancy));

LLVM_DEBUG({
std::string axisStr;
Expand Down Expand Up @@ -1143,8 +1152,8 @@ LogicalResult AxisInfoAnalysis::visitOperation(
auto vals = cast<DenseElementsAttr>(attr).getValues<int>();
newConstancy = AxisInfo::DimVectorT(vals.begin(), vals.end());
}
curr = AxisInfo(newContiguity, newDivisibility, newConstancy,
curr.getConstantValue());
curr = AxisInfo(std::move(newContiguity), std::move(newDivisibility),
std::move(newConstancy), curr.getConstantValue());
// join all lattice elements
for (auto *result : results)
propagateIfChanged(result, result->join(curr));
Expand All @@ -1154,17 +1163,18 @@ LogicalResult AxisInfoAnalysis::visitOperation(
void AxisInfoAnalysis::visitForOpInductionVar(
scf::ForOp op, ArrayRef<dataflow::Lattice<AxisInfo> *> argLattices) {
ProgramPoint programPoint(op);
const auto lb =
const auto &lb =
getLatticeElementFor(&programPoint, op.getLowerBound())->getValue();
const auto step =
const auto &step =
getLatticeElementFor(&programPoint, op.getStep())->getValue();

AxisInfo::DimVectorT knownContiguity(1, 1);
AxisInfo::DimVectorT knownDivisibility(1, 1);
AxisInfo::DimVectorT knownConstancy(1, 1);
knownDivisibility[0] = gcd(lb.getDivisibility(0), step.getDivisibility(0));
auto inductionVar =
AxisInfo(knownContiguity, knownDivisibility, knownConstancy);
AxisInfo(std::move(knownContiguity), std::move(knownDivisibility),
std::move(knownConstancy));
(void)argLattices[0]->join(inductionVar);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ template <unsigned opIdx> class DpasMatmulLoader {
ConversionPatternRewriter &rewriter,
const LLVMTypeConverter *typeConverter, Location loc)
: dpasLayout(dpasLayout), descTy(descTy), smemStrides(smemStrides),
multiDimWarpId(multiDimWarpId), rewriter(rewriter), loc(loc) {
multiDimWarpId(std::move(multiDimWarpId)), rewriter(rewriter),
loc(loc) {
static_assert(opIdx == 0 || opIdx == 1);

size_t rank = warpShape.size();
Expand Down