-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[flang] add option to generate runtime type info as external #145901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-flang-codegen @llvm/pr-subscribers-flang-fir-hlfir Author: None (jeanPerier) ChangesSo far flang generates runtime derived type info global definitions (as opposed to declaratin) for all the types used in the current compilation unit even when the derived types are defined in other compilation units. It is using linkonce_odr to achieve derived type descriptor address "uniqueness" aspect needed to match two derived type inside the runtime. This has two pros:
This comes at a big compile time cost because of all the extra globals and their definitions in apps with many and complex derived types. This patch adds and experimental option to only generate the rtti definition for the types defined in the current compilation unit and to only generate external declaration for the derived type descriptor object of types defined elsewhere. Note that objects compiled with this option are not compatible with object files compiled without because files compiled without it may drop the rtti for type they defined if it is not used in the compilation unit because of the linkonce_odr aspect. I am adding the option so that we can better measure the extra cost of the current approach on apps and allow speeding up some compilation where devirtualization does not matter (and the build config links to all module file object anyway). This is notably bringing great speed-ups to CP2K and WRF compilation times (I measured about 30% speed-up on CP2K compilation and 15% speed-up on WRF, although these numbers may vary due to the parallel aspect of these builds). Patch is 43.96 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/145901.diff 15 Files Affected:
diff --git a/flang/include/flang/Evaluate/tools.h b/flang/include/flang/Evaluate/tools.h
index e04621f71f9a7..3205a87a86eba 100644
--- a/flang/include/flang/Evaluate/tools.h
+++ b/flang/include/flang/Evaluate/tools.h
@@ -1575,6 +1575,7 @@ bool IsExtensibleType(const DerivedTypeSpec *);
bool IsSequenceOrBindCType(const DerivedTypeSpec *);
bool IsBuiltinDerivedType(const DerivedTypeSpec *derived, const char *name);
bool IsBuiltinCPtr(const Symbol &);
+bool IsFromBuiltinModule(const Symbol &);
bool IsEventType(const DerivedTypeSpec *);
bool IsLockType(const DerivedTypeSpec *);
bool IsNotifyType(const DerivedTypeSpec *);
diff --git a/flang/include/flang/Optimizer/CodeGen/CodeGen.h b/flang/include/flang/Optimizer/CodeGen/CodeGen.h
index 0398d0f248e08..93f07d8d5d4d9 100644
--- a/flang/include/flang/Optimizer/CodeGen/CodeGen.h
+++ b/flang/include/flang/Optimizer/CodeGen/CodeGen.h
@@ -39,6 +39,9 @@ struct FIRToLLVMPassOptions {
// that such programs would crash at runtime if the derived type descriptors
// are required by the runtime, so this is only an option to help debugging.
bool ignoreMissingTypeDescriptors = false;
+ // Similar to ignoreMissingTypeDescriptors, but generate external declaration
+ // for the missing type descriptor globals instead.
+ bool skipExternalRttiDefinition = false;
// Generate TBAA information for FIR types and memory accessing operations.
bool applyTBAA = false;
diff --git a/flang/include/flang/Optimizer/Passes/CommandLineOpts.h b/flang/include/flang/Optimizer/Passes/CommandLineOpts.h
index 1cfaf285e75e6..76ac9d0622d2b 100644
--- a/flang/include/flang/Optimizer/Passes/CommandLineOpts.h
+++ b/flang/include/flang/Optimizer/Passes/CommandLineOpts.h
@@ -32,6 +32,19 @@ extern llvm::cl::opt<std::size_t> arrayStackAllocationThreshold;
/// generated by the frontend.
extern llvm::cl::opt<bool> ignoreMissingTypeDescriptors;
+/// Shared option in tools to only generate rtti static object definitions for
+/// derived types defined in the current compilation unit. Derived type
+/// descriptor object for types defined in other objects will only be declared
+/// as external. This also changes the linkage of rtti objects defined in the
+/// current compilation unit from linkonce_odr to external so that unused rtti
+/// objects are retained and can be accessed from other compilation units. This
+/// is an experimental option to explore compilation speed improvements and is
+/// an ABI breaking change because of the linkage change.
+/// It will also require linking against module file objects of modules defining
+/// only types (even for trivial types without type bound procedures, which
+/// differs from most compilers).
+extern llvm::cl::opt<bool> skipExternalRttiDefinition;
+
/// Default optimization level used to create Flang pass pipeline is O0.
extern llvm::OptimizationLevel defaultOptLevel;
diff --git a/flang/include/flang/Optimizer/Support/Utils.h b/flang/include/flang/Optimizer/Support/Utils.h
index ec73af6ec72e9..83c936b7dcada 100644
--- a/flang/include/flang/Optimizer/Support/Utils.h
+++ b/flang/include/flang/Optimizer/Support/Utils.h
@@ -35,32 +35,6 @@ inline std::int64_t toInt(mlir::arith::ConstantOp cop) {
.getSExtValue();
}
-// Reconstruct binding tables for dynamic dispatch.
-using BindingTable = llvm::DenseMap<llvm::StringRef, unsigned>;
-using BindingTables = llvm::DenseMap<llvm::StringRef, BindingTable>;
-
-inline void buildBindingTables(BindingTables &bindingTables,
- mlir::ModuleOp mod) {
-
- // The binding tables are defined in FIR after lowering inside fir.type_info
- // operations. Go through each binding tables and store the procedure name and
- // binding index for later use by the fir.dispatch conversion pattern.
- for (auto typeInfo : mod.getOps<fir::TypeInfoOp>()) {
- unsigned bindingIdx = 0;
- BindingTable bindings;
- if (typeInfo.getDispatchTable().empty()) {
- bindingTables[typeInfo.getSymName()] = bindings;
- continue;
- }
- for (auto dtEntry :
- typeInfo.getDispatchTable().front().getOps<fir::DTEntryOp>()) {
- bindings[dtEntry.getMethod()] = bindingIdx;
- ++bindingIdx;
- }
- bindingTables[typeInfo.getSymName()] = bindings;
- }
-}
-
// Translate front-end KINDs for use in the IR and code gen.
inline std::vector<fir::KindTy>
fromDefaultKinds(const Fortran::common::IntrinsicTypeDefaultKinds &defKinds) {
diff --git a/flang/include/flang/Semantics/runtime-type-info.h b/flang/include/flang/Semantics/runtime-type-info.h
index e90d3ae8baf1e..6c5a061d1c1a2 100644
--- a/flang/include/flang/Semantics/runtime-type-info.h
+++ b/flang/include/flang/Semantics/runtime-type-info.h
@@ -38,6 +38,10 @@ RuntimeDerivedTypeTables BuildRuntimeDerivedTypeTables(SemanticsContext &);
/// to describe other derived types at runtime in flang descriptor.
constexpr char typeInfoBuiltinModule[]{"__fortran_type_info"};
+/// Name of the builtin derived type in __fortran_type_inf that is used for
+/// derived type descriptors.
+constexpr char typeDescriptorTypeName[]{"derivedtype"};
+
/// Name of the bindings descriptor component in the DerivedType type of the
/// __Fortran_type_info module
constexpr char bindingDescCompName[]{"binding"};
diff --git a/flang/lib/Evaluate/tools.cpp b/flang/lib/Evaluate/tools.cpp
index 68838564f87ba..fcacdb93d662b 100644
--- a/flang/lib/Evaluate/tools.cpp
+++ b/flang/lib/Evaluate/tools.cpp
@@ -2334,6 +2334,11 @@ bool IsBuiltinCPtr(const Symbol &symbol) {
return false;
}
+bool IsFromBuiltinModule(const Symbol &symbol) {
+ const Scope &scope{symbol.GetUltimate().owner()};
+ return IsSameModule(&scope, scope.context().GetBuiltinsScope());
+}
+
bool IsIsoCType(const DerivedTypeSpec *derived) {
return IsBuiltinDerivedType(derived, "c_ptr") ||
IsBuiltinDerivedType(derived, "c_funptr");
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index 8506b9a984e58..39addfa41d7c4 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -52,6 +52,7 @@
#include "flang/Optimizer/Dialect/FIROps.h"
#include "flang/Optimizer/Dialect/Support/FIRContext.h"
#include "flang/Optimizer/HLFIR/HLFIROps.h"
+#include "flang/Optimizer/Passes/CommandLineOpts.h"
#include "flang/Optimizer/Support/DataLayout.h"
#include "flang/Optimizer/Support/FatalError.h"
#include "flang/Optimizer/Support/InternalNames.h"
@@ -262,6 +263,7 @@ class TypeInfoConverter {
}
void createTypeInfo(Fortran::lower::AbstractConverter &converter) {
+ createTypeInfoForTypeDescriptorBuiltinType(converter);
while (!registeredTypeInfoA.empty()) {
currentTypeInfoStack = ®isteredTypeInfoB;
for (const TypeInfo &info : registeredTypeInfoA)
@@ -277,10 +279,22 @@ class TypeInfoConverter {
private:
void createTypeInfoOpAndGlobal(Fortran::lower::AbstractConverter &converter,
const TypeInfo &info) {
- Fortran::lower::createRuntimeTypeInfoGlobal(converter, info.symbol.get());
+ if (!::skipExternalRttiDefinition)
+ Fortran::lower::createRuntimeTypeInfoGlobal(converter, info.symbol.get());
createTypeInfoOp(converter, info);
}
+ void createTypeInfoForTypeDescriptorBuiltinType(
+ Fortran::lower::AbstractConverter &converter) {
+ if (registeredTypeInfoA.empty())
+ return;
+ auto builtinTypeInfoType = llvm::cast<fir::RecordType>(
+ converter.genType(registeredTypeInfoA[0].symbol.get()));
+ converter.getFirOpBuilder().createTypeInfoOp(
+ registeredTypeInfoA[0].loc, builtinTypeInfoType,
+ /*parentType=*/fir::RecordType{});
+ }
+
void createTypeInfoOp(Fortran::lower::AbstractConverter &converter,
const TypeInfo &info) {
fir::RecordType parentType{};
diff --git a/flang/lib/Lower/ConvertVariable.cpp b/flang/lib/Lower/ConvertVariable.cpp
index 6f818cd7dc303..5e09a23e74c2b 100644
--- a/flang/lib/Lower/ConvertVariable.cpp
+++ b/flang/lib/Lower/ConvertVariable.cpp
@@ -38,6 +38,7 @@
#include "flang/Optimizer/Dialect/FIROps.h"
#include "flang/Optimizer/Dialect/Support/FIRContext.h"
#include "flang/Optimizer/HLFIR/HLFIROps.h"
+#include "flang/Optimizer/Passes/CommandLineOpts.h"
#include "flang/Optimizer/Support/FatalError.h"
#include "flang/Optimizer/Support/InternalNames.h"
#include "flang/Optimizer/Support/Utils.h"
@@ -652,8 +653,13 @@ getLinkageAttribute(fir::FirOpBuilder &builder,
// Runtime type info for a same derived type is identical in each compilation
// unit. It desired to avoid having to link against module that only define a
// type. Therefore the runtime type info is generated everywhere it is needed
- // with `linkonce_odr` LLVM linkage.
- if (var.isRuntimeTypeInfoData())
+ // with `linkonce_odr` LLVM linkage (unless the skipExternalRttiDefinition
+ // option is set, in which case one will need to link against objects of
+ // modules defining types). Builtin objects rtti is always generated because
+ // the builtin module is currently not compiled or part of the runtime.
+ if (var.isRuntimeTypeInfoData() &&
+ (!::skipExternalRttiDefinition ||
+ Fortran::semantics::IsFromBuiltinModule(var.getSymbol())))
return builder.createLinkOnceODRLinkage();
if (var.isModuleOrSubmoduleVariable())
return {}; // external linkage
diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
index a3de3ae9d116a..2b018912b40e4 100644
--- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -1294,6 +1294,51 @@ genCUFAllocDescriptor(mlir::Location loc,
.getResult();
}
+/// Get the address of the type descriptor global variable that was created by
+/// lowering for derived type \p recType.
+template <typename ModOpTy>
+static mlir::Value
+getTypeDescriptor(ModOpTy mod, mlir::ConversionPatternRewriter &rewriter,
+ mlir::Location loc, fir::RecordType recType,
+ const fir::FIRToLLVMPassOptions &options) {
+ std::string name =
+ options.typeDescriptorsRenamedForAssembly
+ ? fir::NameUniquer::getTypeDescriptorAssemblyName(recType.getName())
+ : fir::NameUniquer::getTypeDescriptorName(recType.getName());
+ mlir::Type llvmPtrTy = ::getLlvmPtrType(mod.getContext());
+ if (auto global = mod.template lookupSymbol<fir::GlobalOp>(name))
+ return rewriter.create<mlir::LLVM::AddressOfOp>(loc, llvmPtrTy,
+ global.getSymName());
+ // The global may have already been translated to LLVM.
+ if (auto global = mod.template lookupSymbol<mlir::LLVM::GlobalOp>(name))
+ return rewriter.create<mlir::LLVM::AddressOfOp>(loc, llvmPtrTy,
+ global.getSymName());
+ // Type info derived types do not have type descriptors since they are the
+ // types defining type descriptors.
+ if (options.ignoreMissingTypeDescriptors ||
+ fir::NameUniquer::belongsToModule(
+ name, Fortran::semantics::typeInfoBuiltinModule))
+ return rewriter.create<mlir::LLVM::ZeroOp>(loc, llvmPtrTy);
+
+ if (!options.skipExternalRttiDefinition)
+ fir::emitFatalError(loc,
+ "runtime derived type info descriptor was not "
+ "generated and skipExternalRttiDefinition and "
+ "ignoreMissingTypeDescriptors options are not set");
+
+ // Rtti for a derived type defined in another compilation unit and for which
+ // rtti was not defined in lowering because of the skipExternalRttiDefinition
+ // option. Generate the object declaration now.
+ auto insertPt = rewriter.saveInsertionPoint();
+ rewriter.setInsertionPoint(mod.getBody(), mod.getBody()->end());
+ mlir::LLVM::GlobalOp global = rewriter.create<mlir::LLVM::GlobalOp>(
+ loc, llvmPtrTy, /*constant=*/true, mlir::LLVM::Linkage::External, name,
+ mlir::Attribute());
+ rewriter.restoreInsertionPoint(insertPt);
+ return rewriter.create<mlir::LLVM::AddressOfOp>(loc, llvmPtrTy,
+ global.getSymName());
+}
+
/// Common base class for embox to descriptor conversion.
template <typename OP>
struct EmboxCommonConversion : public fir::FIROpConversion<OP> {
@@ -1406,36 +1451,6 @@ struct EmboxCommonConversion : public fir::FIROpConversion<OP> {
stride);
}
- /// Get the address of the type descriptor global variable that was created by
- /// lowering for derived type \p recType.
- template <typename ModOpTy>
- mlir::Value
- getTypeDescriptor(ModOpTy mod, mlir::ConversionPatternRewriter &rewriter,
- mlir::Location loc, fir::RecordType recType) const {
- std::string name =
- this->options.typeDescriptorsRenamedForAssembly
- ? fir::NameUniquer::getTypeDescriptorAssemblyName(recType.getName())
- : fir::NameUniquer::getTypeDescriptorName(recType.getName());
- mlir::Type llvmPtrTy = ::getLlvmPtrType(mod.getContext());
- if (auto global = mod.template lookupSymbol<fir::GlobalOp>(name)) {
- return rewriter.create<mlir::LLVM::AddressOfOp>(loc, llvmPtrTy,
- global.getSymName());
- }
- if (auto global = mod.template lookupSymbol<mlir::LLVM::GlobalOp>(name)) {
- // The global may have already been translated to LLVM.
- return rewriter.create<mlir::LLVM::AddressOfOp>(loc, llvmPtrTy,
- global.getSymName());
- }
- // Type info derived types do not have type descriptors since they are the
- // types defining type descriptors.
- if (!this->options.ignoreMissingTypeDescriptors &&
- !fir::NameUniquer::belongsToModule(
- name, Fortran::semantics::typeInfoBuiltinModule))
- fir::emitFatalError(
- loc, "runtime derived type info descriptor was not generated");
- return rewriter.create<mlir::LLVM::ZeroOp>(loc, llvmPtrTy);
- }
-
template <typename ModOpTy>
mlir::Value populateDescriptor(mlir::Location loc, ModOpTy mod,
fir::BaseBoxType boxTy, mlir::Type inputType,
@@ -1500,7 +1515,8 @@ struct EmboxCommonConversion : public fir::FIROpConversion<OP> {
mlir::Type innerType = fir::unwrapInnerType(inputType);
if (innerType && mlir::isa<fir::RecordType>(innerType)) {
auto recTy = mlir::dyn_cast<fir::RecordType>(innerType);
- typeDesc = getTypeDescriptor(mod, rewriter, loc, recTy);
+ typeDesc =
+ getTypeDescriptor(mod, rewriter, loc, recTy, this->options);
} else {
// Unlimited polymorphic type descriptor with no record type. Set
// type descriptor address to a clean state.
@@ -1508,8 +1524,8 @@ struct EmboxCommonConversion : public fir::FIROpConversion<OP> {
loc, ::getLlvmPtrType(mod.getContext()));
}
} else {
- typeDesc = getTypeDescriptor(mod, rewriter, loc,
- fir::unwrapIfDerived(boxTy));
+ typeDesc = getTypeDescriptor(
+ mod, rewriter, loc, fir::unwrapIfDerived(boxTy), this->options);
}
}
if (typeDesc)
@@ -3021,22 +3037,10 @@ struct TypeDescOpConversion : public fir::FIROpConversion<fir::TypeDescOp> {
assert(mlir::isa<fir::RecordType>(inTy) && "expecting fir.type");
auto recordType = mlir::dyn_cast<fir::RecordType>(inTy);
auto module = typeDescOp.getOperation()->getParentOfType<mlir::ModuleOp>();
- std::string typeDescName =
- this->options.typeDescriptorsRenamedForAssembly
- ? fir::NameUniquer::getTypeDescriptorAssemblyName(
- recordType.getName())
- : fir::NameUniquer::getTypeDescriptorName(recordType.getName());
- auto llvmPtrTy = ::getLlvmPtrType(typeDescOp.getContext());
- if (auto global = module.lookupSymbol<mlir::LLVM::GlobalOp>(typeDescName)) {
- rewriter.replaceOpWithNewOp<mlir::LLVM::AddressOfOp>(
- typeDescOp, llvmPtrTy, global.getSymName());
- return mlir::success();
- } else if (auto global = module.lookupSymbol<fir::GlobalOp>(typeDescName)) {
- rewriter.replaceOpWithNewOp<mlir::LLVM::AddressOfOp>(
- typeDescOp, llvmPtrTy, global.getSymName());
- return mlir::success();
- }
- return mlir::failure();
+ mlir::Value typeDesc = getTypeDescriptor(
+ module, rewriter, typeDescOp.getLoc(), recordType, this->options);
+ rewriter.replaceOp(typeDescOp, typeDesc);
+ return mlir::success();
}
};
diff --git a/flang/lib/Optimizer/Passes/CommandLineOpts.cpp b/flang/lib/Optimizer/Passes/CommandLineOpts.cpp
index f95a280883cba..014237542f24d 100644
--- a/flang/lib/Optimizer/Passes/CommandLineOpts.cpp
+++ b/flang/lib/Optimizer/Passes/CommandLineOpts.cpp
@@ -39,6 +39,12 @@ cl::opt<bool> ignoreMissingTypeDescriptors(
"translating FIR to LLVM"),
cl::init(false), cl::Hidden);
+cl::opt<bool> skipExternalRttiDefinition(
+ "skip-external-rtti-definition", llvm::cl::init(false),
+ llvm::cl::desc("do not define rtti static objects for types belonging to "
+ "other compilation units"),
+ cl::Hidden);
+
OptimizationLevel defaultOptLevel{OptimizationLevel::O0};
codegenoptions::DebugInfoKind noDebugInfo{codegenoptions::NoDebugInfo};
diff --git a/flang/lib/Optimizer/Passes/Pipelines.cpp b/flang/lib/Optimizer/Passes/Pipelines.cpp
index 70f57bdeddd3f..42d9e7ba2418f 100644
--- a/flang/lib/Optimizer/Passes/Pipelines.cpp
+++ b/flang/lib/Optimizer/Passes/Pipelines.cpp
@@ -108,6 +108,7 @@ void addFIRToLLVMPass(mlir::PassManager &pm,
const MLIRToLLVMPassPipelineConfig &config) {
fir::FIRToLLVMPassOptions options;
options.ignoreMissingTypeDescriptors = ignoreMissingTypeDescriptors;
+ options.skipExternalRttiDefinition = skipExternalRttiDefinition;
options.applyTBAA = config.AliasAnalysis;
options.forceUnifiedTBAATree = useOldAliasTags;
options.typeDescriptorsRenamedForAssembly =
diff --git a/flang/lib/Optimizer/Transforms/PolymorphicOpConversion.cpp b/flang/lib/Optimizer/Transforms/PolymorphicOpConversion.cpp
index f9a4c4d0283c7..57eae1ff052a2 100644
--- a/flang/lib/Optimizer/Transforms/PolymorphicOpConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/PolymorphicOpConversion.cpp
@@ -16,7 +16,6 @@
#include "flang/Optimizer/Dialect/Support/KindMapping.h"
#include "flang/Optimizer/Support/InternalNames.h"
#include "flang/Optimizer/Support/TypeCode.h"
-#include "flang/Optimizer/Support/Utils.h"
#include "flang/Optimizer/Transforms/Passes.h"
#include "flang/Runtime/derived-api.h"
#include "flang/Semantics/runtime-type-info.h"
@@ -38,6 +37,45 @@ namespace fir {
using namespace fir;
using namespace mlir;
+// Reconstruct binding tables for dynamic dispatch.
+using BindingTable = llvm::DenseMap<llvm::StringRef, unsigned>;
+using BindingTables = llvm::DenseMap<llvm::StringRef, BindingTable>;
+
+static std::string getTypeDescriptorTypeName() {
+ llvm::SmallVector<llvm::StringRef, 1> modules = {
+ Fortran::semantics::typeInfoBuiltinModule};
+ return fir::NameUniquer::doType(modules, /*proc=*/{}, /*blockId=*/0,
+ Fortran::semantics::typeDescriptorTypeName,
+ /*kinds=*/{});
+}
+
+static std::optional<mlir::Type>
+buildBindingTables(BindingTables &bindingTables, mlir::ModuleOp mod) {
+
+ std::optional<mlir::Type> typeDescriptorType;
+ std::string typeDescriptorTypeName = getTypeDescriptorTypeName();
+ // The binding tables are defined in FIR after lowering inside fir.type_info
+ // operations. Go through each binding tables and store the procedure name and
+ // binding index for later use by the fir.dispatch conversion pattern.
+ for (auto typeInfo : mod.getOps<fir::TypeInfoOp>()) {
+ if (!typeDescriptorType && typeInfo.getSymName() == typeDescriptorTypeName)
+ typeDescriptorType = typeInfo.getType();
+ unsigned bindingIdx = 0;
+ BindingTable bindings;
+ if (typeInfo.getDispatchTable().empty()) {
+ bindingTables[typeInfo.getSymName()] = bindings;
+ continue;
+ }
+ for (auto dtEntry :
+ typeInfo.getDispatchTable().front().getOps<fir::DTEntryOp>()) {
+ bindings[dtEntry.getMethod()] = bindingIdx;
+ ++bindingIdx;
+ }
+ bindingTables[typeInfo.getS...
[truncated]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thank you, Jean!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/204/builds/13662 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/203/builds/14849 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/205/builds/13639 Here is the relevant piece of the build log for the reference
|
…s external" (#146064) Reverts llvm/llvm-project#145901 Broke shared library builds because of the usage of `skipExternalRttiDefinition` in Lowering.
…5901) So far flang generates runtime derived type info global definitions (as opposed to declarations) for all the types used in the current compilation unit even when the derived types are defined in other compilation units. It is using linkonce_odr to achieve derived type descriptor address "uniqueness" aspect needed to match two derived type inside the runtime. This comes at a big compile time cost because of all the extra globals and their definitions in apps with many and complex derived types. This patch adds and experimental option to only generate the rtti definition for the types defined in the current compilation unit and to only generate external declaration for the derived type descriptor object of types defined elsewhere. Note that objects compiled with this option are not compatible with object files compiled without because files compiled without it may drop the rtti for type they defined if it is not used in the compilation unit because of the linkonce_odr aspect. I am adding the option so that we can better measure the extra cost of the current approach on apps and allow speeding up some compilation where devirtualization does not matter (and the build config links to all module file object anyway).
Reland #145901 with a fix for shared library builds. So far flang generates runtime derived type info global definitions (as opposed to declarations) for all the types used in the current compilation unit even when the derived types are defined in other compilation units. It is using linkonce_odr to achieve derived type descriptor address "uniqueness" aspect needed to match two derived type inside the runtime. This comes at a big compile time cost because of all the extra globals and their definitions in apps with many and complex derived types. This patch adds and experimental option to only generate the rtti definition for the types defined in the current compilation unit and to only generate external declaration for the derived type descriptor object of types defined elsewhere. Note that objects compiled with this option are not compatible with object files compiled without because files compiled without it may drop the rtti for type they defined if it is not used in the compilation unit because of the linkonce_odr aspect. I am adding the option so that we can better measure the extra cost of the current approach on apps and allow speeding up some compilation where devirtualization does not matter (and the build config links to all module file object anyway).
So far flang generates runtime derived type info global definitions (as opposed to declaration) for all the types used in the current compilation unit even when the derived types are defined in other compilation units. It is using linkonce_odr to achieve derived type descriptor address "uniqueness" aspect needed to match two derived type inside the runtime.
This has two pros:
This comes at a big compile time cost because of all the extra globals and their definitions in apps with many and complex derived types.
This patch adds and experimental option to only generate the rtti definition for the types defined in the current compilation unit and to only generate external declaration for the derived type descriptor object of types defined elsewhere.
Note that objects compiled with this option are not compatible with object files compiled without because files compiled without it may drop the rtti for type they defined if it is not used in the compilation unit because of the linkonce_odr aspect.
I am adding the option so that we can better measure the extra cost of the current approach on apps and allow speeding up some compilation where devirtualization does not matter (and the build config links to all module file object anyway).
This is notably bringing great speed-ups to CP2K and WRF compilation times (I measured about 30% speed-up on CP2K compilation and 15% speed-up on WRF, although these numbers may vary due to the parallel aspect of these builds).