Skip to content

Commit

Permalink
[Driver][LTO] Copy fix empty stats filename to AIX (#71738)
Browse files Browse the repository at this point in the history
copy implement of #71359 to
AIX.cpp and add test scenario

---------

Co-authored-by: zhijian <zhijian@ca.ibm.com>
  • Loading branch information
diggerlin and diggerlin committed Nov 10, 2023
1 parent b008d66 commit d51dd89
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 9 additions & 1 deletion clang/lib/Driver/ToolChains/AIX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,15 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA,

if (D.isUsingLTO()) {
assert(!Inputs.empty() && "Must have at least one input.");
addLTOOptions(ToolChain, Args, CmdArgs, Output, Inputs[0],
// Find the first filename InputInfo object.
auto Input = llvm::find_if(
Inputs, [](const InputInfo &II) -> bool { return II.isFilename(); });
if (Input == Inputs.end())
// For a very rare case, all of the inputs to the linker are
// InputArg. If that happens, just use the first InputInfo.
Input = Inputs.begin();

addLTOOptions(ToolChain, Args, CmdArgs, Output, *Input,
D.getLTOMode() == LTOK_Thin);
}

Expand Down
8 changes: 8 additions & 0 deletions clang/test/Driver/save-stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
// CHECK-LTO: "-o" "obj/dir{{/|\\\\}}save-stats.exe"
// CHECK-LTO: "-plugin-opt=stats-file=save-stats.stats"


// RUN: %clang --target=powerpc-unknown-aix -save-stats -flto -o obj/dir/save-stats %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-AIX-LTO
// RUN: %clang --target=powerpc-unknown-aix -save-stats -flto -o obj/dir/save-stats -Wl,-bplugin-opt:-dummy %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-AIX-LTO

// CHECK-AIX-LTO: "-stats-file=save-stats.stats"
// CHECK-AIX-LTO: "-o" "obj/dir{{/|\\\\}}save-stats"
// CHECK-AIX-LTO: "-bplugin_opt:stats-file=save-stats.stats"

// RUN: %clang --target=x86_64-unknown-linux -save-stats=obj -flto -o obj/dir/save-stats.exe %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-LTO-OBJ
// CHECK-LTO-OBJ: "-plugin-opt=stats-file=obj/dir{{/|\\\\}}save-stats.stats"

Expand Down

0 comments on commit d51dd89

Please sign in to comment.