[flang-commits] [flang] 082ec3a - [flang][fir][NFC] Remove dead code.

Eric Schweitz via flang-commits flang-commits at lists.llvm.org
Wed Feb 24 17:31:50 PST 2021


Author: Eric Schweitz
Date: 2021-02-24T17:31:23-08:00
New Revision: 082ec3ab07760d1a6e47886246090c6f58708dbf

URL: https://github.com/llvm/llvm-project/commit/082ec3ab07760d1a6e47886246090c6f58708dbf
DIFF: https://github.com/llvm/llvm-project/commit/082ec3ab07760d1a6e47886246090c6f58708dbf.diff

LOG: [flang][fir][NFC] Remove dead code.

This patch removes OpaqueAttr as it is no longer used.

Differential Revision: https://reviews.llvm.org/D97424

Added: 
    

Modified: 
    flang/include/flang/Optimizer/Dialect/FIRAttr.h
    flang/lib/Optimizer/Dialect/FIRAttr.cpp
    flang/lib/Optimizer/Dialect/FIRDialect.cpp
    flang/test/Fir/fir-ops.fir

Removed: 
    


################################################################################
diff  --git a/flang/include/flang/Optimizer/Dialect/FIRAttr.h b/flang/include/flang/Optimizer/Dialect/FIRAttr.h
index 8317b6eb4fd9..20c82102c207 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 @@ class RealAttr
   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<OpaqueAttr, mlir::Attribute,
-                                       detail::OpaqueAttributeStorage> {
-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 1996143fcc21..035245dbe935 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>())
-        OpaqueAttributeStorage(key);
-  }
-
-  void *getPointer() const { return value; }
-
-private:
-  void *value;
-};
 } // namespace fir::detail
 
 //===----------------------------------------------------------------------===//
@@ -149,16 +127,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<fir::OpaqueAttr>()) {
-    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 24df36cf6cff..696b55255938 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<ClosedIntervalAttr, ExactTypeAttr, LowerBoundAttr, OpaqueAttr,
+  addAttributes<ClosedIntervalAttr, ExactTypeAttr, LowerBoundAttr,
                 PointIntervalAttr, RealAttr, SubclassAttr, UpperBoundAttr>();
   addOperations<
 #define GET_OP_LIST

diff  --git a/flang/test/Fir/fir-ops.fir b/flang/test/Fir/fir-ops.fir
index 4a754359cd28..3e8c81cd8d1b 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<!fir.type<derived3{f:f32}>>)
 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>


        


More information about the flang-commits mailing list