From cd4f04d6bcb7aefa24d92582fbadfe17519f4756 Mon Sep 17 00:00:00 2001 From: Bob Wilson Date: Tue, 27 Oct 2009 23:49:38 +0000 Subject: Record CodeGen optimization level in the BranchFolding pass so that we can use it to control tail merging when there is a tradeoff between performance and code size. When there is only 1 instruction in the common tail, we have been merging. That can be good for code size but is a definite loss for performance. Now we will avoid tail merging in that case when the optimization level is "Aggressive", i.e., "-O3". Radar 7338114. Since the IfConversion pass invokes BranchFolding, it too needs to know the optimization level. Note that I removed the RegisterPass instantiation for IfConversion because it required a default constructor. If someone wants to keep that for some reason, we can add a default constructor with a hard-wired optimization level. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85346 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/IfConversion.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'lib/CodeGen/IfConversion.cpp') diff --git a/lib/CodeGen/IfConversion.cpp b/lib/CodeGen/IfConversion.cpp index 45f08b1..be9e1f1 100644 --- a/lib/CodeGen/IfConversion.cpp +++ b/lib/CodeGen/IfConversion.cpp @@ -148,9 +148,11 @@ namespace { const TargetInstrInfo *TII; bool MadeChange; int FnNum; + CodeGenOpt::Level OptLevel; public: static char ID; - IfConverter() : MachineFunctionPass(&ID), FnNum(-1) {} + IfConverter(CodeGenOpt::Level OL) : + MachineFunctionPass(&ID), FnNum(-1), OptLevel(OL) {} virtual bool runOnMachineFunction(MachineFunction &MF); virtual const char *getPassName() const { return "If Converter"; } @@ -219,10 +221,9 @@ namespace { char IfConverter::ID = 0; } -static RegisterPass -X("if-converter", "If Converter"); - -FunctionPass *llvm::createIfConverterPass() { return new IfConverter(); } +FunctionPass *llvm::createIfConverterPass(CodeGenOpt::Level OptLevel) { + return new IfConverter(OptLevel); +} bool IfConverter::runOnMachineFunction(MachineFunction &MF) { TLI = MF.getTarget().getTargetLowering(); @@ -362,7 +363,7 @@ bool IfConverter::runOnMachineFunction(MachineFunction &MF) { BBAnalysis.clear(); if (MadeChange) { - BranchFolder BF(false); + BranchFolder BF(false, OptLevel); BF.OptimizeFunction(MF, TII, MF.getTarget().getRegisterInfo(), getAnalysisIfAvailable()); -- cgit v1.1