Index: include/clang/Driver/Options.td =================================================================== --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1388,6 +1388,8 @@ HelpText<"Do not include column number on diagnostics">; def fno_show_source_location : Flag<["-"], "fno-show-source-location">, Group, Flags<[CC1Option]>, HelpText<"Do not include source location information with diagnostics">; +def fno_shrink_wrap : Flag<["-"], "fno-shrink-wrap">, Group, + Flags<[CC1Option]>, HelpText<"Disable shrink wrapping">; def fdiagnostics_absolute_paths : Flag<["-"], "fdiagnostics-absolute-paths">, Group, Flags<[CC1Option, CoreOption]>, HelpText<"Print absolute paths in diagnostics">; def fno_spell_checking : Flag<["-"], "fno-spell-checking">, Group, Index: lib/Driver/ToolChains/Clang.cpp =================================================================== --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -4047,6 +4047,11 @@ Args.AddLastArg(CmdArgs, options::OPT_ftrap_function_EQ); + if (Args.hasArg(options::OPT_fno_shrink_wrap)) { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("-enable-shrink-wrap=false"); + } + // -fno-strict-overflow implies -fwrapv if it isn't disabled, but // -fstrict-overflow won't turn off an explicitly enabled -fwrapv. if (Arg *A = Args.getLastArg(options::OPT_fwrapv, options::OPT_fno_wrapv)) { Index: test/Driver/shrink-wrap.c =================================================================== --- /dev/null +++ test/Driver/shrink-wrap.c @@ -0,0 +1,12 @@ +// RUN: %clang -### %s -fno-shrink-wrap 2> %t +// RUN: FileCheck --check-prefix=CHECK-NO < %t %s + +// The below case should be handled when shrink wrapping is available for all +// targets. + +// FIXME: %clang -### %s -fshrink-wrap 2> %t +// FIXME: FileCheck --check-prefix=CHECK-YES < %t %s + +// CHECK-NO: "-mllvm" "-enable-shrink-wrap=false" + +// CHECK-YES: "-mllvm" "-enable-shrink-wrap=true"