summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorFrancis Visoiu Mistrih <francisvm@yahoo.com>2019-11-18 10:09:31 -0800
committerFrancis Visoiu Mistrih <francisvm@yahoo.com>2019-11-18 10:38:10 -0800
commitb4e2b112b58154a89171df39dae80044865ff4ff (patch)
treeadca3f65a1a2250cc23fa1eb79a4d1830b288a20 /clang/lib
parent1689ad27af5c5712f42542807eb4ecdfe84c2eca (diff)
downloadbcm5719-llvm-b4e2b112b58154a89171df39dae80044865ff4ff.tar.gz
bcm5719-llvm-b4e2b112b58154a89171df39dae80044865ff4ff.zip
[Remarks][Driver] Use different remark files when targeting multiple architectures
When the driver is targeting multiple architectures at once, for things like Universal Mach-Os, we need to emit different remark files for each cc1 invocation to avoid overwriting the files from a different invocation. For example: $ clang -c -o foo.o -fsave-optimization-record -arch x86_64 -arch x86_64h will create two remark files: * foo-x86_64.opt.yaml * foo-x86_64h.opt.yaml
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Driver/ToolChains/Clang.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 2b1c24275e3..f5591c48d4e 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5403,6 +5403,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
if (A) {
CmdArgs.push_back(A->getValue());
} else {
+ bool hasMultipleArchs =
+ Args.getAllArgValues(options::OPT_arch).size() > 1;
SmallString<128> F;
if (Args.hasArg(options::OPT_c) || Args.hasArg(options::OPT_S)) {
@@ -5427,6 +5429,22 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
}
}
+ // If we're having more than one "-arch", we should name the files
+ // differently so that every cc1 invocation writes to a different file.
+ // We're doing that by appending "-<arch>" with "<arch>" being the arch
+ // name from the triple.
+ if (hasMultipleArchs) {
+ // First, remember the extension.
+ SmallString<64> OldExtension = llvm::sys::path::extension(F);
+ // then, remove it.
+ llvm::sys::path::replace_extension(F, "");
+ // attach -<arch> to it.
+ F += "-";
+ F += Triple.getArchName();
+ // put back the extension.
+ llvm::sys::path::replace_extension(F, OldExtension);
+ }
+
std::string Extension = "opt.";
if (const Arg *A =
Args.getLastArg(options::OPT_fsave_optimization_record_EQ))
OpenPOWER on IntegriCloud