diff --git a/llvm/lib/CodeGen/TargetInstrInfo.cpp b/llvm/lib/CodeGen/TargetInstrInfo.cpp --- a/llvm/lib/CodeGen/TargetInstrInfo.cpp +++ b/llvm/lib/CodeGen/TargetInstrInfo.cpp @@ -1579,10 +1579,6 @@ // Just go right to the target implementation. return getOutliningTypeImpl(MIT, Flags); - // Don't allow instructions that don't materialize to impact analysis. - if (MI.isMetaInstruction()) - return outliner::InstrType::Invisible; - // Be conservative about inline assembly. if (MI.isInlineAsm()) return outliner::InstrType::Illegal; @@ -1591,6 +1587,21 @@ if (MI.isLabel()) return outliner::InstrType::Illegal; + // Don't let debug instructions impact analysis. + if (MI.isDebugInstr()) + return outliner::InstrType::Invisible; + + // Some other special cases. + switch (MI.getOpcode()) { + case TargetOpcode::IMPLICIT_DEF: + case TargetOpcode::KILL: + case TargetOpcode::LIFETIME_START: + case TargetOpcode::LIFETIME_END: + return outliner::InstrType::Invisible; + default: + break; + } + // Is this a terminator for a basic block? if (MI.isTerminator()) { // If this is a branch to another block, we can't outline it. diff --git a/llvm/test/CodeGen/AArch64/machine-outliner-labels.mir b/llvm/test/CodeGen/AArch64/machine-outliner-labels.mir new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/machine-outliner-labels.mir @@ -0,0 +1,49 @@ +# RUN: llc -mtriple aarch64 -run-pass=machine-outliner -verify-machineinstrs %s -o - | FileCheck %s +# CHECK-NOT: OUTLINED_FUNCTION + +... +--- +name: foo1 +tracksRegLiveness: true +machineFunctionInfo: + hasRedZone: false +body: | + bb.0: + liveins: $x0 + $x0 = ADDXri $x0, 0, 0 + EH_LABEL + EH_LABEL + EH_LABEL + EH_LABEL + RET_ReallyLR implicit $x0 +... +--- +name: foo2 +tracksRegLiveness: true +machineFunctionInfo: + hasRedZone: false +body: | + bb.0: + liveins: $x0 + $x0 = ADDXri $x0, 0, 0 + EH_LABEL + EH_LABEL + EH_LABEL + EH_LABEL + RET_ReallyLR implicit $x0 +... +--- +name: foo3 +tracksRegLiveness: true +machineFunctionInfo: + hasRedZone: false +body: | + bb.0: + liveins: $x0 + $x0 = ADDXri $x0, 0, 0 + EH_LABEL + EH_LABEL + EH_LABEL + EH_LABEL + RET_ReallyLR implicit $x0 +...