diff options
author | Daniel Jasper <djasper@google.com> | 2015-07-10 08:25:54 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2015-07-10 08:25:54 +0000 |
commit | 7450f91716d02c18a96de2a9d8ae9849f09a6dc9 (patch) | |
tree | bf9a4682cb6e76aa72bc6dcafe5a50b831bb0a19 /clang/lib/Driver/Tools.cpp | |
parent | db82d2f33827dc44dc0076ad26a1a0f4638719c5 (diff) | |
download | bcm5719-llvm-7450f91716d02c18a96de2a9d8ae9849f09a6dc9.tar.gz bcm5719-llvm-7450f91716d02c18a96de2a9d8ae9849f09a6dc9.zip |
Re-use a single SmallString instance to reduce the stack frame size
In certain builds (msan), this can otherwise exceed the stack frame
limit set for certain environments.
llvm-svn: 241894
Diffstat (limited to 'clang/lib/Driver/Tools.cpp')
-rw-r--r-- | clang/lib/Driver/Tools.cpp | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 6a1ac112d4f..d692a7f161b 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -3547,6 +3547,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, << ProfileGenerateArg->getSpelling() << ProfileUseArg->getSpelling(); + SmallString<128> Path; if (ProfileGenerateArg && ProfileGenerateArg->getOption().matches( options::OPT_fprofile_instr_generate_EQ)) @@ -3554,7 +3555,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, else if (ProfileGenerateArg && ProfileGenerateArg->getOption().matches( options::OPT_fprofile_generate_EQ)) { - SmallString<128> Path(ProfileGenerateArg->getValue()); + Path = ProfileGenerateArg->getValue(); llvm::sys::path::append(Path, "default.profraw"); CmdArgs.push_back( Args.MakeArgString(Twine("-fprofile-instr-generate=") + Path)); @@ -3568,8 +3569,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, (ProfileUseArg->getOption().matches(options::OPT_fprofile_use_EQ) || ProfileUseArg->getOption().matches( options::OPT_fprofile_instr_use))) { - SmallString<128> Path( - ProfileUseArg->getNumValues() == 0 ? "" : ProfileUseArg->getValue()); + Path = ProfileUseArg->getNumValues() == 0 ? "" : ProfileUseArg->getValue(); if (Path.empty() || llvm::sys::fs::is_directory(Path)) llvm::sys::path::append(Path, "default.profdata"); CmdArgs.push_back(Args.MakeArgString(Twine("-fprofile-instr-use=") + Path)); @@ -3602,10 +3602,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, CoverageFilename = llvm::sys::path::filename(Output.getBaseInput()); } if (llvm::sys::path::is_relative(CoverageFilename)) { - SmallString<128> Pwd; - if (!llvm::sys::fs::current_path(Pwd)) { - llvm::sys::path::append(Pwd, CoverageFilename); - CoverageFilename.swap(Pwd); + if (!llvm::sys::fs::current_path(Path)) { + llvm::sys::path::append(Path, CoverageFilename); + CoverageFilename.swap(Path); } } CmdArgs.push_back(Args.MakeArgString(CoverageFilename)); @@ -4196,27 +4195,27 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // -fmodule-cache-path specifies where our implicitly-built module files // should be written. - SmallString<128> ModuleCachePath; + Path = ""; if (Arg *A = Args.getLastArg(options::OPT_fmodules_cache_path)) - ModuleCachePath = A->getValue(); + Path = A->getValue(); if (HaveModules) { if (C.isForDiagnostics()) { // When generating crash reports, we want to emit the modules along with // the reproduction sources, so we ignore any provided module path. - ModuleCachePath = Output.getFilename(); - llvm::sys::path::replace_extension(ModuleCachePath, ".cache"); - llvm::sys::path::append(ModuleCachePath, "modules"); - } else if (ModuleCachePath.empty()) { + Path = Output.getFilename(); + llvm::sys::path::replace_extension(Path, ".cache"); + llvm::sys::path::append(Path, "modules"); + } else if (Path.empty()) { // No module path was provided: use the default. llvm::sys::path::system_temp_directory(/*erasedOnReboot=*/false, - ModuleCachePath); - llvm::sys::path::append(ModuleCachePath, "org.llvm.clang."); - appendUserToPath(ModuleCachePath); - llvm::sys::path::append(ModuleCachePath, "ModuleCache"); + Path); + llvm::sys::path::append(Path, "org.llvm.clang."); + appendUserToPath(Path); + llvm::sys::path::append(Path, "ModuleCache"); } const char Arg[] = "-fmodules-cache-path="; - ModuleCachePath.insert(ModuleCachePath.begin(), Arg, Arg + strlen(Arg)); - CmdArgs.push_back(Args.MakeArgString(ModuleCachePath)); + Path.insert(Path.begin(), Arg, Arg + strlen(Arg)); + CmdArgs.push_back(Args.MakeArgString(Path)); } // When building modules and generating crashdumps, we need to dump a module |