[PATCH] D22883: Add flags to toggle preservation of assembly comments
Eric Christopher via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 27 12:24:23 PDT 2016
Ok
On Wed, Jul 27, 2016, 12:22 PM Nirav Dave <niravd at google.com> wrote:
> niravd created this revision.
> niravd added reviewers: echristo, rnk.
> niravd added a subscriber: llvm-commits.
> Herald added a subscriber: mehdi_amini.
>
> Add -fpreserve-as-comments and -fno-preserve-as-comments.
>
> https://reviews.llvm.org/D22883
>
> Files:
> include/clang/Driver/Options.td
> include/clang/Frontend/CodeGenOptions.def
> lib/CodeGen/BackendUtil.cpp
> lib/Driver/Tools.cpp
> lib/Frontend/CompilerInvocation.cpp
> test/CodeGen/preserve-as-comments.c
>
> Index: test/CodeGen/preserve-as-comments.c
> ===================================================================
> --- /dev/null
> +++ test/CodeGen/preserve-as-comments.c
> @@ -0,0 +1,12 @@
> +// RUN: %clang_cc1 -S -fno-preserve-as-comments %s -o - | FileCheck %s
> --check-prefix=NOASM --check-prefix=CHECK
> +// RUN: %clang_cc1 -S %s -o - | FileCheck %s --check-prefix=ASM
> --check-prefix=CHECK
> +
> +// CHECK-LABEL: main
> +// CHECK: #APP
> +// ASM: #comment
> +// NOASM-NOT: #comment
> +// CHECK: #NO_APP
> +int main() {
> + __asm__("/*comment*/");
> + return 0;
> +}
> Index: lib/Frontend/CompilerInvocation.cpp
> ===================================================================
> --- lib/Frontend/CompilerInvocation.cpp
> +++ lib/Frontend/CompilerInvocation.cpp
> @@ -544,6 +544,7 @@
> Args.hasFlag(OPT_fcoverage_mapping, OPT_fno_coverage_mapping,
> false);
> Opts.DumpCoverageMapping = Args.hasArg(OPT_dump_coverage_mapping);
> Opts.AsmVerbose = Args.hasArg(OPT_masm_verbose);
> + Opts.PreserveAsmComments = !Args.hasArg(OPT_fno_preserve_as_comments);
> Opts.AssumeSaneOperatorNew =
> !Args.hasArg(OPT_fno_assume_sane_operator_new);
> Opts.ObjCAutoRefCountExceptions = Args.hasArg(OPT_fobjc_arc_exceptions);
> Opts.CXAAtExit = !Args.hasArg(OPT_fno_use_cxa_atexit);
> Index: lib/Driver/Tools.cpp
> ===================================================================
> --- lib/Driver/Tools.cpp
> +++ lib/Driver/Tools.cpp
> @@ -4193,6 +4193,10 @@
> true))
> CmdArgs.push_back("-fno-jump-tables");
>
> + if (!Args.hasFlag(options::OPT_fpreserve_as_comments,
> + options::OPT_fno_preserve_as_comments, true))
> + CmdArgs.push_back("-fno-preserve-as-comments");
> +
> if (Arg *A = Args.getLastArg(options::OPT_mregparm_EQ)) {
> CmdArgs.push_back("-mregparm");
> CmdArgs.push_back(A->getValue());
> Index: lib/CodeGen/BackendUtil.cpp
> ===================================================================
> --- lib/CodeGen/BackendUtil.cpp
> +++ lib/CodeGen/BackendUtil.cpp
> @@ -604,6 +604,7 @@
> CodeGenOpts.IncrementalLinkerCompatible;
> Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings;
> Options.MCOptions.AsmVerbose = CodeGenOpts.AsmVerbose;
> + Options.MCOptions.PreserveAsmComments = CodeGenOpts.PreserveAsmComments;
> Options.MCOptions.ABIName = TargetOpts.ABI;
>
> TM.reset(TheTarget->createTargetMachine(Triple, TargetOpts.CPU,
> FeaturesStr,
> Index: include/clang/Frontend/CodeGenOptions.def
> ===================================================================
> --- include/clang/Frontend/CodeGenOptions.def
> +++ include/clang/Frontend/CodeGenOptions.def
> @@ -32,6 +32,7 @@
> CODEGENOPT(CompressDebugSections, 1, 0) ///< -Wa,-compress-debug-sections
> CODEGENOPT(RelaxELFRelocations, 1, 0) ///< -Wa,--mrelax-relocations
> CODEGENOPT(AsmVerbose , 1, 0) ///< -dA, -fverbose-asm.
> +CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.
> CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit
> __attribute__((malloc)) operator new
> CODEGENOPT(Autolink , 1, 1) ///< -fno-autolink
> CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should be
> EH-safe.
> Index: include/clang/Driver/Options.td
> ===================================================================
> --- include/clang/Driver/Options.td
> +++ include/clang/Driver/Options.td
> @@ -1089,6 +1089,9 @@
> def fno_pie : Flag<["-"], "fno-pie">, Group<f_Group>;
> def fplugin_EQ : Joined<["-"], "fplugin=">, Group<f_Group>,
> Flags<[DriverOption]>, MetaVarName<"<dsopath>">,
> HelpText<"Load the named plugin (dynamic shared object)">;
> +def fpreserve_as_comments : Flag<["-"], "fpreserve-as-comments">,
> Group<f_Group>;
> +def fno_preserve_as_comments : Flag<["-"], "fno-preserve-as-comments">,
> Group<f_Group>, Flags<[CC1Option]>,
> + HelpText<"Do not preserve comments in inline assembly">;
> def fprofile_arcs : Flag<["-"], "fprofile-arcs">, Group<f_Group>;
> def fno_profile_arcs : Flag<["-"], "fno-profile-arcs">, Group<f_Group>;
> def framework : Separate<["-"], "framework">, Flags<[LinkerInput]>;
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160727/c9435b19/attachment.html>
More information about the llvm-commits
mailing list