clang-cc: Eliminate cyclic dependency in initializing CodeGenOptions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88980 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2009-11-16 22:38:14 +00:00
Родитель 6d10ac9ef3
Коммит 6143ea28a9
3 изменённых файлов: 25 добавлений и 22 удалений

Просмотреть файл

@ -807,7 +807,9 @@ TargetTriple("triple",
// Option Object Construction
//===----------------------------------------------------------------------===//
void clang::InitializeCodeGenOptions(CodeGenOptions &Opts) {
void clang::InitializeCodeGenOptions(CodeGenOptions &Opts,
const LangOptions &Lang,
bool TimePasses) {
using namespace codegenoptions;
// -Os implies -O2
@ -827,6 +829,13 @@ void clang::InitializeCodeGenOptions(CodeGenOptions &Opts) {
Opts.SimplifyLibCalls = 1;
Opts.UnrollLoops = (Opts.OptimizationLevel > 1 && !OptSize);
// FIXME: Eliminate this dependency?
if (Lang.NoBuiltin)
Opts.SimplifyLibCalls = 0;
if (Lang.CPlusPlus)
Opts.NoCommon = 1;
Opts.TimePasses = TimePasses;
#ifdef NDEBUG
Opts.VerifyModule = 0;
#endif
@ -1068,8 +1077,7 @@ void clang::InitializePreprocessorOptions(PreprocessorOptions &Opts) {
void clang::InitializeLangOptions(LangOptions &Options,
FrontendOptions::InputKind IK,
TargetInfo &Target,
const CodeGenOptions &CodeGenOpts) {
TargetInfo &Target) {
using namespace langoptions;
bool NoPreprocess = false;
@ -1289,18 +1297,19 @@ void clang::InitializeLangOptions(LangOptions &Options,
// The __OPTIMIZE_SIZE__ define is tied to -Oz, which we don't support.
Options.OptimizeSize = 0;
Options.Optimize = !!CodeGenOpts.OptimizationLevel;
Options.Optimize = codegenoptions::OptSize || codegenoptions::OptLevel;
assert(PICLevel <= 2 && "Invalid value for -pic-level");
Options.PICLevel = PICLevel;
Options.GNUInline = !Options.C99;
// FIXME: This is affected by other options (-fno-inline).
// This is the __NO_INLINE__ define, which just depends on things like the
// optimization level and -fno-inline, not actually whether the backend has
// inlining enabled.
Options.NoInline = !CodeGenOpts.OptimizationLevel;
//
// FIXME: This is affected by other options (-fno-inline).
Options.NoInline = !codegenoptions::OptLevel;
Options.Static = StaticDefine;

Просмотреть файл

@ -29,22 +29,23 @@ class TargetOptions;
void InitializeAnalyzerOptions(AnalyzerOptions &Opts);
void InitializeCodeGenOptions(CodeGenOptions &Opts,
const LangOptions &Lang,
bool TimePasses);
void InitializeDependencyOutputOptions(DependencyOutputOptions &Opts);
void InitializeDiagnosticOptions(DiagnosticOptions &Opts);
void InitializeFrontendOptions(FrontendOptions &Opts);
void InitializeCodeGenOptions(CodeGenOptions &Opts);
void InitializeHeaderSearchOptions(HeaderSearchOptions &Opts,
llvm::StringRef BuiltinIncludePath,
const LangOptions &Lang);
void InitializeLangOptions(LangOptions &Options,
FrontendOptions::InputKind LK,
TargetInfo &Target,
const CodeGenOptions &CodeGenOpts);
TargetInfo &Target);
void InitializePreprocessorOptions(PreprocessorOptions &Opts);

Просмотреть файл

@ -165,10 +165,6 @@ ConstructCompilerInvocation(CompilerInvocation &Opts, Diagnostic &Diags,
if (!Target)
return 0;
// Initialize backend options, which may also be used to key some language
// options.
InitializeCodeGenOptions(Opts.getCodeGenOpts());
// Initialize frontend options.
InitializeFrontendOptions(Opts.getFrontendOpts());
@ -188,8 +184,7 @@ ConstructCompilerInvocation(CompilerInvocation &Opts, Diagnostic &Diags,
// code path to make this obvious.
IsAST = (IK == FrontendOptions::IK_AST);
if (!IsAST)
InitializeLangOptions(Opts.getLangOpts(), IK, *Target,
Opts.getCodeGenOpts());
InitializeLangOptions(Opts.getLangOpts(), IK, *Target);
// Initialize the static analyzer options.
InitializeAnalyzerOptions(Opts.getAnalyzerOpts());
@ -208,12 +203,10 @@ ConstructCompilerInvocation(CompilerInvocation &Opts, Diagnostic &Diags,
// Initialize the preprocessed output options.
InitializePreprocessorOutputOptions(Opts.getPreprocessorOutputOpts());
// Finalize some code generation options which are derived from other places.
if (Opts.getLangOpts().NoBuiltin)
Opts.getCodeGenOpts().SimplifyLibCalls = 0;
if (Opts.getLangOpts().CPlusPlus)
Opts.getCodeGenOpts().NoCommon = 1;
Opts.getCodeGenOpts().TimePasses = Opts.getFrontendOpts().ShowTimers;
// Initialize backend options, which may also be used to key some language
// options.
InitializeCodeGenOptions(Opts.getCodeGenOpts(), Opts.getLangOpts(),
Opts.getFrontendOpts().ShowTimers);
return Target.take();
}