Skip to content

Commit 77596e6

Browse files
committed
Revert D157750 "[Driver][CodeGen] Properly handle -fsplit-machine-functions for fatbinary compilation."
This reverts commit 317a0fe. This reverts commit 30c4b97. See post-commit discussions on https://reviews.llvm.org/D157750 that we should use a different mechanism to handle the error with --cuda-gpu-arch= The IR/DiagnosticInfo.cpp, warn_drv_for_elf_only, codegne tests in clang/test/Driver, and the following driver behavior (downgrading error to warning) changes are undesired. ``` % clang --target=riscv64 -fsplit-machine-functions -c a.c warning: -fsplit-machine-functions is not valid for riscv64 [-Wbackend-plugin] ```
1 parent 446abb5 commit 77596e6

File tree

10 files changed

+15
-141
lines changed

10 files changed

+15
-141
lines changed

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -693,10 +693,6 @@ def warn_drv_fjmc_for_elf_only : Warning<
693693
"-fjmc works only for ELF; option ignored">,
694694
InGroup<OptionIgnored>;
695695

696-
def warn_drv_for_elf_only : Warning<
697-
"'%0' works only for ELF; option ignored">,
698-
InGroup<OptionIgnored>;
699-
700696
def warn_target_override_arm64ec : Warning<
701697
"/arm64EC has been overridden by specified target: %0; option ignored">,
702698
InGroup<OptionIgnored>;

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5872,15 +5872,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
58725872

