forked from OSchip/llvm-project
Revert "Emit strong definition for TypeID storage in Op/Type/Attributes definition"
This reverts commit 660a56956c
.
This broke the GCC5 build
This commit is contained in:
parent
f8479d9de5
commit
6e9e4b5a6a
|
@ -137,25 +137,6 @@ TypeID TypeID::get() {
|
|||
|
||||
} // end namespace mlir
|
||||
|
||||
// Declare/define an explicit specialization for TypeID: this forces the
|
||||
// compiler to emit a strong definition for a class and controls which
|
||||
// translation unit and shared object will actually have it.
|
||||
// This can be useful to turn to a link-time failure what would be in other
|
||||
// circumstances a hard-to-catch runtime bug when a TypeID is hidden in two
|
||||
// different shared libraries and instances of the same class only gets the same
|
||||
// TypeID inside a given DSO.
|
||||
#define DECLARE_EXPLICIT_TYPE_ID(CLASS_NAME) \
|
||||
template <> \
|
||||
LLVM_EXTERNAL_VISIBILITY mlir::TypeID \
|
||||
mlir::detail::TypeIDExported::get<CLASS_NAME>();
|
||||
#define DEFINE_EXPLICIT_TYPE_ID(CLASS_NAME) \
|
||||
template <> \
|
||||
LLVM_EXTERNAL_VISIBILITY mlir::TypeID \
|
||||
mlir::detail::TypeIDExported::get<CLASS_NAME>() { \
|
||||
static mlir::TypeID::Storage instance; \
|
||||
return mlir::TypeID(&instance); \
|
||||
}
|
||||
|
||||
namespace llvm {
|
||||
template <> struct DenseMapInfo<mlir::TypeID> {
|
||||
static mlir::TypeID getEmptyKey() {
|
||||
|
|
|
@ -440,7 +440,7 @@ bool DefGenerator::emitDecls(StringRef selectedDialect) {
|
|||
collectAllDefs(selectedDialect, defRecords, defs);
|
||||
if (defs.empty())
|
||||
return false;
|
||||
{
|
||||
|
||||
NamespaceEmitter nsEmitter(os, defs.front().getDialect());
|
||||
|
||||
// Declare all the def classes first (in case they reference each other).
|
||||
|
@ -450,14 +450,6 @@ bool DefGenerator::emitDecls(StringRef selectedDialect) {
|
|||
// Emit the declarations.
|
||||
for (const AttrOrTypeDef &def : defs)
|
||||
emitDefDecl(def);
|
||||
}
|
||||
// Emit the TypeID explicit specializations to have a single definition for
|
||||
// each of these.
|
||||
for (const AttrOrTypeDef &def : defs)
|
||||
if (!def.getDialect().getCppNamespace().empty())
|
||||
os << "DECLARE_EXPLICIT_TYPE_ID(" << def.getDialect().getCppNamespace()
|
||||
<< "::" << def.getCppClassName() << ")\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -942,13 +934,8 @@ bool DefGenerator::emitDefs(StringRef selectedDialect) {
|
|||
|
||||
IfDefScope scope("GET_" + defTypePrefix.upper() + "DEF_CLASSES", os);
|
||||
emitParsePrintDispatch(defs);
|
||||
for (const AttrOrTypeDef &def : defs) {
|
||||
for (const AttrOrTypeDef &def : defs)
|
||||
emitDefDef(def);
|
||||
// Emit the TypeID explicit specializations to have a single symbol def.
|
||||
if (!def.getDialect().getCppNamespace().empty())
|
||||
os << "DEFINE_EXPLICIT_TYPE_ID(" << def.getDialect().getCppNamespace()
|
||||
<< "::" << def.getCppClassName() << ")\n";
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -198,7 +198,6 @@ static void emitDialectDecl(Dialect &dialect,
|
|||
}
|
||||
|
||||
// Emit all nested namespaces.
|
||||
{
|
||||
NamespaceEmitter nsEmitter(os, dialect);
|
||||
|
||||
// Emit the start of the decl.
|
||||
|
@ -226,16 +225,11 @@ static void emitDialectDecl(Dialect &dialect,
|
|||
os << regionResultAttrVerifierDecl;
|
||||
if (dialect.hasOperationInterfaceFallback())
|
||||
os << operationInterfaceFallbackDecl;
|
||||
if (llvm::Optional<StringRef> extraDecl =
|
||||
dialect.getExtraClassDeclaration())
|
||||
if (llvm::Optional<StringRef> extraDecl = dialect.getExtraClassDeclaration())
|
||||
os << *extraDecl;
|
||||
|
||||
// End the dialect decl.
|
||||
os << "};\n";
|
||||
}
|
||||
if (!dialect.getCppNamespace().empty())
|
||||
os << "DECLARE_EXPLICIT_TYPE_ID(" << dialect.getCppNamespace()
|
||||
<< "::" << dialect.getCppClassName() << ")\n";
|
||||
}
|
||||
|
||||
static bool emitDialectDecls(const llvm::RecordKeeper &recordKeeper,
|
||||
|
@ -269,11 +263,6 @@ static const char *const dialectDestructorStr = R"(
|
|||
)";
|
||||
|
||||
static void emitDialectDef(Dialect &dialect, raw_ostream &os) {
|
||||
// Emit the TypeID explicit specializations to have a single symbol def.
|
||||
if (!dialect.getCppNamespace().empty())
|
||||
os << "DEFINE_EXPLICIT_TYPE_ID(" << dialect.getCppNamespace()
|
||||
<< "::" << dialect.getCppClassName() << ")\n";
|
||||
|
||||
// Emit all nested namespaces.
|
||||
NamespaceEmitter nsEmitter(os, dialect);
|
||||
|
||||
|
|
|
@ -650,6 +650,7 @@ OpEmitter::OpEmitter(const Operator &op,
|
|||
generateOpFormat(op, opClass);
|
||||
genSideEffectInterfaceMethods();
|
||||
}
|
||||
|
||||
void OpEmitter::emitDecl(
|
||||
const Operator &op, raw_ostream &os,
|
||||
const StaticVerifierFunctionEmitter &staticVerifierEmitter) {
|
||||
|
@ -2575,30 +2576,16 @@ static void emitOpClasses(const RecordKeeper &recordKeeper,
|
|||
emitDecl);
|
||||
for (auto *def : defs) {
|
||||
Operator op(*def);
|
||||
if (emitDecl) {
|
||||
{
|
||||
NamespaceEmitter emitter(os, op.getCppNamespace());
|
||||
os << formatv(opCommentHeader, op.getQualCppClassName(),
|
||||
"declarations");
|
||||
if (emitDecl) {
|
||||
os << formatv(opCommentHeader, op.getQualCppClassName(), "declarations");
|
||||
OpOperandAdaptorEmitter::emitDecl(op, os);
|
||||
OpEmitter::emitDecl(op, os, staticVerifierEmitter);
|
||||
}
|
||||
// Emit the TypeID explicit specialization to have a single definition.
|
||||
if (!op.getCppNamespace().empty())
|
||||
os << "DECLARE_EXPLICIT_TYPE_ID(" << op.getCppNamespace()
|
||||
<< "::" << op.getCppClassName() << ")\n\n";
|
||||
} else {
|
||||
{
|
||||
NamespaceEmitter emitter(os, op.getCppNamespace());
|
||||
os << formatv(opCommentHeader, op.getQualCppClassName(), "definitions");
|
||||
OpOperandAdaptorEmitter::emitDef(op, os);
|
||||
OpEmitter::emitDef(op, os, staticVerifierEmitter);
|
||||
}
|
||||
// Emit the TypeID explicit specialization to have a single definition.
|
||||
if (!op.getCppNamespace().empty())
|
||||
os << "DEFINE_EXPLICIT_TYPE_ID(" << op.getCppNamespace()
|
||||
<< "::" << op.getCppClassName() << ")\n\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue