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).
80 lines
3.5 KiB
C++
80 lines
3.5 KiB
C++
//===-- CommandLineOpts.cpp -- shared command line options ------*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// This file defines some shared command-line options that can be used when
|
|
/// debugging the test tools.
|
|
|
|
#include "flang/Optimizer/Passes/CommandLineOpts.h"
|
|
|
|
using namespace llvm;
|
|
|
|
#define DisableOption(DOName, DOOption, DODescription) \
|
|
cl::opt<bool> disable##DOName("disable-" DOOption, \
|
|
cl::desc("disable " DODescription " pass"), \
|
|
cl::init(false), cl::Hidden)
|
|
#define EnableOption(EOName, EOOption, EODescription) \
|
|
cl::opt<bool> enable##EOName("enable-" EOOption, \
|
|
cl::desc("enable " EODescription " pass"), \
|
|
cl::init(false), cl::Hidden)
|
|
|
|
cl::opt<bool> dynamicArrayStackToHeapAllocation(
|
|
"fdynamic-heap-array",
|
|
cl::desc("place all array allocations of dynamic size on the heap"),
|
|
cl::init(false), cl::Hidden);
|
|
|
|
cl::opt<std::size_t> arrayStackAllocationThreshold(
|
|
"fstack-array-size",
|
|
cl::desc(
|
|
"place all array allocations more than <size> elements on the heap"),
|
|
cl::init(~static_cast<std::size_t>(0)), cl::Hidden);
|
|
|
|
cl::opt<bool> ignoreMissingTypeDescriptors(
|
|
"ignore-missing-type-desc",
|
|
cl::desc("ignore failures to find derived type descriptors when "
|
|
"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};
|
|
|
|
/// Optimizer Passes
|
|
DisableOption(CfgConversion, "cfg-conversion", "disable FIR to CFG pass");
|
|
DisableOption(FirAvc, "avc", "array value copy analysis and transformation");
|
|
DisableOption(FirMao, "memory-allocation-opt",
|
|
"memory allocation optimization");
|
|
|
|
DisableOption(FirAliasTags, "fir-alias-tags", "fir alias analysis");
|
|
cl::opt<bool> useOldAliasTags(
|
|
"use-old-alias-tags",
|
|
cl::desc("Use a single TBAA tree for all functions and do not use "
|
|
"the FIR alias tags pass"),
|
|
cl::init(false), cl::Hidden);
|
|
|
|
/// CodeGen Passes
|
|
DisableOption(CodeGenRewrite, "codegen-rewrite", "rewrite FIR for codegen");
|
|
DisableOption(TargetRewrite, "target-rewrite", "rewrite FIR for target");
|
|
DisableOption(DebugInfo, "debug-info", "Add debug info");
|
|
DisableOption(FirToLlvmIr, "fir-to-llvmir", "FIR to LLVM-IR dialect");
|
|
DisableOption(LlvmIrToLlvm, "llvm", "conversion to LLVM");
|
|
DisableOption(BoxedProcedureRewrite, "boxed-procedure-rewrite",
|
|
"rewrite boxed procedures");
|
|
|
|
DisableOption(ExternalNameConversion, "external-name-interop",
|
|
"convert names with external convention");
|
|
EnableOption(ConstantArgumentGlobalisation, "constant-argument-globalisation",
|
|
"the local constant argument to global constant conversion");
|
|
DisableOption(CompilerGeneratedNamesConversion, "compiler-generated-names",
|
|
"replace special symbols in compiler generated names");
|