diff --git a/llvm/include/llvm/CodeGen/MIRYamlMapping.h b/llvm/include/llvm/CodeGen/MIRYamlMapping.h --- a/llvm/include/llvm/CodeGen/MIRYamlMapping.h +++ b/llvm/include/llvm/CodeGen/MIRYamlMapping.h @@ -704,6 +704,7 @@ bool HasEHCatchret = false; bool HasEHScopes = false; bool HasEHFunclets = false; + bool IsOutlined = false; bool FailsVerification = false; bool TracksDebugUserValues = false; @@ -742,6 +743,7 @@ YamlIO.mapOptional("hasEHCatchret", MF.HasEHCatchret, false); YamlIO.mapOptional("hasEHScopes", MF.HasEHScopes, false); YamlIO.mapOptional("hasEHFunclets", MF.HasEHFunclets, false); + YamlIO.mapOptional("isOutlined", MF.IsOutlined, false); YamlIO.mapOptional("debugInstrRef", MF.UseDebugInstrRef, false); YamlIO.mapOptional("failsVerification", MF.FailsVerification, false); diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h --- a/llvm/include/llvm/CodeGen/MachineFunction.h +++ b/llvm/include/llvm/CodeGen/MachineFunction.h @@ -374,6 +374,7 @@ bool HasEHCatchret = false; bool HasEHScopes = false; bool HasEHFunclets = false; + bool IsOutlined = false; /// BBID to assign to the next basic block of this function. unsigned NextBBID = 0; @@ -1116,6 +1117,9 @@ bool hasEHFunclets() const { return HasEHFunclets; } void setHasEHFunclets(bool V) { HasEHFunclets = V; } + bool isOutlined() const { return IsOutlined; } + void setIsOutlined(bool V) { IsOutlined = V; } + /// Find or create an LandingPadInfo for the specified MachineBasicBlock. LandingPadInfo &getOrCreateLandingPadInfo(MachineBasicBlock *LandingPad); diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp --- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp +++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp @@ -468,6 +468,7 @@ MF.setHasEHCatchret(YamlMF.HasEHCatchret); MF.setHasEHScopes(YamlMF.HasEHScopes); MF.setHasEHFunclets(YamlMF.HasEHFunclets); + MF.setIsOutlined(YamlMF.IsOutlined); if (YamlMF.Legalized) MF.getProperties().set(MachineFunctionProperties::Property::Legalized); diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp --- a/llvm/lib/CodeGen/MIRPrinter.cpp +++ b/llvm/lib/CodeGen/MIRPrinter.cpp @@ -200,6 +200,7 @@ YamlMF.HasEHCatchret = MF.hasEHCatchret(); YamlMF.HasEHScopes = MF.hasEHScopes(); YamlMF.HasEHFunclets = MF.hasEHFunclets(); + YamlMF.IsOutlined = MF.isOutlined(); YamlMF.UseDebugInstrRef = MF.useDebugInstrRef(); YamlMF.Legalized = MF.getProperties().hasProperty( diff --git a/llvm/lib/CodeGen/MachineOutliner.cpp b/llvm/lib/CodeGen/MachineOutliner.cpp --- a/llvm/lib/CodeGen/MachineOutliner.cpp +++ b/llvm/lib/CodeGen/MachineOutliner.cpp @@ -725,6 +725,7 @@ MachineModuleInfo &MMI = getAnalysis().getMMI(); MachineFunction &MF = MMI.getOrCreateMachineFunction(*F); + MF.setIsOutlined(true); MachineBasicBlock &MBB = *MF.CreateMachineBasicBlock(); // Insert the new function into the module. diff --git a/llvm/test/CodeGen/RISCV/machineoutliner.mir b/llvm/test/CodeGen/RISCV/machineoutliner.mir --- a/llvm/test/CodeGen/RISCV/machineoutliner.mir +++ b/llvm/test/CodeGen/RISCV/machineoutliner.mir @@ -1,7 +1,7 @@ # RUN: llc -march=riscv32 -x mir -run-pass=machine-outliner -simplify-mir -verify-machineinstrs < %s \ -# RUN: | FileCheck -check-prefix=RV32I-MO %s +# RUN: | FileCheck -check-prefixes=CHECK,RV32I-MO %s # RUN: llc -march=riscv64 -x mir -run-pass=machine-outliner -simplify-mir -verify-machineinstrs < %s \ -# RUN: | FileCheck -check-prefix=RV64I-MO %s +# RUN: | FileCheck -check-prefixes=CHECK,RV64I-MO %s --- | define i32 @outline_0(i32 %a, i32 %b) { ret i32 0 } @@ -24,6 +24,7 @@ --- name: outline_0 tracksRegLiveness: true +isOutlined: false body: | bb.0: liveins: $x10, $x11 @@ -42,6 +43,7 @@ --- name: outline_1 tracksRegLiveness: true +isOutlined: false body: | bb.0: liveins: $x10, $x11 @@ -60,6 +62,7 @@ --- name: outline_2 tracksRegLiveness: true +isOutlined: false body: | bb.0: liveins: $x10, $x11 @@ -78,6 +81,7 @@ --- name: dont_outline_0 tracksRegLiveness: true +isOutlined: false body: | bb.0: liveins: $x10, $x11 @@ -96,6 +100,7 @@ --- name: dont_outline_1 tracksRegLiveness: true +isOutlined: false body: | bb.0: liveins: $x10, $x11 @@ -114,6 +119,7 @@ --- name: dont_outline_2 tracksRegLiveness: true +isOutlined: false body: | bb.0: liveins: $x10, $x11, $x5 @@ -130,3 +136,6 @@ PseudoRET implicit $x10 ... + +# CHECK-LABEL: name: OUTLINED_FUNCTION_0 +# CHECK: isOutlined: true diff --git a/llvm/tools/llvm-reduce/ReducerWorkItem.cpp b/llvm/tools/llvm-reduce/ReducerWorkItem.cpp --- a/llvm/tools/llvm-reduce/ReducerWorkItem.cpp +++ b/llvm/tools/llvm-reduce/ReducerWorkItem.cpp @@ -372,6 +372,7 @@ DstMF->setHasEHCatchret(SrcMF->hasEHCatchret()); DstMF->setHasEHScopes(SrcMF->hasEHScopes()); DstMF->setHasEHFunclets(SrcMF->hasEHFunclets()); + DstMF->setIsOutlined(SrcMF->isOutlined()); if (!SrcMF->getLandingPads().empty() || !SrcMF->getCodeViewAnnotations().empty() ||