[Openmp-commits] [PATCH] D116906: [OpenMP][AMDGPU] Optimize the linked in math libraries
Johannes Doerfert via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Wed Jan 19 21:36:44 PST 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6f2ee1ca5e39: [OpenMP][AMDGPU] Optimize the linked in math libraries (authored by jdoerfert).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D116906/new/
https://reviews.llvm.org/D116906
Files:
clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
Index: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
===================================================================
--- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -16,6 +16,7 @@
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Options.h"
+#include "clang/Driver/Tool.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FormatAdapters.h"
@@ -95,9 +96,9 @@
if (II.isFilename())
CmdArgs.push_back(II.getFilename());
+ bool HasLibm = false;
if (Args.hasArg(options::OPT_l)) {
auto Lm = Args.getAllArgValues(options::OPT_l);
- bool HasLibm = false;
for (auto &Lib : Lm) {
if (Lib == "m") {
HasLibm = true;
@@ -143,6 +144,26 @@
C.addCommand(std::make_unique<Command>(
JA, *this, ResponseFileSupport::AtFileCurCP(), Exec, CmdArgs, Inputs,
InputInfo(&JA, Args.MakeArgString(OutputFileName))));
+
+ // If we linked in libm definitions late we run another round of optimizations
+ // to inline the definitions and fold what is foldable.
+ if (HasLibm) {
+ ArgStringList OptCmdArgs;
+ const char *OptOutputFileName =
+ getOutputFileName(C, OutputFilePrefix, "-linked-opt", "bc");
+ addLLCOptArg(Args, OptCmdArgs);
+ OptCmdArgs.push_back(OutputFileName);
+ OptCmdArgs.push_back("-o");
+ OptCmdArgs.push_back(OptOutputFileName);
+ const char *OptExec =
+ Args.MakeArgString(getToolChain().GetProgramPath("opt"));
+ C.addCommand(std::make_unique<Command>(
+ JA, *this, ResponseFileSupport::AtFileCurCP(), OptExec, OptCmdArgs,
+ InputInfo(&JA, Args.MakeArgString(OutputFileName)),
+ InputInfo(&JA, Args.MakeArgString(OptOutputFileName))));
+ OutputFileName = OptOutputFileName;
+ }
+
return OutputFileName;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116906.401502.patch
Type: text/x-patch
Size: 1890 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20220120/8405431e/attachment.bin>
More information about the Openmp-commits
mailing list