Skip to content

Commit

Permalink
[MLIR][NFC] Eliminate .getBlocks() when not needed
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D82229
  • Loading branch information
jurahul committed Jun 19, 2020
1 parent 2565581 commit d150662
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
Expand Up @@ -219,19 +219,19 @@ void LaunchOp::build(OpBuilder &builder, OperationState &result,

KernelDim3 LaunchOp::getBlockIds() {
assert(!body().empty() && "LaunchOp body must not be empty.");
auto args = body().getBlocks().front().getArguments();
auto args = body().front().getArguments();
return KernelDim3{args[0], args[1], args[2]};
}

KernelDim3 LaunchOp::getThreadIds() {
assert(!body().empty() && "LaunchOp body must not be empty.");
auto args = body().getBlocks().front().getArguments();
auto args = body().front().getArguments();
return KernelDim3{args[3], args[4], args[5]};
}

KernelDim3 LaunchOp::getGridSize() {
assert(!body().empty() && "LaunchOp body must not be empty.");
auto args = body().getBlocks().front().getArguments();
auto args = body().front().getArguments();
return KernelDim3{args[6], args[7], args[8]};
}

Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/LLVMIR/Transforms/LegalizeForExport.cpp
Expand Up @@ -50,7 +50,7 @@ static void ensureDistinctSuccessors(Block &bb) {

void mlir::LLVM::ensureDistinctSuccessors(Operation *op) {
op->walk([](LLVMFuncOp f) {
for (auto &bb : f.getBlocks()) {
for (auto &bb : f) {
::ensureDistinctSuccessors(bb);
}
});
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/ExecutionEngine/JitRunner.cpp
Expand Up @@ -167,7 +167,7 @@ static Error compileAndExecuteVoidFunction(
Options &options, ModuleOp module, StringRef entryPoint,
std::function<llvm::Error(llvm::Module *)> transformer) {
auto mainFunction = module.lookupSymbol<LLVM::LLVMFuncOp>(entryPoint);
if (!mainFunction || mainFunction.getBlocks().empty())
if (!mainFunction || mainFunction.empty())
return make_string_error("entry point not found");
void *empty = nullptr;
return compileAndExecute(options, module, entryPoint, transformer, &empty);
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
Expand Up @@ -611,7 +611,7 @@ static llvm::SetVector<Block *> topologicalSort(LLVMFuncOp f) {
// predecessors), add it to the list and traverse its successors in DFS
// preorder.
llvm::SetVector<Block *> blocks;
for (Block &b : f.getBlocks()) {
for (Block &b : f) {
if (blocks.count(&b) == 0)
topologicalSortImpl(blocks, &b);
}
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Transforms/LoopInvariantCodeMotion.cpp
Expand Up @@ -65,7 +65,7 @@ static bool canBeHoisted(Operation *op,
// Recurse into the regions for this op and check whether the contained ops
// can be hoisted.
for (auto &region : op->getRegions()) {
for (auto &block : region.getBlocks()) {
for (auto &block : region) {
for (auto &innerOp : block.without_terminator())
if (!canBeHoisted(&innerOp, definedOutside))
return false;
Expand Down

0 comments on commit d150662

Please sign in to comment.