Skip to content

Commit

Permalink
[BACKEND] Update llvm to llvm/llvm-project@f142f8afe2 (triton-lang#4619)
Browse files Browse the repository at this point in the history
This contains the two commit we want to have for AMD backend:
* llvm/llvm-project#102869
* llvm/llvm-project#104598

This needs to update `visitOperation` signature following
llvm/llvm-project@15e915a44f

Also added `mlir::LLVM::registerInlinerInterface` to address

LLVM ERROR: checking for an interface (`mlir::DialectInlinerInterface`)
that was promised by dialect 'llvm' but never implemented.
  • Loading branch information
antiagainst authored Aug 31, 2024
1 parent e3d2f44 commit 884c0ad
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cmake/llvm-hash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1115dee248e68a155001ac3712a189299d104863
f142f8afe21bceb00fb495468aa0b5043e98c419
2 changes: 1 addition & 1 deletion include/triton/Analysis/Alias.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class SharedMemoryAliasAnalysis
}

/// Computes if the alloc set of the results are changed.
void
LogicalResult
visitOperation(Operation *op,
ArrayRef<const dataflow::Lattice<AliasInfo> *> operands,
ArrayRef<dataflow::Lattice<AliasInfo> *> results) override;
Expand Down
9 changes: 6 additions & 3 deletions lib/Analysis/Alias.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ AliasInfo AliasInfo::join(const AliasInfo &lhs, const AliasInfo &rhs) {
return ret;
}

void SharedMemoryAliasAnalysis::visitOperation(
LogicalResult SharedMemoryAliasAnalysis::visitOperation(
Operation *op, ArrayRef<const dataflow::Lattice<AliasInfo> *> operands,
ArrayRef<dataflow::Lattice<AliasInfo> *> results) {
AliasInfo aliasInfo;
Expand All @@ -31,7 +31,7 @@ void SharedMemoryAliasAnalysis::visitOperation(
if (auto memdescTy = dyn_cast<triton::MemDescType>(result.getType())) {
if (!isa_and_nonnull<triton::gpu::SharedMemorySpaceAttr>(
memdescTy.getMemorySpace()))
return;
return success();
}

// Only LocalAllocOp creates a new buffer.
Expand All @@ -49,11 +49,14 @@ void SharedMemoryAliasAnalysis::visitOperation(
}

if (pessimistic) {
return setAllToEntryStates(results);
setAllToEntryStates(results);
return success();
}
// Join all lattice elements
for (auto *result : results)
propagateIfChanged(result, result->join(aliasInfo));

return success();
}

AliasResult SharedMemoryAliasAnalysis::alias(Value lhs, Value rhs) {
Expand Down
16 changes: 10 additions & 6 deletions lib/Analysis/AxisInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,10 @@ class AxisInfoAnalysis : public dataflow::SparseForwardDataFlowAnalysis<
dataflow::Lattice<AxisInfo>>::getLatticeElement;
using FuncAxisInfoMapT = DenseMap<FunctionOpInterface, AxisInfo>;

void visitOperation(Operation *op,
ArrayRef<const dataflow::Lattice<AxisInfo> *> operands,
ArrayRef<dataflow::Lattice<AxisInfo> *> results) override;
LogicalResult
visitOperation(Operation *op,
ArrayRef<const dataflow::Lattice<AxisInfo> *> operands,
ArrayRef<dataflow::Lattice<AxisInfo> *> results) override;
void
visitForOpInductionVar(scf::ForOp op,
ArrayRef<dataflow::Lattice<AxisInfo> *> argLattices);
Expand Down Expand Up @@ -1039,7 +1040,7 @@ AxisInfoAnalysis::AxisInfoAnalysis(DataFlowSolver &solver)
visitors.append<LoadOpAxisInfoVisitor>();
}

void AxisInfoAnalysis::visitOperation(
LogicalResult AxisInfoAnalysis::visitOperation(
Operation *op, ArrayRef<const dataflow::Lattice<AxisInfo> *> operands,
ArrayRef<dataflow::Lattice<AxisInfo> *> results) {
// TODO: For sure not the right way to do this
Expand All @@ -1048,8 +1049,10 @@ void AxisInfoAnalysis::visitOperation(
if (op->getValue().getRank() == 0)
setToEntryState((dataflow::Lattice<AxisInfo> *)op);
AxisInfo curr = visitors.apply(op, operands);
if (curr.getRank() == 0)
return setAllToEntryStates(results);
if (curr.getRank() == 0) {
setAllToEntryStates(results);
return success();
}
// override with hint
auto newContiguity = curr.getContiguity();
auto newDivisibility = curr.getDivisibility();
Expand All @@ -1071,6 +1074,7 @@ void AxisInfoAnalysis::visitOperation(
// join all lattice elements
for (auto *result : results)
propagateIfChanged(result, result->join(curr));
return success();
}

void AxisInfoAnalysis::visitForOpInductionVar(
Expand Down
2 changes: 2 additions & 0 deletions python/src/ir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "mlir/Dialect/Index/IR/IndexDialect.h"
#include "mlir/Dialect/Index/IR/IndexOps.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/LLVMIR/Transforms/InlinerInterfaceImpl.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/Diagnostics.h"
Expand Down Expand Up @@ -226,6 +227,7 @@ void init_triton_ir(py::module &&m) {
cf::ControlFlowDialect, LLVM::LLVMDialect>();
registerBuiltinDialectTranslation(registry);
registerLLVMDialectTranslation(registry);
mlir::LLVM::registerInlinerInterface(registry);
context.appendDialectRegistry(registry);
context.loadAllAvailableDialects();
});
Expand Down

0 comments on commit 884c0ad

Please sign in to comment.