[llvm] [llvm] Refactor llc to use OptTable (PR #187901)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 28 13:23:33 PDT 2026
================
@@ -399,19 +497,79 @@ int main(int argc, char **argv) {
initializeScavengerTestPass(*Registry);
SmallVector<PassPlugin, 1> PluginList;
- PassPlugins.setCallback([&](const std::string &PluginPath) {
- auto Plugin = PassPlugin::Load(PluginPath);
- if (!Plugin)
- reportFatalUsageError(Plugin.takeError());
- PluginList.emplace_back(Plugin.get());
- });
- // Register the Target and CPU printer for --version.
- cl::AddExtraVersionPrinter(sys::printDefaultTargetAndDetectedCPU);
- // Register the target printer for --version.
- cl::AddExtraVersionPrinter(TargetRegistry::printRegisteredTargetsForVersion);
+ LlcOptTable Tbl;
+ unsigned MissingArgIndex, MissingArgCount;
+ ArrayRef<const char *> ArgsArr = ArrayRef(argv + 1, argc - 1);
+ opt::InputArgList Args =
+ Tbl.ParseArgs(ArgsArr, MissingArgIndex, MissingArgCount);
- cl::ParseCommandLineOptions(argc, argv, "llvm system compiler\n");
+ if (MissingArgCount) {
+ reportError("missing argument to option: " +
+ Twine(Args.getArgString(MissingArgIndex)));
+ }
+
+ if (Args.hasArg(OPT_help)) {
+ Tbl.printHelp(outs(), "llc [options] <input bitcode>",
+ "llvm system compiler");
+ return 0;
+ }
+
+ RecordLlcOpts(Args, PluginList);
+
+ // Arguments not consumed by llc directly must be passed
+ // to the backend via cl::ParseCommandLineOptions. Unfortunately, this
----------------
PiJoules wrote:
Any particular reason to remove them? I could remove them but I would think it wouldn't be straightforward why we're still using `cl::` without them.
https://github.com/llvm/llvm-project/pull/187901
More information about the llvm-commits
mailing list