[flang][fir][NFC] Remove dead code.
This patch removes OpaqueAttr as it is no longer used.
Differential Revision: https://reviews.llvm.org/D97424
GitOrigin-RevId: 082ec3ab07760d1a6e47886246090c6f58708dbf
diff --git a/include/flang/Optimizer/Dialect/FIRAttr.h b/include/flang/Optimizer/Dialect/FIRAttr.h
index 8317b6e..20c8210 100644
--- a/include/flang/Optimizer/Dialect/FIRAttr.h
+++ b/include/flang/Optimizer/Dialect/FIRAttr.h
@@ -25,7 +25,6 @@
class FIROpsDialect;
namespace detail {
-struct OpaqueAttributeStorage;
struct RealAttributeStorage;
struct TypeAttributeStorage;
} // namespace detail
@@ -134,27 +133,6 @@
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/lib/Optimizer/Dialect/FIRAttr.cpp b/lib/Optimizer/Dialect/FIRAttr.cpp
index 1996143..035245d 100644
--- a/lib/Optimizer/Dialect/FIRAttr.cpp
+++ b/lib/Optimizer/Dialect/FIRAttr.cpp
@@ -74,28 +74,6 @@
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
//===----------------------------------------------------------------------===//
@@ -150,16 +128,6 @@
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 @@
}
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 @@
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/lib/Optimizer/Dialect/FIRDialect.cpp b/lib/Optimizer/Dialect/FIRDialect.cpp
index 24df36c..696b552 100644
--- a/lib/Optimizer/Dialect/FIRDialect.cpp
+++ b/lib/Optimizer/Dialect/FIRDialect.cpp
@@ -24,7 +24,7 @@
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/test/Fir/fir-ops.fir b/test/Fir/fir-ops.fir
index 4a75435..3e8c81c 100644
--- a/test/Fir/fir-ops.fir
+++ b/test/Fir/fir-ops.fir
@@ -32,9 +32,6 @@
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>