Skip to content

Commit f35b9ad

Browse files
authored
[clang] Propagate -ftime-report to offload lto (#122143)
1 parent 676c641 commit f35b9ad

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9282,6 +9282,10 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
92829282
if (const Arg *A = Args.getLastArg(options::OPT_Rpass_analysis_EQ))
92839283
CmdArgs.push_back(Args.MakeArgString(
92849284
Twine("--offload-opt=-pass-remarks-analysis=") + A->getValue()));
9285+
9286+
if (Args.getLastArg(options::OPT_ftime_report))
9287+
CmdArgs.push_back("--device-compiler=-ftime-report");
9288+
92859289
if (Args.getLastArg(options::OPT_save_temps_EQ))
92869290
CmdArgs.push_back("--save-temps");
92879291

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,10 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
12091209
if (ImplicitMapSyms)
12101210
CmdArgs.push_back(
12111211
Args.MakeArgString(Twine(PluginOptPrefix) + "-implicit-mapsyms"));
1212+
1213+
if (Args.hasArg(options::OPT_ftime_report))
1214+
CmdArgs.push_back(
1215+
Args.MakeArgString(Twine(PluginOptPrefix) + "-time-passes"));
12121216
}
12131217

12141218
void tools::addOpenMPRuntimeLibraryPath(const ToolChain &TC,

clang/test/Driver/amdgpu-openmp-toolchain.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,7 @@
8181
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S -fopenmp --offload-arch=gfx803 \
8282
// RUN: -stdlib=libc++ -nogpulib %s 2>&1 | FileCheck %s --check-prefix=LIBCXX
8383
// LIBCXX-NOT: include/amdgcn-amd-amdhsa/c++/v1
84+
85+
// RUN: %clang -### -target x86_64-pc-linux-gnu -nogpulib -fopenmp --offload-arch=gfx90a \
86+
// RUN: -ftime-report %s 2>&1 | FileCheck %s --check-prefix=CHECK-TIME-REPORT
87+
// CHECK-TIME-REPORT: clang-linker-wrapper{{.*}}"--device-compiler=-ftime-report"

clang/test/Driver/lto.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,9 @@
114114
//
115115
// CHECK-GISEL: "-plugin-opt=-global-isel=1"
116116
// CHECK-DISABLE-GISEL: "-plugin-opt=-global-isel=0"
117+
118+
// -flto passes -time-passes when -ftime-report is passed
119+
// RUN: %clang --target=x86_64-unknown-linux-gnu -### %s -flto -ftime-report 2> %t
120+
// RUN: FileCheck --check-prefix=CHECK-TIME-REPORT < %t %s
121+
122+
// CHECK-TIME-REPORT: "-plugin-opt=-time-passes"

0 commit comments

Comments
 (0)