From a830c269ab55ec31cd67801039ab18007f6b6af3 Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Wed, 24 Nov 2021 11:56:01 -0800 Subject: [PATCH 1/2] address clang 10 warnings --- src/script_opt/ZAM/Ops.in | 2 +- src/script_opt/ZAM/Stmt.cc | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/script_opt/ZAM/Ops.in b/src/script_opt/ZAM/Ops.in index e1516bce99..d74cacc9d5 100644 --- a/src/script_opt/ZAM/Ops.in +++ b/src/script_opt/ZAM/Ops.in @@ -1099,7 +1099,7 @@ eval auto v = frame[z.v2].double_val; ZAM_run_time_error(z.loc, "underflow converting double to count"); break; } - if ( v > UINT64_MAX ) + if ( v > static_cast(UINT64_MAX) ) { ZAM_run_time_error(z.loc, "overflow converting double to count"); break; diff --git a/src/script_opt/ZAM/Stmt.cc b/src/script_opt/ZAM/Stmt.cc index 84ca6598aa..f6af240c95 100644 --- a/src/script_opt/ZAM/Stmt.cc +++ b/src/script_opt/ZAM/Stmt.cc @@ -379,6 +379,13 @@ const ZAMStmt ZAMCompiler::GenCond(const Expr* e, int& branch_v) else branch_v = 2; +// clang 10 gets perturbed that the indentation of the "default" in the +// following switch block doesn't match that of the cases that we include +// from "ZAM-Conds.h". It really shouldn't worry about indentation mismatches +// across included files since those are not indicative of possible +// logic errors, but Oh Well. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmisleading-indentation" switch ( e->Tag() ) { #include "ZAM-Conds.h" @@ -386,6 +393,7 @@ const ZAMStmt ZAMCompiler::GenCond(const Expr* e, int& branch_v) default: reporter->InternalError("bad expression type in ZAMCompiler::GenCond"); } +#pragma GCC diagnostic pop // Not reached. } From a2cec7463f8cade21f2310ea34cb925e69776cba Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Wed, 24 Nov 2021 12:17:16 -0800 Subject: [PATCH 2/2] suppress unneeded initializations --- src/script_opt/CPP/Driver.cc | 20 ++++++++++---------- src/script_opt/CPP/Inits.cc | 3 +++ src/script_opt/ScriptOpt.cc | 26 +++++++++++++------------- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/script_opt/CPP/Driver.cc b/src/script_opt/CPP/Driver.cc index dd7348ddca..5aec30b95a 100644 --- a/src/script_opt/CPP/Driver.cc +++ b/src/script_opt/CPP/Driver.cc @@ -64,6 +64,12 @@ void CPPCompile::Compile(bool report_uncompilable) // previously compiled instances of those if present. for ( const auto& func : funcs ) { + if ( func.ShouldSkip() ) + { + not_fully_compilable.insert(func.Func()->Name()); + continue; + } + if ( func.Func()->Flavor() != FUNC_FLAVOR_FUNCTION ) // Can't be called directly. continue; @@ -94,7 +100,6 @@ void CPPCompile::Compile(bool report_uncompilable) { TypePtr tp{NewRef{}, (Type*)(t)}; types.AddKey(tp, pfs.HashType(t)); - (void)RegisterType(tp); } // ### This doesn't work for -O add-C++ @@ -102,13 +107,6 @@ void CPPCompile::Compile(bool report_uncompilable) NL(); -#if 0 - for ( auto gi : all_global_info ) - Emit(gi->Declare()); - - NL(); -#endif - for ( auto& g : pfs.AllGlobals() ) CreateGlobal(g); @@ -126,7 +124,8 @@ void CPPCompile::Compile(bool report_uncompilable) // The scaffolding is now in place to go ahead and generate // the functions & lambdas. First declare them ... for ( const auto& func : funcs ) - DeclareFunc(func); + if ( ! func.ShouldSkip() ) + DeclareFunc(func); // We track lambdas by their internal names, because two different // LambdaExpr's can wind up referring to the same underlying lambda @@ -148,7 +147,8 @@ void CPPCompile::Compile(bool report_uncompilable) // ... and now generate their bodies. for ( const auto& func : funcs ) - CompileFunc(func); + if ( ! func.ShouldSkip() ) + CompileFunc(func); lambda_names.clear(); for ( const auto& l : pfs.Lambdas() ) diff --git a/src/script_opt/CPP/Inits.cc b/src/script_opt/CPP/Inits.cc index 2e51b95412..d462f19a82 100644 --- a/src/script_opt/CPP/Inits.cc +++ b/src/script_opt/CPP/Inits.cc @@ -240,6 +240,9 @@ void CPPCompile::GenStandaloneActivation() for ( const auto& func : funcs ) { + if ( func.ShouldSkip() ) + continue; + auto f = func.Func(); auto fname = BodyName(func); auto bname = Canonicalize(fname.c_str()) + "_zf"; diff --git a/src/script_opt/ScriptOpt.cc b/src/script_opt/ScriptOpt.cc index 2940b1b5ec..311f8d8e7b 100644 --- a/src/script_opt/ScriptOpt.cc +++ b/src/script_opt/ScriptOpt.cc @@ -382,19 +382,6 @@ static void generate_CPP(std::unique_ptr& pfs) auto hm = std::make_unique(hash_name.c_str()); - if ( analysis_options.gen_CPP ) - { - if ( analysis_options.only_func ) - { // deactivate all functions except the target one - for ( auto& func : funcs ) - { - auto fn = func.Func()->Name(); - if ( *analysis_options.only_func != fn ) - func.SetSkip(true); - } - } - } - const auto gen_name = hash_dir + "CPP-gen.cc"; const auto addl_name = hash_dir + "CPP-gen-addl.h"; @@ -551,6 +538,19 @@ void analyze_scripts() // No work to do, avoid profiling overhead. return; + if ( analysis_options.gen_CPP ) + { + if ( analysis_options.only_func ) + { // deactivate all functions except the target one + for ( auto& func : funcs ) + { + auto fn = func.Func()->Name(); + if ( *analysis_options.only_func != fn ) + func.SetSkip(true); + } + } + } + // Now that everything's parsed and BiF's have been initialized, // profile the functions. auto pfs = std::make_unique(funcs, is_CPP_compilable, false);