Index: cfe/trunk/include/clang/Driver/Options.td =================================================================== --- cfe/trunk/include/clang/Driver/Options.td +++ cfe/trunk/include/clang/Driver/Options.td @@ -1089,6 +1089,9 @@ def fno_pie : Flag<["-"], "fno-pie">, Group; def fplugin_EQ : Joined<["-"], "fplugin=">, Group, Flags<[DriverOption]>, MetaVarName<"">, HelpText<"Load the named plugin (dynamic shared object)">; +def fpreserve_as_comments : Flag<["-"], "fpreserve-as-comments">, Group; +def fno_preserve_as_comments : Flag<["-"], "fno-preserve-as-comments">, Group, Flags<[CC1Option]>, + HelpText<"Do not preserve comments in inline assembly">; def fprofile_arcs : Flag<["-"], "fprofile-arcs">, Group; def fno_profile_arcs : Flag<["-"], "fno-profile-arcs">, Group; def framework : Separate<["-"], "framework">, Flags<[LinkerInput]>; Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.def =================================================================== --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def +++ cfe/trunk/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: cfe/trunk/lib/CodeGen/BackendUtil.cpp =================================================================== --- cfe/trunk/lib/CodeGen/BackendUtil.cpp +++ cfe/trunk/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: cfe/trunk/lib/Driver/Tools.cpp =================================================================== --- cfe/trunk/lib/Driver/Tools.cpp +++ cfe/trunk/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: cfe/trunk/lib/Frontend/CompilerInvocation.cpp =================================================================== --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp +++ cfe/trunk/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: cfe/trunk/test/CodeGen/preserve-as-comments.c =================================================================== --- cfe/trunk/test/CodeGen/preserve-as-comments.c +++ cfe/trunk/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; +}