shenhan created this revision. shenhan added a reviewer: MaskRay. Herald added a subscriber: pengfei. Herald added a project: All. shenhan requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Previously, when clang reports an error when -fno-split-machine-functions is used for non-X86 archs. However, in some cases, users may specify flags as "-fsplit-machine-functions -fother-flags -fno-split-machine-functions", the first one is from a global flag set, the last one is used to negate the global flag, we think this is a valid usage mode. Another cases is when clang is used to invoke multiple workloads, like "-x cuda -fsplit-machine-functions -Xarch_device -fno-split-machine-functions", the latter is used to negate the global -fsplit-machine-functions when invoke workloads for GPU." This change makes this work. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D158755 Files: clang/lib/Driver/ToolChains/Clang.cpp Index: clang/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -5872,13 +5872,13 @@ if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions, options::OPT_fno_split_machine_functions)) { - // This codegen pass is only available on x86-elf targets. - if (Triple.isX86() && Triple.isOSBinFormatELF()) { - if (A->getOption().matches(options::OPT_fsplit_machine_functions)) + if (!A->getOption().matches(options::OPT_fno_split_machine_functions)) { + // This codegen pass is only available on x86-elf targets. + if (Triple.isX86() && Triple.isOSBinFormatELF()) A->render(Args, CmdArgs); - } else { - D.Diag(diag::err_drv_unsupported_opt_for_target) - << A->getAsString(Args) << TripleStr; + else + D.Diag(diag::err_drv_unsupported_opt_for_target) + << A->getAsString(Args) << TripleStr; } }
Index: clang/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -5872,13 +5872,13 @@ if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions, options::OPT_fno_split_machine_functions)) { - // This codegen pass is only available on x86-elf targets. - if (Triple.isX86() && Triple.isOSBinFormatELF()) { - if (A->getOption().matches(options::OPT_fsplit_machine_functions)) + if (!A->getOption().matches(options::OPT_fno_split_machine_functions)) { + // This codegen pass is only available on x86-elf targets. + if (Triple.isX86() && Triple.isOSBinFormatELF()) A->render(Args, CmdArgs); - } else { - D.Diag(diag::err_drv_unsupported_opt_for_target) - << A->getAsString(Args) << TripleStr; + else + D.Diag(diag::err_drv_unsupported_opt_for_target) + << A->getAsString(Args) << TripleStr; } }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits