Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 06f0802

Browse files
committed
Porting Clang rC324498 to Emscripten.
This change adds option to manually control whether to discard value names in LLVM IRs generated by Clang. Upstream change can be viewed at: https://reviews.llvm.org/rC324498
1 parent 605a43b commit 06f0802

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

include/clang/Driver/Options.td

+4
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,10 @@ def fdiagnostics_show_template_tree : Flag<["-"], "fdiagnostics-show-template-tr
786786
HelpText<"Print a template comparison tree for differing templates">;
787787
def fdeclspec : Flag<["-"], "fdeclspec">, Group<f_clang_Group>,
788788
HelpText<"Allow __declspec as a keyword">, Flags<[CC1Option]>;
789+
def fdiscard_value_names : Flag<["-"], "fdiscard-value-names">, Group<f_clang_Group>,
790+
HelpText<"Discard value names in LLVM IR">, Flags<[DriverOption]>;
791+
def fno_discard_value_names : Flag<["-"], "fno-discard-value-names">, Group<f_clang_Group>,
792+
HelpText<"Do not discard value names in LLVM IR">, Flags<[DriverOption]>;
789793
def fdollars_in_identifiers : Flag<["-"], "fdollars-in-identifiers">, Group<f_Group>,
790794
HelpText<"Allow '$' in identifiers">, Flags<[CC1Option]>;
791795
def fdwarf2_cfi_asm : Flag<["-"], "fdwarf2-cfi-asm">, Group<clang_ignored_f_Group>;

lib/Driver/ToolChains/Clang.cpp

+16-3
Original file line numberDiff line numberDiff line change
@@ -3226,11 +3226,24 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
32263226

32273227
// Disable the verification pass in -asserts builds.
32283228
#ifdef NDEBUG
3229-
CmdArgs.push_back("-disable-llvm-verifier");
3230-
// Discard LLVM value names in -asserts builds.
3231-
CmdArgs.push_back("-discard-value-names");
3229+
const bool IsAssertBuild = false;
3230+
#else
3231+
const bool IsAssertBuild = true;
32323232
#endif
32333233

3234+
// Disable the verification pass in -asserts builds.
3235+
if (!IsAssertBuild)
3236+
CmdArgs.push_back("-disable-llvm-verifier");
3237+
3238+
// Discard value names in assert builds unless otherwise specified.
3239+
if (const Arg *A = Args.getLastArg(options::OPT_fdiscard_value_names,
3240+
options::OPT_fno_discard_value_names)) {
3241+
if (A->getOption().matches(options::OPT_fdiscard_value_names))
3242+
CmdArgs.push_back("-discard-value-names");
3243+
} else if (!IsAssertBuild)
3244+
CmdArgs.push_back("-discard-value-names");
3245+
3246+
32343247
// Set the main file name, so that debug info works even with
32353248
// -save-temps.
32363249
CmdArgs.push_back("-main-file-name");

0 commit comments

Comments
 (0)