58735873
if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions,
58745874
options::OPT_fno_split_machine_functions)) {
5875-
if (A->getOption().matches(options::OPT_fsplit_machine_functions)) {
5876-
// This codegen pass is only available on elf targets.
5877-
if (Triple.isOSBinFormatELF())
5875+
// This codegen pass is only available on x86-elf targets.
5876+
if (Triple.isX86() && Triple.isOSBinFormatELF()) {
5877+
if (A->getOption().matches(options::OPT_fsplit_machine_functions))
58785878
A->render(Args, CmdArgs);
5879-
else
5880-
D.Diag(diag::warn_drv_for_elf_only) << A->getAsString(Args);
5879+
} else {
5880+
D.Diag(diag::err_drv_unsupported_opt_for_target)
5881+
<< A->getAsString(Args) << TripleStr;
58815882
}
5882-
// Do not issue warnings for -fno-split-machine-functions even it is not
5883-
// on ELF.
58845883
}
58855884

58865885
Args.AddLastArg(CmdArgs, options::OPT_finstrument_functions,

clang/test/Driver/fsplit-machine-functions-with-cuda-nvptx.c

Lines changed: 0 additions & 68 deletions
This file was deleted.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// REQUIRES: arm-registered-target
22

3-
// RUN: %clang -### -target x86_64 -fprofile-use=default.profdata -fsplit-machine-functions %s -c -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-OPT %s
4-
// RUN: %clang -### -target x86_64 -fsplit-machine-functions %s -c -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-OPT %s
5-
// RUN: %clang -### -target x86_64 -fprofile-use=default.profdata -fsplit-machine-functions -fno-split-machine-functions %s -c -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOOPT %s
6-
// RUN: %clang -c -target arm-unknown-linux-gnueabi -fsplit-machine-functions %s -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
3+
// RUN: %clang -### -target x86_64 -fprofile-use=default.profdata -fsplit-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-OPT %s
4+
// RUN: %clang -### -target x86_64 -fsplit-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-OPT %s
5+
// RUN: %clang -### -target x86_64 -fprofile-use=default.profdata -fsplit-machine-functions -fno-split-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-NOOPT %s
6+
// RUN: not %clang -c -target arm-unknown-linux -fsplit-machine-functions %s 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
77

88
// CHECK-OPT: "-fsplit-machine-functions"
99
// CHECK-NOOPT-NOT: "-fsplit-machine-functions"
10-
// CHECK-TRIPLE: warning: -fsplit-machine-functions is not valid for arm
10+
// CHECK-TRIPLE: error: unsupported option '-fsplit-machine-functions' for target
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
// Test -fsplit-machine-functions option pass-through with lto
2-
// RUN: %clang -### -target x86_64-unknown-linux -flto -fsplit-machine-functions %s -o %t.o 2>&1 | FileCheck %s -check-prefix=CHECK-PASS
2+
// RUN: %clang -### -target x86_64-unknown-linux -flto -fsplit-machine-functions %s 2>&1 | FileCheck %s -check-prefix=CHECK-PASS
33

44
// Test no pass-through to ld without lto
5-
// RUN: %clang -### -target x86_64-unknown-linux -fsplit-machine-functions %s -o %t.o 2>&1 | FileCheck %s -check-prefix=CHECK-NOPASS
5+
// RUN: %clang -### -target x86_64-unknown-linux -fsplit-machine-functions %s 2>&1 | FileCheck %s -check-prefix=CHECK-NOPASS
66

77
// Test the mix of -fsplit-machine-functions and -fno-split-machine-functions
8-
// RUN: %clang -### -target x86_64-unknown-linux -flto -fsplit-machine-functions -fno-split-machine-functions %s -o %t.o 2>&1 | FileCheck %s -check-prefix=CHECK-NOPASS
9-
// RUN: %clang -### -target x86_64-unknown-linux -flto -fno-split-machine-functions -fsplit-machine-functions %s -o %t.o 2>&1 | FileCheck %s -check-prefix=CHECK-PASS
10-
// Check that for non-X86, passing no-split-machine-functions does not cause error.
11-
// RUN: %clang -### -target aarch64-unknown-linux-gnu -flto -fsplit-machine-functions -fno-split-machine-functions %s -o %t.o 2>&1 | FileCheck %s -check-prefix=CHECK-NOPASS2
8+
// RUN: %clang -### -target x86_64-unknown-linux -flto -fsplit-machine-functions -fno-split-machine-functions %s 2>&1 | FileCheck %s -check-prefix=CHECK-NOPASS
9+
// RUN: %clang -### -target x86_64-unknown-linux -flto -fno-split-machine-functions -fsplit-machine-functions %s 2>&1 | FileCheck %s -check-prefix=CHECK-PASS
1210

1311
// CHECK-PASS: "-plugin-opt=-split-machine-functions"
1412
// CHECK-NOPASS-NOT: "-plugin-opt=-split-machine-functions"
15-
// CHECK-NOPASS2-NOT: "-plugin-opt=-split-machine-functions"

llvm/include/llvm/IR/DiagnosticInfo.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ enum DiagnosticKind {
8686
DK_SrcMgr,
8787
DK_DontCall,
8888
DK_MisExpect,
89-
DK_MachineFunctionSplit,
9089
DK_FirstPluginKind // Must be last value to work with
9190
// getNextAvailablePluginDiagnosticKind
9291
};
@@ -1118,20 +1117,6 @@ class DiagnosticInfoDontCall : public DiagnosticInfo {
11181117
}
11191118
};
11201119

1121-
class DiagnosticInfoMachineFunctionSplit : public DiagnosticInfo {
1122-
StringRef TargetTriple;
1123-
1124-
public:
1125-
DiagnosticInfoMachineFunctionSplit(StringRef TargetTriple,
1126-
DiagnosticSeverity DS)
1127-
: DiagnosticInfo(DK_MachineFunctionSplit, DS),
1128-
TargetTriple(TargetTriple) {}
1129-
void print(DiagnosticPrinter &DP) const override;
1130-
static bool classof(const DiagnosticInfo *DI) {
1131-
return DI->getKind() == DK_MachineFunctionSplit;
1132-
}
1133-
};
1134-
11351120
} // end namespace llvm
11361121

11371122
#endif // LLVM_IR_DIAGNOSTICINFO_H

llvm/lib/CodeGen/MachineFunctionSplitter.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,9 @@
3535
#include "llvm/CodeGen/MachineFunctionPass.h"
3636
#include "llvm/CodeGen/MachineModuleInfo.h"
3737
#include "llvm/CodeGen/Passes.h"
38-
#include "llvm/IR/DiagnosticInfo.h"
3938
#include "llvm/IR/Function.h"
4039
#include "llvm/InitializePasses.h"
4140
#include "llvm/Support/CommandLine.h"
42-
#include "llvm/TargetParser/Triple.h"
4341
#include <optional>
4442

