[llvm] r279891 - [GlobalISel] Add a fallback path to SDISel.
Quentin Colombet via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 26 17:18:32 PDT 2016
Author: qcolombet
Date: Fri Aug 26 19:18:31 2016
New Revision: 279891
URL: http://llvm.org/viewvc/llvm-project?rev=279891&view=rev
Log:
[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.
Added:
llvm/trunk/lib/CodeGen/ResetMachineFunctionPass.cpp
llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll
Modified:
llvm/trunk/include/llvm/CodeGen/Passes.h
llvm/trunk/include/llvm/InitializePasses.h
llvm/trunk/lib/CodeGen/CMakeLists.txt
llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp
Modified: llvm/trunk/include/llvm/CodeGen/Passes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/Passes.h?rev=279891&r1=279890&r2=279891&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/Passes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/Passes.h Fri Aug 26 19:18:31 2016
@@ -53,6 +53,8 @@ namespace llvm {
/// using the MIR serialization format.
MachineFunctionPass *createPrintMIRPass(raw_ostream &OS);
+ MachineFunctionPass *createResetMachineFunctionPass();
+
/// createCodeGenPreparePass - Transform the code to expose more pattern
/// matching during instruction selection.
FunctionPass *createCodeGenPreparePass(const TargetMachine *TM = nullptr);
Modified: llvm/trunk/include/llvm/InitializePasses.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InitializePasses.h?rev=279891&r1=279890&r2=279891&view=diff
==============================================================================
--- llvm/trunk/include/llvm/InitializePasses.h (original)
+++ llvm/trunk/include/llvm/InitializePasses.h Fri Aug 26 19:18:31 2016
@@ -292,6 +292,7 @@ void initializeRegionPrinterPass(PassReg
void initializeRegionViewerPass(PassRegistry&);
void initializeRegisterCoalescerPass(PassRegistry&);
void initializeRenameIndependentSubregsPass(PassRegistry&);
+void initializeResetMachineFunctionPass(PassRegistry &);
void initializeReversePostOrderFunctionAttrsLegacyPassPass(PassRegistry&);
void initializeRewriteStatepointsForGCPass(PassRegistry&);
void initializeRewriteSymbolsLegacyPassPass(PassRegistry&);
Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CMakeLists.txt?rev=279891&r1=279890&r2=279891&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/CMakeLists.txt (original)
+++ llvm/trunk/lib/CodeGen/CMakeLists.txt Fri Aug 26 19:18:31 2016
@@ -105,6 +105,7 @@ add_llvm_library(LLVMCodeGen
RegisterUsageInfo.cpp
RegUsageInfoCollector.cpp
RegUsageInfoPropagate.cpp
+ ResetMachineFunctionPass.cpp
SafeStack.cpp
SafeStackColoring.cpp
SafeStackLayout.cpp
Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=279891&r1=279890&r2=279891&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original)
+++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Fri Aug 26 19:18:31 2016
@@ -168,6 +168,15 @@ addPassesToGenerateCode(LLVMTargetMachin
if (PassConfig->addGlobalInstructionSelect())
return nullptr;
+ // Pass to reset the MachineFunction if the ISel failed.
+ PM.add(createResetMachineFunctionPass());
+
+ // Provide a fallback path when we do not want to abort on
+ // not-yet-supported input.
+ if (LLVM_UNLIKELY(!PassConfig->isGlobalISelAbortEnabled()) &&
+ PassConfig->addInstSelector())
+ return nullptr;
+
} else if (PassConfig->addInstSelector())
return nullptr;
Added: llvm/trunk/lib/CodeGen/ResetMachineFunctionPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ResetMachineFunctionPass.cpp?rev=279891&view=auto
==============================================================================
--- llvm/trunk/lib/CodeGen/ResetMachineFunctionPass.cpp (added)
+++ llvm/trunk/lib/CodeGen/ResetMachineFunctionPass.cpp Fri Aug 26 19:18:31 2016
@@ -0,0 +1,53 @@
+//===-- ResetMachineFunctionPass.cpp - Machine Loop Invariant Code Motion Pass ---------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/CodeGen/Passes.h"
+#include "llvm/CodeGen/MachineFunction.h"
+#include "llvm/CodeGen/MachineFunctionPass.h"
+#include "llvm/Support/Debug.h"
+using namespace llvm;
+
+#define DEBUG_TYPE "reset-machine-function"
+
+namespace {
+ class ResetMachineFunction : public MachineFunctionPass {
+ public:
+ static char ID; // Pass identification, replacement for typeid
+ ResetMachineFunction() :
+ MachineFunctionPass(ID) {
+ }
+
+ const char *getPassName() const override {
+ return "ResetMachineFunction";
+ }
+
+ bool runOnMachineFunction(MachineFunction &MF) override {
+ if (MF.getProperties().hasProperty(
+ MachineFunctionProperties::Property::FailedISel)) {
+ DEBUG(dbgs() << "Reseting: " << MF.getName() << '\n');
+ MF.reset();
+ return true;
+ }
+ return false;
+ }
+
+ };
+} // end anonymous namespace
+
+char ResetMachineFunction::ID = 0;
+INITIALIZE_PASS(ResetMachineFunction, DEBUG_TYPE,
+ "reset machine function if ISel failed", false, false)
+
+MachineFunctionPass *
+llvm::createResetMachineFunctionPass() {
+ return new ResetMachineFunction();
+}
Added: llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll?rev=279891&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll (added)
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll Fri Aug 26 19:18:31 2016
@@ -0,0 +1,19 @@
+; RUN: not llc -O0 -global-isel -verify-machineinstrs %s -o - 2>&1 | FileCheck %s --check-prefix=ERROR
+; RUN: llc -O0 -global-isel -global-isel-abort=false -verify-machineinstrs %s -o - 2>&1 | FileCheck %s --check-prefix=FALLBACK
+; This file checks that the fallback path to selection dag works.
+; The test is fragile in the sense that it must be updated to expose
+; something that fails with global-isel.
+; When we cannot produce a test case anymore, that means we can remove
+; the fallback path.
+
+target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
+target triple = "aarch64-apple-ios"
+
+; ERROR: Unable to lower arguments
+; FALLBACK: ldr q0,
+; FALLBACK-NEXT: bl ___fixunstfti
+define i128 @ABIi128(i128 %arg1) {
+ %farg1 = bitcast i128 %arg1 to fp128
+ %res = fptoui fp128 %farg1 to i128
+ ret i128 %res
+}
More information about the llvm-commits
mailing list