[clang] [LTO] Fix Veclib flags correctly pass to LTO flags (PR #78749)

Maciej Gabka via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 22 05:17:43 PST 2024


================
@@ -783,6 +783,28 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
                                          "-generate-arange-section"));
   }
 
+  // Pass vector library arguments to LTO.
+  Arg *ArgVecLib = Args.getLastArg(options::OPT_fveclib);
+  if (ArgVecLib && ArgVecLib->getNumValues() == 1) {
+    // Map the vector library names from clang front-end to opt front-end. The
+    // values are taken from the TargetLibraryInfo class command line options.
+    std::optional<StringRef> OptVal =
+        llvm::StringSwitch<std::optional<StringRef>>(ArgVecLib->getValue())
----------------
mgabka wrote:

the TLI belongs to llvm world, while clang driver from what I can see is only linked with following llvm components:
set(LLVM_LINK_COMPONENTS
  BinaryFormat
  MC
  Object
  Option
  ProfileData
  Support
  TargetParser
  WindowsDriver
  )
so I don't think it is possible to do it.

Unfortunately at the early stage when the  tools::addLTOOptions function is called the CodeGenOptions are not even created, perhaps we could have a function defined which does the strings checking in include/llvm/Analysis/TargetLibraryInfo.h and include it in  the CommonArgs.cpp? a least everything would be in one place? what do you think @david-arm ?

https://github.com/llvm/llvm-project/pull/78749


More information about the cfe-commits mailing list