From: Eric Schweitz Date: Thu, 25 Feb 2021 00:06:17 +0000 (-0800) Subject: [flang][fir][NFC] Remove dead code. X-Git-Tag: llvmorg-14-init~14094 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=082ec3ab07760d1a6e47886246090c6f58708dbf;p=platform%2Fupstream%2Fllvm.git [flang][fir][NFC] Remove dead code. This patch removes OpaqueAttr as it is no longer used. Differential Revision: https://reviews.llvm.org/D97424 --- diff --git a/flang/include/flang/Optimizer/Dialect/FIRAttr.h b/flang/include/flang/Optimizer/Dialect/FIRAttr.h index 8317b6e..20c8210 100644 --- a/flang/include/flang/Optimizer/Dialect/FIRAttr.h +++ b/flang/include/flang/Optimizer/Dialect/FIRAttr.h @@ -25,7 +25,6 @@ namespace fir { class FIROpsDialect; namespace detail { -struct OpaqueAttributeStorage; struct RealAttributeStorage; struct TypeAttributeStorage; } // namespace detail @@ -134,27 +133,6 @@ public: llvm::APFloat getValue() const; }; -/// An opaque attribute is used to provide dictionary lookups of pointers. The -/// underlying type of the pointee object is left up to the client. Opaque -/// attributes are always constructed as null pointers when parsing. Clearly, -/// opaque attributes come with restrictions and must be used with care. -/// 1. An opaque attribute should not refer to information of semantic -/// significance, since the pointed-to object will not be a part of -/// round-tripping the IR. -/// 2. The lifetime of the pointed-to object must outlive any possible uses -/// via the opaque attribute. -class OpaqueAttr - : public mlir::Attribute::AttrBase { -public: - using Base::Base; - - static constexpr llvm::StringRef getAttrName() { return "opaque"; } - static OpaqueAttr get(mlir::MLIRContext *ctxt, void *pointer); - - void *getPointer() const; -}; - mlir::Attribute parseFirAttribute(FIROpsDialect *dialect, mlir::DialectAsmParser &parser, mlir::Type type); diff --git a/flang/lib/Optimizer/Dialect/FIRAttr.cpp b/flang/lib/Optimizer/Dialect/FIRAttr.cpp index 1996143..035245d 100644 --- a/flang/lib/Optimizer/Dialect/FIRAttr.cpp +++ b/flang/lib/Optimizer/Dialect/FIRAttr.cpp @@ -74,28 +74,6 @@ struct TypeAttributeStorage : public mlir::AttributeStorage { private: mlir::Type value; }; - -/// An attribute representing a raw pointer. -struct OpaqueAttributeStorage : public mlir::AttributeStorage { - using KeyTy = void *; - - OpaqueAttributeStorage(void *value) : value(value) {} - - /// Key equality function. - bool operator==(const KeyTy &key) const { return key == value; } - - /// Construct a new storage instance. - static OpaqueAttributeStorage * - construct(mlir::AttributeStorageAllocator &allocator, KeyTy key) { - return new (allocator.allocate()) - OpaqueAttributeStorage(key); - } - - void *getPointer() const { return value; } - -private: - void *value; -}; } // namespace fir::detail //===----------------------------------------------------------------------===// @@ -150,16 +128,6 @@ KindTy fir::RealAttr::getFKind() const { return getImpl()->getFKind(); } llvm::APFloat fir::RealAttr::getValue() const { return getImpl()->getValue(); } //===----------------------------------------------------------------------===// -// OpaqueAttr -//===----------------------------------------------------------------------===// - -OpaqueAttr fir::OpaqueAttr::get(mlir::MLIRContext *ctxt, void *key) { - return Base::get(ctxt, key); -} - -void *fir::OpaqueAttr::getPointer() const { return getImpl()->getPointer(); } - -//===----------------------------------------------------------------------===// // FIR attribute parsing //===----------------------------------------------------------------------===// @@ -227,15 +195,6 @@ mlir::Attribute fir::parseFirAttribute(FIROpsDialect *dialect, } return SubclassAttr::get(type); } - if (attrName == OpaqueAttr::getAttrName()) { - if (parser.parseLess() || parser.parseGreater()) { - parser.emitError(loc, "expected <>"); - return {}; - } - // NB: opaque pointers are always parsed in as nullptrs. The tool must - // rebuild the context. - return OpaqueAttr::get(dialect->getContext(), nullptr); - } if (attrName == PointIntervalAttr::getAttrName()) return PointIntervalAttr::get(dialect->getContext()); if (attrName == LowerBoundAttr::getAttrName()) @@ -279,8 +238,6 @@ void fir::printFirAttribute(FIROpsDialect *dialect, mlir::Attribute attr, llvm::SmallString<40> ss; a.getValue().bitcastToAPInt().toStringUnsigned(ss, 16); os << ss << '>'; - } else if (attr.isa()) { - os << fir::OpaqueAttr::getAttrName() << "<>"; } else { // don't know how to print the attribute, so use a default os << "<(unknown attribute)>"; diff --git a/flang/lib/Optimizer/Dialect/FIRDialect.cpp b/flang/lib/Optimizer/Dialect/FIRDialect.cpp index 24df36c..696b552 100644 --- a/flang/lib/Optimizer/Dialect/FIRDialect.cpp +++ b/flang/lib/Optimizer/Dialect/FIRDialect.cpp @@ -24,7 +24,7 @@ fir::FIROpsDialect::FIROpsDialect(mlir::MLIRContext *ctx) PointerType, RealType, RecordType, ReferenceType, SequenceType, ShapeType, ShapeShiftType, SliceType, TypeDescType, fir::VectorType>(); - addAttributes(); addOperations< #define GET_OP_LIST diff --git a/flang/test/Fir/fir-ops.fir b/flang/test/Fir/fir-ops.fir index 4a75435..3e8c81c 100644 --- a/flang/test/Fir/fir-ops.fir +++ b/flang/test/Fir/fir-ops.fir @@ -32,9 +32,6 @@ func private @method_impl(!fir.box>) func private @nop() func private @get_func() -> (() -> ()) -// CHECK-LABEL: func private @attr1() -> none attributes {a = #fir.opaque<>, b = #fir.opaque<>} -func private @attr1() -> none attributes {a = #fir.opaque<>, b = #fir.opaque<>} - // CHECK-LABEL: func @instructions() { func @instructions() { // CHECK: [[VAL_0:%.*]] = fir.alloca !fir.array<10xi32>