diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -69,6 +69,7 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/LowLevelTypeImpl.h" #include "llvm/Support/MathExtras.h" +#include "llvm/Support/Timer.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetIntrinsicInfo.h" #include "llvm/Target/TargetMachine.h" @@ -2947,6 +2948,10 @@ } bool IRTranslator::runOnMachineFunction(MachineFunction &CurMF) { + StringRef GroupName = "gisel"; + StringRef GroupDescription = "GlobalISel instruction selection"; + NamedRegionTimer T("irtranslator", "IR Translator", GroupName, + GroupDescription); MF = &CurMF; const Function &F = MF->getFunction(); if (F.empty()) diff --git a/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp b/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp --- a/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp +++ b/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp @@ -29,6 +29,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/TargetRegistry.h" +#include "llvm/Support/Timer.h" #include "llvm/Target/TargetMachine.h" #define DEBUG_TYPE "instruction-select" @@ -69,6 +70,10 @@ if (MF.getProperties().hasProperty( MachineFunctionProperties::Property::FailedISel)) return false; + StringRef GroupName = "gisel"; + StringRef GroupDescription = "GlobalISel instruction selection"; + NamedRegionTimer T("instruction-select", "Instruction Selector", GroupName, + GroupDescription); LLVM_DEBUG(dbgs() << "Selecting function: " << MF.getName() << '\n'); GISelKnownBits &KB = getAnalysis().get(MF); diff --git a/llvm/lib/CodeGen/GlobalISel/Legalizer.cpp b/llvm/lib/CodeGen/GlobalISel/Legalizer.cpp --- a/llvm/lib/CodeGen/GlobalISel/Legalizer.cpp +++ b/llvm/lib/CodeGen/GlobalISel/Legalizer.cpp @@ -30,6 +30,7 @@ #include "llvm/InitializePasses.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Error.h" +#include "llvm/Support/Timer.h" #include "llvm/Target/TargetMachine.h" #include @@ -312,6 +313,9 @@ if (MF.getProperties().hasProperty( MachineFunctionProperties::Property::FailedISel)) return false; + StringRef GroupName = "gisel"; + StringRef GroupDescription = "GlobalISel instruction selection"; + NamedRegionTimer T("legalizer", "Legalizer", GroupName, GroupDescription); LLVM_DEBUG(dbgs() << "Legalize Machine IR for: " << MF.getName() << '\n'); init(MF); const TargetPassConfig &TPC = getAnalysis(); diff --git a/llvm/lib/CodeGen/GlobalISel/Localizer.cpp b/llvm/lib/CodeGen/GlobalISel/Localizer.cpp --- a/llvm/lib/CodeGen/GlobalISel/Localizer.cpp +++ b/llvm/lib/CodeGen/GlobalISel/Localizer.cpp @@ -16,6 +16,7 @@ #include "llvm/CodeGen/TargetLowering.h" #include "llvm/InitializePasses.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/Timer.h" #define DEBUG_TYPE "localizer" @@ -168,7 +169,9 @@ if (MF.getProperties().hasProperty( MachineFunctionProperties::Property::FailedISel)) return false; - + StringRef GroupName = "gisel"; + StringRef GroupDescription = "GlobalISel instruction selection"; + NamedRegionTimer T("localizer", "Localizer", GroupName, GroupDescription); // Don't run the pass if the target asked so. if (DoNotRunPass(MF)) return false; diff --git a/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp b/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp --- a/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp +++ b/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp @@ -39,6 +39,7 @@ #include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/Timer.h" #include "llvm/Support/raw_ostream.h" #include #include @@ -654,7 +655,10 @@ if (MF.getProperties().hasProperty( MachineFunctionProperties::Property::FailedISel)) return false; - + StringRef GroupName = "gisel"; + StringRef GroupDescription = "GlobalISel instruction selection"; + NamedRegionTimer T("regbankselect", "Register Bank Select", GroupName, + GroupDescription); LLVM_DEBUG(dbgs() << "Assign register banks for: " << MF.getName() << '\n'); const Function &F = MF.getFunction(); Mode SaveOptMode = OptMode; diff --git a/llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerCombiner.cpp b/llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerCombiner.cpp --- a/llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerCombiner.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerCombiner.cpp @@ -32,6 +32,7 @@ #include "llvm/CodeGen/TargetOpcodes.h" #include "llvm/CodeGen/TargetPassConfig.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/Timer.h" #define DEBUG_TYPE "aarch64-postlegalizer-combiner" @@ -321,6 +322,11 @@ if (MF.getProperties().hasProperty( MachineFunctionProperties::Property::FailedISel)) return false; + StringRef GroupName = "gisel"; + StringRef GroupDescription = "GlobalISel instruction selection"; + NamedRegionTimer T("aarch64-postlegalizer-combiner", + "AArch64 Post-Legalizer Combiner", GroupName, + GroupDescription); assert(MF.getProperties().hasProperty( MachineFunctionProperties::Property::Legalized) && "Expected a legalized function?"); diff --git a/llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerLowering.cpp b/llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerLowering.cpp --- a/llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerLowering.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerLowering.cpp @@ -35,6 +35,7 @@ #include "llvm/CodeGen/TargetPassConfig.h" #include "llvm/InitializePasses.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/Timer.h" #define DEBUG_TYPE "aarch64-postlegalizer-lowering" @@ -678,6 +679,11 @@ if (MF.getProperties().hasProperty( MachineFunctionProperties::Property::FailedISel)) return false; + StringRef GroupName = "gisel"; + StringRef GroupDescription = "GlobalISel instruction selection"; + NamedRegionTimer T("aarch64-postlegalizer-lowering", + "AArch64 Post-Legalizer Lowering", GroupName, + GroupDescription); assert(MF.getProperties().hasProperty( MachineFunctionProperties::Property::Legalized) && "Expected a legalized function?"); diff --git a/llvm/lib/Target/AArch64/GISel/AArch64PostSelectOptimize.cpp b/llvm/lib/Target/AArch64/GISel/AArch64PostSelectOptimize.cpp --- a/llvm/lib/Target/AArch64/GISel/AArch64PostSelectOptimize.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64PostSelectOptimize.cpp @@ -19,6 +19,7 @@ #include "llvm/CodeGen/MachineOperand.h" #include "llvm/CodeGen/TargetPassConfig.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/Timer.h" #define DEBUG_TYPE "aarch64-post-select-optimize" @@ -165,10 +166,16 @@ assert(MF.getProperties().hasProperty( MachineFunctionProperties::Property::Selected) && "Expected a selected MF"); - - bool Changed = false; - for (auto &BB : MF) - Changed |= optimizeNZCVDefs(BB); + StringRef GroupName = "gisel"; + StringRef GroupDescription = "GlobalISel instruction selection"; + { + NamedRegionTimer T("aarch64-postselect-optimize", + "AArch64 Post-Select Optimizer", GroupName, + GroupDescription); + bool Changed = false; + for (auto &BB : MF) + Changed |= optimizeNZCVDefs(BB); + } return true; } diff --git a/llvm/lib/Target/AArch64/GISel/AArch64PreLegalizerCombiner.cpp b/llvm/lib/Target/AArch64/GISel/AArch64PreLegalizerCombiner.cpp --- a/llvm/lib/Target/AArch64/GISel/AArch64PreLegalizerCombiner.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64PreLegalizerCombiner.cpp @@ -21,6 +21,7 @@ #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/TargetPassConfig.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/Timer.h" #define DEBUG_TYPE "aarch64-prelegalizer-combiner" @@ -163,6 +164,11 @@ if (MF.getProperties().hasProperty( MachineFunctionProperties::Property::FailedISel)) return false; + StringRef GroupName = "gisel"; + StringRef GroupDescription = "GlobalISel instruction selection"; + NamedRegionTimer T("aarch64-prelegalizer-combiner", + "AArch64 Pre-Legalizer Combiner", GroupName, + GroupDescription); auto *TPC = &getAnalysis(); const Function &F = MF.getFunction(); bool EnableOpt =