Skip to content

Commit

Permalink
Merge pull request #34 from vjayathirtha-nv/release_60
Browse files Browse the repository at this point in the history
Add -Minfo, -Mneginfo flags.
  • Loading branch information
sscalpone authored Aug 24, 2018
2 parents 79937ec + 1dd735e commit 742de5f
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/clang/Basic/DiagnosticDriverKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ def warn_drv_omp_offload_target_duplicate : Warning<
InGroup<OpenMPTarget>;
def err_drv_bitcode_unsupported_on_toolchain : Error<
"-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
def err_drv_clang_unsupported_minfo_arg : Error<
"'%0' option does not support '%1' value">;

def warn_O4_is_O3 : Warning<"-O4 is equivalent to -O3">, InGroup<Deprecated>;
def warn_drv_optimization_value : Warning<"optimization level '%0' is not supported; using '%1%2' instead">,
Expand Down
10 changes: 10 additions & 0 deletions include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -2846,6 +2846,16 @@ def Mfreeform_off: Flag<["-"], "Mnofreeform">, Group<fortran_format_Group>,
HelpText<"Disable free-form format for Fortran">,
Flags<[HelpHidden]>;

def Minfo_EQ : CommaJoined<["-"], "Minfo=">,
HelpText<"Diagnostic information about successful optimizations">,
Values<"all,vect,inline">;
def Minfoall : Flag<["-"], "Minfo">,
HelpText<"Diagnostic information about all successful optimizations">;
def Mneginfo_EQ : CommaJoined<["-"], "Mneginfo=">,
HelpText<"Diagnostic information about missed optimizations">,
Values<"all,vect,inline">;
def Mneginfoall : Flag<["-"], "Mneginfo">,
HelpText<"Diagnostic information about all missed optimizations">;
def Mipa: Joined<["-"], "Mipa">, Group<pgi_fortran_Group>;
def Mstackarrays: Joined<["-"], "Mstack_arrays">, Group<pgi_fortran_Group>;
def pc: JoinedOrSeparate<["-"], "pc">, Group<pgi_fortran_Group>;
Expand Down
54 changes: 54 additions & 0 deletions lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3295,6 +3295,60 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
Args.AddLastArg(CmdArgs, options::OPT_fveclib);
#endif

std::string PassRemarkVal(""), PassRemarkOpt("");
if (Args.getLastArg(options::OPT_Minfoall)) {
PassRemarkVal = ".*";
Args.ClaimAllArgs(options::OPT_Minfoall);
} else if (Arg *A = Args.getLastArg(options::OPT_Minfo_EQ)) {
for (const StringRef &val : A->getValues()) {
if(val.equals("all")) {
PassRemarkVal = ".*";
break;
} else if(val.equals("inline") || val.equals("vect")) {
PassRemarkVal += PassRemarkVal.empty() ? "" : "|";
PassRemarkVal += val;
} else {
D.Diag(diag::err_drv_clang_unsupported_minfo_arg)
<< A->getOption().getName()
<< val.str();
break;
}
}
}
PassRemarkOpt = "-pass-remarks=" + PassRemarkVal;
CmdArgs.push_back("-mllvm");
CmdArgs.push_back(Args.MakeArgString(PassRemarkOpt));
Args.ClaimAllArgs(options::OPT_Minfo_EQ);
PassRemarkVal.clear();
PassRemarkOpt.clear();

if (Args.getLastArg(options::OPT_Mneginfoall)) {
PassRemarkVal = ".*";
Args.ClaimAllArgs(options::OPT_Mneginfoall);
} else if (Arg *A = Args.getLastArg(options::OPT_Mneginfo_EQ)) {
for (const StringRef &val : A->getValues()) {
if(val.equals("all")) {
PassRemarkVal = ".*";
break;
} else if(val.equals("inline") || val.equals("vect")) {
PassRemarkVal += PassRemarkVal.empty() ? "" : "|";
PassRemarkVal += val;
} else {
D.Diag(diag::err_drv_clang_unsupported_minfo_arg)
<< A->getOption().getName()
<< val.str();
break;
}
}
}
PassRemarkOpt = "-pass-remarks-missed=" + PassRemarkVal;
CmdArgs.push_back("-mllvm");
CmdArgs.push_back(Args.MakeArgString(PassRemarkOpt));
PassRemarkOpt = "-pass-remarks-analysis=" + PassRemarkVal;
CmdArgs.push_back("-mllvm");
CmdArgs.push_back(Args.MakeArgString(PassRemarkOpt));
Args.ClaimAllArgs(options::OPT_Mneginfo_EQ);

if (Args.hasFlag(options::OPT_fmerge_all_constants,
options::OPT_fno_merge_all_constants, false))
CmdArgs.push_back("-fmerge-all-constants");
Expand Down

0 comments on commit 742de5f

Please sign in to comment.