This is an archive of the discontinued LLVM Phabricator instance.

[clang] Fix -Xarch_ for -mllvm and alike

Authored by yaxunl on Feb 3 2023, 5:14 PM.



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.

Diff Detail

Event Timeline

yaxunl created this revision.Feb 3 2023, 5:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 3 2023, 5:14 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
yaxunl requested review of this revision.Feb 3 2023, 5:14 PM
Herald added a project: Restricted Project. · View Herald Transcript

An option value treating a space differently (as a delimiter in this case) is uncommon. I suggest an alias -mllvm= (D143325) which is more inline with the convention of the majority of options that take a value (= instead of ).

MaskRay requested changes to this revision.Aug 30 2023, 11:19 PM

I assume that this is unneeded after :)

This revision now requires changes to proceed.Aug 30 2023, 11:19 PM
yaxunl abandoned this revision.Sep 12 2023, 10:52 AM

Abandon this patch unless we need it in the future.