Skip to content

Commit 6b4ca37

Browse files
committed
Fix issues with extract() deleting used arguments
1 parent 5b4a352 commit 6b4ca37

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

mlir/lib/Tools/mlir-query/Marshallers.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class VariadicMatcherCreateCallback : public MatcherCreateCallback {
144144

145145
// Helper function to perform template argument deduction.
146146
template <typename MarshallerType, typename FuncType>
147-
MatcherCreateCallback *createMarshallerCallback(MarshallerType Marshaller,
147+
auto createMarshallerCallback(MarshallerType Marshaller,
148148
FuncType Func,
149149
StringRef MatcherName) {
150150
return new FixedArgCountMatcherCreateCallback<MarshallerType, FuncType>(
@@ -235,23 +235,23 @@ DynMatcher *matcherMarshall1(ReturnType (*Func)(InArgType1, InArgType2),
235235

236236
// 0-arg overload
237237
template <typename T, typename ReturnType>
238-
MatcherCreateCallback *makeMatcherAutoMarshall(ReturnType (*Func)(),
238+
auto makeMatcherAutoMarshall(ReturnType (*Func)(),
239239
StringRef MatcherName) {
240240
return createMarshallerCallback(matcherMarshall0<T, ReturnType>, Func,
241241
MatcherName);
242242
}
243243

244244
// 1-arg overload
245245
template <typename T, typename ReturnType, typename ArgType1>
246-
MatcherCreateCallback *makeMatcherAutoMarshall(ReturnType (*Func)(ArgType1),
246+
auto makeMatcherAutoMarshall(ReturnType (*Func)(ArgType1),
247247
StringRef MatcherName) {
248248
return createMarshallerCallback(matcherMarshall1<T, ReturnType, ArgType1>,
249249
Func, MatcherName);
250250
}
251251

252252
// 2-arg overload
253253
template <typename T, typename ReturnType, typename ArgType1, typename ArgType2>
254-
MatcherCreateCallback *makeMatcherAutoMarshall(ReturnType (*Func)(ArgType1,
254+
auto makeMatcherAutoMarshall(ReturnType (*Func)(ArgType1,
255255
ArgType2),
256256
StringRef MatcherName) {
257257
return createMarshallerCallback(
@@ -260,7 +260,7 @@ MatcherCreateCallback *makeMatcherAutoMarshall(ReturnType (*Func)(ArgType1,
260260

261261
// Variadic overload.
262262
template <typename T, typename MatcherType>
263-
MatcherCreateCallback *makeMatcherAutoMarshall(MatcherType Func,
263+
auto makeMatcherAutoMarshall(MatcherType Func,
264264
StringRef MatcherName) {
265265
return new VariadicMatcherCreateCallback<T>(MatcherName);
266266
}

mlir/lib/Tools/mlir-query/Query.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ Operation *extractFunction(std::vector<matcher::DynTypedNode> &nodes,
9595
builder.clone(*slicedOp, mapper);
9696

9797
// Remove func arguments that are not used.
98-
int currentIndex = 0;
99-
for (auto value : funcOp.getArguments()) {
100-
if (value.getUses().empty()) {
98+
unsigned currentIndex = 0;
99+
while (currentIndex < funcOp.getNumArguments()) {
100+
if (funcOp.getArgument(currentIndex).getUses().empty()) {
101101
funcOp.eraseArgument(currentIndex);
102102
} else {
103103
currentIndex++;

0 commit comments

Comments
 (0)