4543
using namespace llvm;
@@ -84,13 +82,6 @@ class MachineFunctionSplitter : public MachineFunctionPass {
8482
void getAnalysisUsage(AnalysisUsage &AU) const override;
8583

8684
bool runOnMachineFunction(MachineFunction &F) override;
87-
88-
bool doInitialization(Module &) override;
89-
90-
static bool isSupportedTriple(const Triple &T) { return T.isX86(); }
91-
92-
private:
93-
bool UnsupportedTriple = false;
9485
};
9586
} // end anonymous namespace
9687

@@ -136,20 +127,7 @@ static bool isColdBlock(const MachineBasicBlock &MBB,
136127
return (*Count < ColdCountThreshold);
137128
}
138129

139-
bool MachineFunctionSplitter::doInitialization(Module &M) {
140-
StringRef T = M.getTargetTriple();
141-
if (!isSupportedTriple(Triple(T))) {
142-
UnsupportedTriple = true;
143-
M.getContext().diagnose(
144-
DiagnosticInfoMachineFunctionSplit(T, DS_Warning));
145-
return false;
146-
}
147-
return MachineFunctionPass::doInitialization(M);
148-
}
149-
150130
bool MachineFunctionSplitter::runOnMachineFunction(MachineFunction &MF) {
151-
if (UnsupportedTriple)
152-
return false;
153131
// We target functions with profile data. Static information in the form
154132
// of exception handling code may be split to cold if user passes the
155133
// mfs-split-ehcode flag.

llvm/lib/IR/DiagnosticInfo.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,3 @@ void DiagnosticInfoDontCall::print(DiagnosticPrinter &DP) const {
449449
if (!getNote().empty())
450450
DP << ": " << getNote();
451451
}
452-
453-
void DiagnosticInfoMachineFunctionSplit::print(DiagnosticPrinter &DP) const {
454-
DP << "-fsplit-machine-functions is not valid for " << TargetTriple;
455-
}
-135 Bytes
Binary file not shown.

llvm/test/CodeGen/Generic/machine-function-splitter.ll

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,6 @@
1111
; RUN: sed 's/InstrProf/SampleProfile/g' %s > %t.ll
1212
; RUN: llc < %t.ll -mtriple=x86_64-unknown-linux-gnu -split-machine-functions | FileCheck %s --check-prefix=FSAFDO-MFS
1313
; RUN: llc < %t.ll -mtriple=x86_64-unknown-linux-gnu -split-machine-functions | FileCheck %s --check-prefix=FSAFDO-MFS2
14-
; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -debug-pass=Structure -fs-profile-file=%S/Inputs/fsloader-mfs.afdo -enable-fs-discriminator=true -improved-fs-discriminator=true -split-machine-functions 2>&1 | FileCheck %s --check-prefix=MFS_ON
15-
; RUN: llc < %s -mtriple=aarch64-unknown-linux-gnu -debug-pass=Structure -fs-profile-file=%S/Inputs/fsloader-mfs.afdo -enable-fs-discriminator=true -improved-fs-discriminator=true -split-machine-functions 2>&1 | FileCheck %s --check-prefix=MFS_OFF
16-
17-
;; Check that MFS is on for X86 targets.
18-
; MFS_ON: Machine Function Splitter Transformation
19-
; MFS_ON_NO: warning: -fsplit-machine-functions is not valid for
20-
;; Check that MFS is not on for non-X86 targets.
21-
; MFS_OFF: warning: -fsplit-machine-functions is not valid for
22-
; MFS_OFF_NO: Machine Function Splitter Transformation
2314

2415
define void @foo1(i1 zeroext %0) nounwind !prof !14 !section_prefix !15 {
2516
;; Check that cold block is moved to .text.split.

0 commit comments

Comments
 (0)