[PATCH] D143305: [clang] Fix -Xarch_ for -mllvm and alike

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 3 17:14:25 PST 2023


yaxunl created this revision.
yaxunl added reviewers: tra, MaskRay.
Herald added a subscriber: hiraditya.
Herald added a project: All.
yaxunl requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, sstefan1.
Herald added a project: LLVM.

Currently -Xarch_ does not work for options using space as delimiter, e.g.
-mllvm, which is a big limitation for -Xarch_ as device specific llvm options
are often needed.

The main obstacle is in OptTable::ParseOneArg, which can only parse
one newly added string to the base InputArgList of a DerivedArgList,
since Option::acceptInternal is bounded by size of the original strings
in InputArgList. The reason is that the newly added strings are used
to create new args in derived arg list, which usually happens during
parsing of the original arg strings, therefore Option::acceptInternal
should not go beyond the original arg strings.

In the case of -Xarch handling, if the newly created arg have two
strings, e.g. "-mllvm" and "--inline-threshold-count=1",
 OptTable::ParseOneArg needs to be enhanced to handle a
range of newly added strings beyond the original strings. A new
parameter IndexEnd is added.


https://reviews.llvm.org/D143305

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
  clang/test/Driver/hip-options.hip
  llvm/include/llvm/Option/OptTable.h
  llvm/include/llvm/Option/Option.h
  llvm/lib/Option/OptTable.cpp
  llvm/lib/Option/Option.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143305.494775.patch
Type: text/x-patch
Size: 13808 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230204/25e1f9b3/attachment.bin>


More information about the cfe-commits mailing list