From 52ba7857585881a79172cb2053a8c46ed2f159bf Mon Sep 17 00:00:00 2001 From: River Riddle Date: Mon, 24 Jun 2019 09:22:07 -0700 Subject: [PATCH] NFC: Simplify Operation::getContext to use the context within the location. PiperOrigin-RevId: 254771979 --- mlir/lib/IR/Operation.cpp | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp index 1328580..3d16e98 100644 --- a/mlir/lib/IR/Operation.cpp +++ b/mlir/lib/IR/Operation.cpp @@ -260,19 +260,7 @@ void Operation::destroy() { } /// Return the context this operation is associated with. -MLIRContext *Operation::getContext() { - // If the op has an attribute, a result type, or an operand type, we have a - // constant time way to get to the context. - if (auto dict = attrs.getDictionary()) - return dict.getContext(); - if (getNumResults()) - return getResult(0)->getType().getContext(); - if (getNumOperands()) - return getOperand(0)->getType().getContext(); - - // For the rest, fallback to find the context by the enclosing region. - return getContainingRegion()->getContext(); -} +MLIRContext *Operation::getContext() { return location->getContext(); } /// Return the dialact this operation is associated with, or nullptr if the /// associated dialect is not registered. -- 2.7.4