Skip to content

Commit d8ae1cf

Browse files
authored
[SYCL-MLIR]: Fix warnings (#8410)
Fix the following issues in the SYCL-MLIR codebase: - adapt SYCL-MLIR and Polygeist dialects to MLIR improved `fold` method signature (https://discourse.llvm.org/t/psa-new-improved-fold-method-signature-has-landed-please-update-your-downstream-projects/67618) - warning: 'makeArrayRef<const char *, 6>' is deprecated: Use deduction guide instead (https://reviews.llvm.org/D140896) - fix some clang-tidy warnings --------- Signed-off-by: Tiotto, Ettore <[email protected]>
1 parent 818ea74 commit d8ae1cf

File tree

5 files changed

+21
-20
lines changed

5 files changed

+21
-20
lines changed

mlir-sycl/include/mlir/Dialect/SYCL/IR/SYCLOps.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def SYCL_Dialect : Dialect {
3333
let name = "sycl";
3434
let cppNamespace = "::mlir::sycl";
3535
let useDefaultTypePrinterParser = 1;
36+
let useFoldAPI = kEmitFoldAdaptorFolder;
3637
let extraClassDeclaration = [{
3738
MethodRegistry methods;
3839

polygeist/include/mlir/Dialect/Polygeist/IR/PolygeistBase.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def Polygeist_Dialect : Dialect {
1515
let name = "polygeist";
1616
let cppNamespace = "::mlir::polygeist";
1717
let description = [{}];
18+
let useFoldAPI = kEmitFoldAdaptorFolder;
1819
}
1920

2021
#endif // POLYGEIST_BASE

polygeist/lib/Dialect/Polygeist/IR/Ops.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ bool getEffectsBefore(Operation *op,
9797
if (isa<BarrierOp>(it)) {
9898
if (stopAtBarrier)
9999
return true;
100-
else
101-
continue;
100+
continue;
102101
}
103102
if (!collectEffects(it, effects, /* ignoreBarriers */ true))
104103
return false;
@@ -259,7 +258,7 @@ class BarrierHoist final : public OpRewritePattern<BarrierOp> {
259258
// Move barrier into after region and after loop, if possible
260259
if (auto whileOp = dyn_cast<scf::WhileOp>(barrier->getParentOp())) {
261260
if (barrier->getParentRegion() == &whileOp.getBefore()) {
262-
auto cond = whileOp.getBefore().front().getTerminator();
261+
auto *cond = whileOp.getBefore().front().getTerminator();
263262

264263
bool above = true;
265264
for (Operation *it = cond; it != nullptr; it = it->getPrevNode()) {
@@ -289,7 +288,7 @@ bool isCaptured(Value v, Operation *potentialUser = nullptr,
289288
SmallVector<Value> todo = {v};
290289
while (todo.size()) {
291290
Value v = todo.pop_back_val();
292-
for (auto u : v.getUsers()) {
291+
for (auto *u : v.getUsers()) {
293292
if (seenuse && u == potentialUser)
294293
*seenuse = true;
295294
if (isa<memref::LoadOp, LLVM::LoadOp, AffineLoadOp, polygeist::CacheLoad>(
@@ -1408,7 +1407,7 @@ class SetSimplification final : public OpRewritePattern<T> {
14081407
}
14091408
};
14101409

1411-
OpFoldResult Memref2PointerOp::fold(ArrayRef<Attribute> operands) {
1410+
OpFoldResult Memref2PointerOp::fold(FoldAdaptor operands) {
14121411
if (auto subindex = getSource().getDefiningOp<SubIndexOp>()) {
14131412
if (auto cop = subindex.getIndex().getDefiningOp<ConstantIndexOp>()) {
14141413
if (cop.value() == 0) {
@@ -1920,7 +1919,7 @@ void Pointer2MemrefOp::getCanonicalizationPatterns(RewritePatternSet &results,
19201919
MoveIntoIfs, MoveOutOfIfs, IfAndLazy>(context);
19211920
}
19221921

1923-
OpFoldResult Pointer2MemrefOp::fold(ArrayRef<Attribute> operands) {
1922+
OpFoldResult Pointer2MemrefOp::fold(FoldAdaptor operands) {
19241923
/// Simplify pointer2memref(bitcast(x)) to pointer2memref(x)
19251924
if (auto mc = getSource().getDefiningOp<LLVM::BitcastOp>()) {
19261925
getSourceMutable().assign(mc.getArg());
@@ -1948,7 +1947,7 @@ OpFoldResult Pointer2MemrefOp::fold(ArrayRef<Attribute> operands) {
19481947
return nullptr;
19491948
}
19501949

1951-
OpFoldResult SubIndexOp::fold(ArrayRef<Attribute> operands) {
1950+
OpFoldResult SubIndexOp::fold(FoldAdaptor operands) {
19521951
if (getResult().getType() == getSource().getType()) {
19531952
if (matchPattern(getIndex(), m_Zero()))
19541953
return getSource();
@@ -1964,7 +1963,7 @@ OpFoldResult SubIndexOp::fold(ArrayRef<Attribute> operands) {
19641963
return nullptr;
19651964
}
19661965

1967-
OpFoldResult TypeSizeOp::fold(ArrayRef<Attribute> operands) {
1966+
OpFoldResult TypeSizeOp::fold(FoldAdaptor operands) {
19681967
Type T = getSourceAttr().getValue();
19691968
if (T.isa<IntegerType, FloatType>() || LLVM::isCompatibleType(T)) {
19701969
DataLayout DLI(((Operation *)*this)->getParentOfType<ModuleOp>());
@@ -1994,7 +1993,7 @@ void TypeSizeOp::getCanonicalizationPatterns(RewritePatternSet &results,
19941993
results.insert<TypeSizeCanonicalize>(context);
19951994
}
19961995

1997-
OpFoldResult TypeAlignOp::fold(ArrayRef<Attribute> operands) {
1996+
OpFoldResult TypeAlignOp::fold(FoldAdaptor operands) {
19981997
Type T = getSourceAttr().getValue();
19991998
if (T.isa<IntegerType, FloatType>() || LLVM::isCompatibleType(T)) {
20001999
DataLayout DLI(((Operation *)*this)->getParentOfType<ModuleOp>());
@@ -2267,7 +2266,7 @@ struct AlwaysAllocaScopeHoister : public OpRewritePattern<T> {
22672266
// lastParentWithoutScope (i.e. where we would hoist to), skip.
22682267
if (llvm::any_of(alloc->getOperands(), [&](Value v) { return !fix(v); }))
22692268
return WalkResult::skip();
2270-
for (auto s : subHoist)
2269+
for (auto *s : subHoist)
22712270
toHoist.insert(s);
22722271
toHoist.insert(alloc);
22732272
return WalkResult::advance();

polygeist/lib/Dialect/Polygeist/Transforms/Utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
namespace llvm {
10-
template <typename T> struct SmallVectorImpl;
10+
template <typename T> class SmallVectorImpl;
1111
} // namespace llvm
1212

1313
namespace mlir {

polygeist/tools/cgeist/driver.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ std::string GetExecutablePath(const char *Argv0, bool CanonicalPrefixes) {
9696

9797
// This just needs to be some symbol in the binary; C++ doesn't
9898
// allow taking the address of ::main however.
99-
void *P = (void *)(intptr_t)GetExecutablePath;
100-
return llvm::sys::fs::getMainExecutable(Argv0, P);
99+
return llvm::sys::fs::getMainExecutable(
100+
Argv0, reinterpret_cast<void *>(GetExecutablePath));
101101
}
102102

103103
static int executeCC1Tool(llvm::SmallVectorImpl<const char *> &ArgV) {
@@ -111,15 +111,15 @@ static int executeCC1Tool(llvm::SmallVectorImpl<const char *> &ArgV) {
111111
llvm::StringSaver Saver(A);
112112
llvm::cl::ExpandResponseFiles(Saver, &llvm::cl::TokenizeGNUCommandLine, ArgV);
113113
llvm::StringRef Tool = ArgV[1];
114-
void *GetExecutablePathVP = (void *)(intptr_t)GetExecutablePath;
114+
void *GetExecutablePathVP = reinterpret_cast<void *>(GetExecutablePath);
115+
llvm::ArrayRef<const char *> argv{ArgV};
116+
115117
if (Tool == "-cc1")
116-
return cc1_main(makeArrayRef(ArgV).slice(1), ArgV[0], GetExecutablePathVP);
118+
return cc1_main(argv.slice(1), ArgV[0], GetExecutablePathVP);
117119
if (Tool == "-cc1as")
118-
return cc1as_main(makeArrayRef(ArgV).slice(2), ArgV[0],
119-
GetExecutablePathVP);
120+
return cc1as_main(argv.slice(2), ArgV[0], GetExecutablePathVP);
120121
if (Tool == "-cc1gen-reproducer")
121-
return cc1gen_reproducer_main(makeArrayRef(ArgV).slice(2), ArgV[0],
122-
GetExecutablePathVP);
122+
return cc1gen_reproducer_main(argv.slice(2), ArgV[0], GetExecutablePathVP);
123123
// Reject unknown tools.
124124
llvm::errs() << "error: unknown integrated tool '" << Tool << "'. "
125125
<< "Valid tools include '-cc1' and '-cc1as'.\n";
@@ -1076,7 +1076,7 @@ int main(int argc, char **argv) {
10761076
for (int I = 0; I < argc; I++)
10771077
Args.push_back(argv[I]);
10781078

1079-
llvm::ArrayRef<const char *> Argv = makeArrayRef(Args);
1079+
llvm::ArrayRef<const char *> Argv{Args};
10801080
const llvm::opt::OptTable &OptTbl = clang::driver::getDriverOptTable();
10811081
const unsigned IncludedFlagsBitmask = clang::driver::options::CC1AsOption;
10821082
unsigned MissingArgIndex, MissingArgCount;

0 commit comments

Comments
 (0)