llvm.org GIT mirror llvm / c47e5db
[GlobalISel] Add a fallback path to SDISel. When global-isel fails on a MachineFunction MF, MF will be cleaned up and given to SDISel. Thanks to this fallback, we can already perform correctness test even if we support only a small portion of the functions in a test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279891 91177308-0d34-0410-b5e6-96231b3b80d8 Quentin Colombet 3 years ago
6 changed file(s) with 85 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
5151 /// MIRPrinting pass - this pass prints out the LLVM IR into the given stream
5252 /// using the MIR serialization format.
5353 MachineFunctionPass *createPrintMIRPass(raw_ostream &OS);
54
55 MachineFunctionPass *createResetMachineFunctionPass();
5456
5557 /// createCodeGenPreparePass - Transform the code to expose more pattern
5658 /// matching during instruction selection.
291291 void initializeRegionViewerPass(PassRegistry&);
292292 void initializeRegisterCoalescerPass(PassRegistry&);
293293 void initializeRenameIndependentSubregsPass(PassRegistry&);
294 void initializeResetMachineFunctionPass(PassRegistry &);
294295 void initializeReversePostOrderFunctionAttrsLegacyPassPass(PassRegistry&);
295296 void initializeRewriteStatepointsForGCPass(PassRegistry&);
296297 void initializeRewriteSymbolsLegacyPassPass(PassRegistry&);
104104 RegisterUsageInfo.cpp
105105 RegUsageInfoCollector.cpp
106106 RegUsageInfoPropagate.cpp
107 ResetMachineFunctionPass.cpp
107108 SafeStack.cpp
108109 SafeStackColoring.cpp
109110 SafeStackLayout.cpp
167167 if (PassConfig->addGlobalInstructionSelect())
168168 return nullptr;
169169
170 // Pass to reset the MachineFunction if the ISel failed.
171 PM.add(createResetMachineFunctionPass());
172
173 // Provide a fallback path when we do not want to abort on
174 // not-yet-supported input.
175 if (LLVM_UNLIKELY(!PassConfig->isGlobalISelAbortEnabled()) &&
176 PassConfig->addInstSelector())
177 return nullptr;
178
170179 } else if (PassConfig->addInstSelector())
171180 return nullptr;
172181
0 //===-- ResetMachineFunctionPass.cpp - Machine Loop Invariant Code Motion Pass ---------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 //
10 //===----------------------------------------------------------------------===//
11
12 #include "llvm/CodeGen/Passes.h"
13 #include "llvm/CodeGen/MachineFunction.h"
14 #include "llvm/CodeGen/MachineFunctionPass.h"
15 #include "llvm/Support/Debug.h"
16 using namespace llvm;
17
18 #define DEBUG_TYPE "reset-machine-function"
19
20 namespace {
21 class ResetMachineFunction : public MachineFunctionPass {
22 public:
23 static char ID; // Pass identification, replacement for typeid
24 ResetMachineFunction() :
25 MachineFunctionPass(ID) {
26 }
27
28 const char *getPassName() const override {
29 return "ResetMachineFunction";
30 }
31
32 bool runOnMachineFunction(MachineFunction &MF) override {
33 if (MF.getProperties().hasProperty(
34 MachineFunctionProperties::Property::FailedISel)) {
35 DEBUG(dbgs() << "Reseting: " << MF.getName() << '\n');
36 MF.reset();
37 return true;
38 }
39 return false;
40 }
41
42 };
43 } // end anonymous namespace
44
45 char ResetMachineFunction::ID = 0;
46 INITIALIZE_PASS(ResetMachineFunction, DEBUG_TYPE,
47 "reset machine function if ISel failed", false, false)
48
49 MachineFunctionPass *
50 llvm::createResetMachineFunctionPass() {
51 return new ResetMachineFunction();
52 }
0 ; RUN: not llc -O0 -global-isel -verify-machineinstrs %s -o - 2>&1 | FileCheck %s --check-prefix=ERROR
1 ; RUN: llc -O0 -global-isel -global-isel-abort=false -verify-machineinstrs %s -o - 2>&1 | FileCheck %s --check-prefix=FALLBACK
2 ; This file checks that the fallback path to selection dag works.
3 ; The test is fragile in the sense that it must be updated to expose
4 ; something that fails with global-isel.
5 ; When we cannot produce a test case anymore, that means we can remove
6 ; the fallback path.
7
8 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
9 target triple = "aarch64-apple-ios"
10
11 ; ERROR: Unable to lower arguments
12 ; FALLBACK: ldr q0,
13 ; FALLBACK-NEXT: bl ___fixunstfti
14 define i128 @ABIi128(i128 %arg1) {
15 %farg1 = bitcast i128 %arg1 to fp128
16 %res = fptoui fp128 %farg1 to i128
17 ret i128 %res
18 }