[all-commits] [llvm/llvm-project] 317a0f: [Driver][CodeGen] Properly handle -fsplit-machine-...

Han Shen via All-commits all-commits at lists.llvm.org
Wed Aug 16 23:46:06 PDT 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 317a0fe5bd7113c0ac9d30b2de58ca409e5ff754
  Author: Han Shen <shenhan at google.com>
  Date:   2023-08-16 (Wed, 16 Aug 2023)

  Changed paths:
    M clang/include/clang/Basic/DiagnosticDriverKinds.td
    M clang/lib/Driver/ToolChains/Clang.cpp
    A clang/test/Driver/fsplit-machine-functions-with-cuda-nvptx.c
    M clang/test/Driver/fsplit-machine-functions.c
    M clang/test/Driver/fsplit-machine-functions2.c
    M llvm/include/llvm/IR/DiagnosticInfo.h
    M llvm/lib/CodeGen/MachineFunctionSplitter.cpp
    M llvm/lib/IR/DiagnosticInfo.cpp
    A llvm/test/CodeGen/Generic/Inputs/fsloader-mfs.afdo
    M llvm/test/CodeGen/Generic/machine-function-splitter.ll

  Log Message:
  [Driver][CodeGen] Properly handle -fsplit-machine-functions for fatbinary compilation.

When building a fatbinary, the driver invokes the compiler multiple
times with different "--target". (For example, with "-x cuda
--cuda-gpu-arch=sm_70" flags, clang will be invoded twice, once with
--target=x86_64_...., once with --target=sm_70) If we use
-fsplit-machine-functions or -fno-split-machine-functions for such
invocation, the driver reports an error.

This CL changes the behavior so:

  - "-fsplit-machine-functions" is now passed to all targets, for non-X86
    targets, the flag is a NOOP and causes a warning.

  - "-fno-split-machine-functions" now negates -fsplit-machine-functions (if
    -fno-split-machine-functions appears after any -fsplit-machine-functions)
    for any target triple, previously, it causes an error.

  - "-fsplit-machine-functions -Xarch_device -fno-split-machine-functions"
    enables MFS on host but disables MFS for GPUS without warnings/errors.

  - "-Xarch_host -fsplit-machine-functions" enables MFS on host but disables
    MFS for GPUS without warnings/errors.

Reviewed by: xur, dhoekwater

Differential Revision: https://reviews.llvm.org/D157750

More information about the All-commits mailing list