forked from OSchip/llvm-project
Base optimization-record file names on the final output
Using Output.getFilename() to construct the file name used for optimization recording in Clang::ConstructJob, when -c is provided, does not work correctly if we're not using the integrated assembler. With -no-integrated-as (or -save-temps) Output.getFilename() gives the name of the temporary assembly file, not the final output file. Instead, use the final output (as provided by -o). If this is not available, then fall back to using a name based on the input file. Fixes PR31532. llvm-svn: 311041
This commit is contained in:
parent
2414429962
commit
67814df3ea
|
@ -4261,10 +4261,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
||||||
CmdArgs.push_back(A->getValue());
|
CmdArgs.push_back(A->getValue());
|
||||||
} else {
|
} else {
|
||||||
SmallString<128> F;
|
SmallString<128> F;
|
||||||
if (Output.isFilename() && (Args.hasArg(options::OPT_c) ||
|
|
||||||
Args.hasArg(options::OPT_S))) {
|
if (Args.hasArg(options::OPT_c) || Args.hasArg(options::OPT_S)) {
|
||||||
F = Output.getFilename();
|
if (Arg *FinalOutput = Args.getLastArg(options::OPT_o))
|
||||||
} else {
|
F = FinalOutput->getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (F.empty()) {
|
||||||
// Use the input filename.
|
// Use the input filename.
|
||||||
F = llvm::sys::path::stem(Input.getBaseInput());
|
F = llvm::sys::path::stem(Input.getBaseInput());
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,13 @@
|
||||||
// RUN: %clang -### -S -o FOO -fsave-optimization-record %s 2>&1 | FileCheck %s
|
// RUN: %clang -### -S -o FOO -fsave-optimization-record %s 2>&1 | FileCheck %s
|
||||||
// RUN: %clang -### -c -o FOO -fsave-optimization-record %s 2>&1 | FileCheck %s
|
// RUN: %clang -### -c -o FOO -fsave-optimization-record %s 2>&1 | FileCheck %s
|
||||||
|
// RUN: %clang -### -c -o FOO.o -fsave-optimization-record %s 2>&1 | FileCheck %s
|
||||||
|
// RUN: %clang -### -no-integrated-as -S -o FOO -fsave-optimization-record %s 2>&1 | FileCheck %s
|
||||||
|
// RUN: %clang -### -no-integrated-as -c -o FOO.o -fsave-optimization-record %s 2>&1 | FileCheck %s
|
||||||
|
// RUN: %clang -### -save-temps -S -o FOO -fsave-optimization-record %s 2>&1 | FileCheck %s
|
||||||
|
// RUN: %clang -### -save-temps -c -o FOO.o -fsave-optimization-record %s 2>&1 | FileCheck %s
|
||||||
// RUN: %clang -### -c -fsave-optimization-record %s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O
|
// RUN: %clang -### -c -fsave-optimization-record %s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O
|
||||||
|
// RUN: %clang -### -no-integrated-as -c -fsave-optimization-record %s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O
|
||||||
|
// RUN: %clang -### -save-temps -c -fsave-optimization-record %s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O
|
||||||
// RUN: %clang -### -fsave-optimization-record %s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O
|
// RUN: %clang -### -fsave-optimization-record %s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O
|
||||||
// RUN: %clang -### -S -fsave-optimization-record -x cuda -nocudainc -nocudalib %s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O -check-prefix=CHECK-CUDA-DEV
|
// RUN: %clang -### -S -fsave-optimization-record -x cuda -nocudainc -nocudalib %s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O -check-prefix=CHECK-CUDA-DEV
|
||||||
// RUN: %clang -### -fsave-optimization-record -x cuda -nocudainc -nocudalib %s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O -check-prefix=CHECK-CUDA-DEV
|
// RUN: %clang -### -fsave-optimization-record -x cuda -nocudainc -nocudalib %s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O -check-prefix=CHECK-CUDA-DEV
|
||||||
|
|
Loading…
Reference in New Issue