Skip to content

Commit dceabaa

Browse files
ftynsewsmoses
andauthored
Update APIs to match LLVM to llvmorg-16-init-8549-gcbc378ecb87e (#282)
* Update APIs to match LLVM to llvmorg-16-init-8549-gcbc378ecb87e * Stop the ridiculously fragile mathcing of SSA values MLIR tests must not match specific SSA values to avoid huge costs with version bumps. * Fix namespace * Stop more ridiculously fragile matching Co-authored-by: William S. Moses <[email protected]>
1 parent 4d42aa6 commit dceabaa

File tree

174 files changed

+3241
-3248
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+3241
-3248
lines changed

include/polygeist/BarrierUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
#define MLIR_LIB_DIALECT_SCF_TRANSFORMS_BARRIERUTILS_H_
1111

1212
#include "mlir/Analysis/DataLayoutAnalysis.h"
13+
#include "mlir/Dialect/Arith/IR/Arith.h"
1314
#include "mlir/Dialect/Func/IR/FuncOps.h"
1415
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
1516
#include "mlir/Dialect/MemRef/IR/MemRef.h"
1617
#include "mlir/Dialect/SCF/IR/SCF.h"
1718
#include "mlir/IR/Block.h"
1819
#include "polygeist/Ops.h"
1920
#include "llvm/ADT/SetVector.h"
20-
#include <mlir/Dialect/Arith/IR/Arith.h>
2121

2222
std::pair<mlir::Block *, mlir::Block::iterator>
2323
findInsertionPointAfterLoopOperands(mlir::scf::ParallelOp op);

include/polygeist/Ops.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,19 @@ class BarrierElim final
8585
return failure();
8686

8787
{
88-
SmallVector<MemoryEffects::EffectInstance> beforeEffects;
88+
SmallVector<mlir::MemoryEffects::EffectInstance> beforeEffects;
8989
getEffectsBefore(op, beforeEffects, /*stopAtBarrier*/ true);
9090

91-
SmallVector<MemoryEffects::EffectInstance> afterEffects;
91+
SmallVector<mlir::MemoryEffects::EffectInstance> afterEffects;
9292
getEffectsAfter(op, afterEffects, /*stopAtBarrier*/ false);
9393

9494
bool conflict = false;
9595
for (auto before : beforeEffects)
9696
for (auto after : afterEffects) {
9797
if (mayAlias(before, after)) {
9898
// Read, read is okay
99-
if (isa<MemoryEffects::Read>(before.getEffect()) &&
100-
isa<MemoryEffects::Read>(after.getEffect())) {
99+
if (isa<mlir::MemoryEffects::Read>(before.getEffect()) &&
100+
isa<mlir::MemoryEffects::Read>(after.getEffect())) {
101101
continue;
102102
}
103103

@@ -115,19 +115,19 @@ class BarrierElim final
115115
}
116116

117117
{
118-
SmallVector<MemoryEffects::EffectInstance> beforeEffects;
118+
SmallVector<mlir::MemoryEffects::EffectInstance> beforeEffects;
119119
getEffectsBefore(op, beforeEffects, /*stopAtBarrier*/ false);
120120

121-
SmallVector<MemoryEffects::EffectInstance> afterEffects;
121+
SmallVector<mlir::MemoryEffects::EffectInstance> afterEffects;
122122
getEffectsAfter(op, afterEffects, /*stopAtBarrier*/ true);
123123

124124
bool conflict = false;
125125
for (auto before : beforeEffects)
126126
for (auto after : afterEffects) {
127127
if (mayAlias(before, after)) {
128128
// Read, read is okay
129-
if (isa<MemoryEffects::Read>(before.getEffect()) &&
130-
isa<MemoryEffects::Read>(after.getEffect())) {
129+
if (isa<mlir::MemoryEffects::Read>(before.getEffect()) &&
130+
isa<mlir::MemoryEffects::Read>(after.getEffect())) {
131131
continue;
132132
}
133133
// Write, write is not okay because may be different offsets and the

include/polygeist/PolygeistOps.td

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def BarrierOp
5151
//===----------------------------------------------------------------------===//
5252

5353
def SubIndexOp : Polygeist_Op<"subindex", [
54-
ViewLikeOpInterface, NoSideEffect
54+
ViewLikeOpInterface, Pure
5555
]> {
5656
let summary = "memref subview operation";
5757

@@ -68,7 +68,7 @@ def SubIndexOp : Polygeist_Op<"subindex", [
6868

6969

7070
def StreamToTokenOp : Polygeist_Op<"stream2token", [
71-
NoSideEffect
71+
Pure
7272
]> {
7373
let summary = "Extract an async stream from a cuda stream";
7474

@@ -81,7 +81,7 @@ def StreamToTokenOp : Polygeist_Op<"stream2token", [
8181
//===----------------------------------------------------------------------===//
8282

8383
def Memref2PointerOp : Polygeist_Op<"memref2pointer", [
84-
ViewLikeOpInterface, NoSideEffect
84+
ViewLikeOpInterface, Pure
8585
]> {
8686
let summary = "Extract and LLVM pointer from a MemRef";
8787

@@ -97,7 +97,7 @@ def Memref2PointerOp : Polygeist_Op<"memref2pointer", [
9797
}
9898

9999
def Pointer2MemrefOp : Polygeist_Op<"pointer2memref", [
100-
ViewLikeOpInterface, NoSideEffect
100+
ViewLikeOpInterface, Pure
101101
]> {
102102
let summary = "Upgrade a pointer to a memref";
103103

@@ -113,7 +113,7 @@ def Pointer2MemrefOp : Polygeist_Op<"pointer2memref", [
113113
}
114114

115115
def GetFuncOp : Polygeist_Op<"get_func",
116-
[NoSideEffect, DeclareOpInterfaceMethods<SymbolUserOpInterface>]> {
116+
[Pure, DeclareOpInterfaceMethods<SymbolUserOpInterface>]> {
117117
let summary = "get the pointer pointing to a function";
118118
let arguments = (ins FlatSymbolRefAttr:$name);
119119
let results = (outs LLVM_AnyPointer : $result);
@@ -127,15 +127,15 @@ def TrivialUseOp : Polygeist_Op<"trivialuse"> {
127127

128128
}
129129

130-
def TypeSizeOp : Polygeist_Op<"typeSize", [NoSideEffect]> {
130+
def TypeSizeOp : Polygeist_Op<"typeSize", [Pure]> {
131131
let summary = "Get size of type";
132132
let arguments = (ins TypeAttr : $source);
133133
let results = (outs AnyType : $result);
134134
let hasFolder = 1;
135135
let hasCanonicalizer = 1;
136136
}
137137

138-
def TypeAlignOp : Polygeist_Op<"typeAlign", [NoSideEffect]> {
138+
def TypeAlignOp : Polygeist_Op<"typeAlign", [Pure]> {
139139
let summary = "Get alignment of type";
140140
let arguments = (ins TypeAttr : $source);
141141
let results = (outs AnyType : $result);

lib/polygeist/Ops.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "mlir/Dialect/SCF/IR/SCF.h"
2828
#include "mlir/IR/BlockAndValueMapping.h"
2929
#include "mlir/IR/IntegerSet.h"
30+
#include "mlir/Transforms/SideEffectUtils.h"
3031

3132
#include "llvm/ADT/SetVector.h"
3233
#include "llvm/Support/Debug.h"
@@ -40,10 +41,6 @@ using namespace mlir::arith;
4041
llvm::cl::opt<bool> BarrierOpt("barrier-opt", llvm::cl::init(true),
4142
llvm::cl::desc("Optimize barriers"));
4243

43-
namespace mlir {
44-
bool isSideEffectFree(Operation *op);
45-
}
46-
4744
//===----------------------------------------------------------------------===//
4845
// BarrierOp
4946
//===----------------------------------------------------------------------===//
@@ -76,7 +73,7 @@ bool collectEffects(Operation *op,
7673
llvm::append_range(effects, localEffects);
7774
return true;
7875
}
79-
if (op->hasTrait<OpTrait::HasRecursiveSideEffects>()) {
76+
if (op->hasTrait<OpTrait::HasRecursiveMemoryEffects>()) {
8077
for (auto &region : op->getRegions()) {
8178
for (auto &block : region) {
8279
for (auto &innerOp : block)
@@ -200,7 +197,7 @@ void BarrierOp::getEffects(
200197
}
201198

202199
bool isReadOnly(Operation *op) {
203-
bool hasRecursiveEffects = op->hasTrait<OpTrait::HasRecursiveSideEffects>();
200+
bool hasRecursiveEffects = op->hasTrait<OpTrait::HasRecursiveMemoryEffects>();
204201
if (hasRecursiveEffects) {
205202
for (Region &region : op->getRegions()) {
206203
for (auto &block : region) {
@@ -230,7 +227,7 @@ bool isReadOnly(Operation *op) {
230227
}
231228

232229
bool isReadNone(Operation *op) {
233-
bool hasRecursiveEffects = op->hasTrait<OpTrait::HasRecursiveSideEffects>();
230+
bool hasRecursiveEffects = op->hasTrait<OpTrait::HasRecursiveMemoryEffects>();
234231
if (hasRecursiveEffects) {
235232
for (Region &region : op->getRegions()) {
236233
for (auto &block : region) {
@@ -2330,7 +2327,7 @@ struct AlwaysAllocaScopeHoister : public OpRewritePattern<T> {
23302327
static bool isOpItselfPotentialAutomaticAllocation(Operation *op) {
23312328
// This op itself doesn't create a stack allocation,
23322329
// the inner allocation should be handled separately.
2333-
if (op->hasTrait<OpTrait::HasRecursiveSideEffects>())
2330+
if (op->hasTrait<OpTrait::HasRecursiveMemoryEffects>())
23342331
return false;
23352332
MemoryEffectOpInterface interface = dyn_cast<MemoryEffectOpInterface>(op);
23362333
if (!interface)
@@ -2477,11 +2474,11 @@ struct RankReduction : public OpRewritePattern<T> {
24772474
}
24782475
if (auto load = dyn_cast<memref::LoadOp>(u)) {
24792476
if (!set) {
2480-
for (auto i : load.indices())
2477+
for (auto i : load.getIndices())
24812478
v.push_back(i);
24822479
set = true;
24832480
} else {
2484-
for (auto pair : llvm::zip(load.indices(), v)) {
2481+
for (auto pair : llvm::zip(load.getIndices(), v)) {
24852482
if (std::get<0>(pair) != std::get<1>(pair))
24862483
return failure();
24872484
}
@@ -2506,7 +2503,7 @@ struct RankReduction : public OpRewritePattern<T> {
25062503
v.push_back(i);
25072504
set = true;
25082505
} else {
2509-
for (auto pair : llvm::zip(load.indices(), v)) {
2506+
for (auto pair : llvm::zip(load.getIndices(), v)) {
25102507
if (std::get<0>(pair) != std::get<1>(pair))
25112508
return failure();
25122509
}
@@ -2518,11 +2515,11 @@ struct RankReduction : public OpRewritePattern<T> {
25182515
if (store.getValue() == op)
25192516
return failure();
25202517
if (!set) {
2521-
for (auto i : store.indices())
2518+
for (auto i : store.getIndices())
25222519
v.push_back(i);
25232520
set = true;
25242521
} else {
2525-
for (auto pair : llvm::zip(store.indices(), v)) {
2522+
for (auto pair : llvm::zip(store.getIndices(), v)) {
25262523
if (std::get<0>(pair) != std::get<1>(pair))
25272524
return failure();
25282525
}
@@ -2550,7 +2547,7 @@ struct RankReduction : public OpRewritePattern<T> {
25502547
v.push_back(i);
25512548
set = true;
25522549
} else {
2553-
for (auto pair : llvm::zip(store.indices(), v)) {
2550+
for (auto pair : llvm::zip(store.getIndices(), v)) {
25542551
if (std::get<0>(pair) != std::get<1>(pair))
25552552
return failure();
25562553
}
@@ -3762,7 +3759,7 @@ struct PrepMergeNestedAffineParallelLoops
37623759
innerOp = innerOp2;
37633760
continue;
37643761
}
3765-
if (isSideEffectFree(&op)) {
3762+
if (isMemoryEffectFree(&op)) {
37663763
if (!isa<AffineYieldOp>(&op))
37673764
toMove.push_back(&op);
37683765
continue;

lib/polygeist/Passes/AffineCFG.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "mlir/Dialect/Affine/IR/AffineOps.h"
44
#include "mlir/Dialect/Affine/Passes.h"
5+
#include "mlir/Dialect/Arith/IR/Arith.h"
56
#include "mlir/Dialect/MemRef/IR/MemRef.h"
67
#include "mlir/Dialect/SCF/IR/SCF.h"
78
#include "mlir/IR/BlockAndValueMapping.h"
@@ -15,7 +16,6 @@
1516
#include "llvm/ADT/SmallSet.h"
1617
#include "llvm/Support/Debug.h"
1718
#include <deque>
18-
#include <mlir/Dialect/Arith/IR/Arith.h>
1919

2020
#define DEBUG_TYPE "affine-cfg"
2121

lib/polygeist/Passes/BarrierRemovalContinuation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -587,11 +587,11 @@ static void createContinuations(scf::ParallelOp parallel, Value storage) {
587587
}
588588

589589
static void createContinuations(FunctionOpInterface func) {
590-
if (func->getNumRegions() == 0 || func.getBody().empty())
590+
if (func->getNumRegions() == 0 || func.getFunctionBody().empty())
591591
return;
592592

593-
OpBuilder allocaBuilder(&func.getBody().front(),
594-
func.getBody().front().begin());
593+
OpBuilder allocaBuilder(&func.getFunctionBody().front(),
594+
func.getFunctionBody().front().begin());
595595
func.walk([&](scf::ParallelOp parallel) {
596596
// Ignore parallel ops with no barriers.
597597
if (!hasImmediateBarriers(parallel))

lib/polygeist/Passes/CanonicalizeFor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "PassDetails.h"
22

3+
#include "mlir/Dialect/Arith/IR/Arith.h"
34
#include "mlir/Dialect/Func/IR/FuncOps.h"
45
#include "mlir/Dialect/Math/IR/Math.h"
56
#include "mlir/Dialect/SCF/IR/SCF.h"
@@ -9,7 +10,6 @@
910
#include "mlir/IR/Matchers.h"
1011
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
1112
#include "polygeist/Passes/Passes.h"
12-
#include <mlir/Dialect/Arith/IR/Arith.h>
1313

1414
using namespace mlir;
1515
using namespace mlir::scf;
@@ -1820,13 +1820,13 @@ struct WhileLICM : public OpRewritePattern<WhileOp> {
18201820
}
18211821
// If the operation doesn't have side effects and it doesn't recursively
18221822
// have side effects, it can always be hoisted.
1823-
if (!op->hasTrait<OpTrait::HasRecursiveSideEffects>())
1823+
if (!op->hasTrait<OpTrait::HasRecursiveMemoryEffects>())
18241824
return true;
18251825

18261826
// Otherwise, if the operation doesn't provide the memory effect interface
18271827
// and it doesn't have recursive side effects we treat it conservatively
18281828
// as side-effecting.
1829-
} else if (!op->hasTrait<OpTrait::HasRecursiveSideEffects>()) {
1829+
} else if (!op->hasTrait<OpTrait::HasRecursiveMemoryEffects>()) {
18301830
return false;
18311831
}
18321832

lib/polygeist/Passes/ConvertPolygeistToLLVM.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,14 +425,12 @@ struct AsyncOpLowering : public ConvertOpToLLVMPattern<async::ExecuteOp> {
425425

426426
// Make sure that all constants will be inside the outlined async function
427427
// to reduce the number of function arguments.
428-
Region &funcReg = *execute.getBody()->getParent();
429-
;
428+
Region &funcReg = execute.getBodyRegion();
430429

431430
// Collect all outlined function inputs.
432431
SetVector<mlir::Value> functionInputs;
433432

434-
getUsedValuesDefinedAbove(*execute.getBody()->getParent(), funcReg,
435-
functionInputs);
433+
getUsedValuesDefinedAbove(execute.getBodyRegion(), funcReg, functionInputs);
436434
SmallVector<Value> toErase;
437435
for (auto a : functionInputs) {
438436
Operation *op = a.getDefiningOp();

lib/polygeist/Passes/InnerSerialization.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "PassDetails.h"
22

3+
#include "mlir/Dialect/Arith/IR/Arith.h"
34
#include "mlir/Dialect/Func/IR/FuncOps.h"
45
#include "mlir/Dialect/MemRef/IR/MemRef.h"
56
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
@@ -10,7 +11,6 @@
1011
#include "mlir/IR/Matchers.h"
1112
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
1213
#include "polygeist/Passes/Passes.h"
13-
#include <mlir/Dialect/Arith/IR/Arith.h>
1414

1515
using namespace mlir;
1616
using namespace mlir::func;

lib/polygeist/Passes/Mem2Reg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,7 @@ bool Mem2Reg::forwardStoreToLoad(
12831283
SmallVector<Operation *> capEffects;
12841284
AI.getDefiningOp()->getParentOp()->walk([&](Operation *op) {
12851285
bool opMayHaveEffect = false;
1286-
if (op->hasTrait<OpTrait::HasRecursiveSideEffects>())
1286+
if (op->hasTrait<OpTrait::HasRecursiveMemoryEffects>())
12871287
return;
12881288
if (auto callOp = dyn_cast<mlir::LLVM::CallOp>(op)) {
12891289
if (callOp.getCallee() && (*callOp.getCallee() == "printf" ||

0 commit comments

Comments
 (0)