From b05bddb4bae4e693225df4c517d9b368d923f1b3 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Thu, 21 Nov 2013 10:55:15 +0000 Subject: [PATCH] Revert r195317 (and r195333), "Teach ISel not to optimize 'optnone' functions." It broke, at least, i686 target. It is reproducible with "llc -mtriple=i686-unknown". FYI, it didn't appear to add either "-O0" or "-fast-isel". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195339 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCCodeGenInfo.h | 3 -- include/llvm/Target/TargetMachine.h | 6 +-- lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 41 +------------------ lib/Target/TargetMachine.cpp | 5 --- test/CodeGen/Generic/isel-optnone.ll | 32 --------------- 5 files changed, 2 insertions(+), 85 deletions(-) delete mode 100644 test/CodeGen/Generic/isel-optnone.ll diff --git a/include/llvm/MC/MCCodeGenInfo.h b/include/llvm/MC/MCCodeGenInfo.h index 84ce934d822..d1765e1240a 100644 --- a/include/llvm/MC/MCCodeGenInfo.h +++ b/include/llvm/MC/MCCodeGenInfo.h @@ -42,9 +42,6 @@ namespace llvm { CodeModel::Model getCodeModel() const { return CMModel; } CodeGenOpt::Level getOptLevel() const { return OptLevel; } - - // Allow overriding OptLevel on a per-function basis. - void setOptLevel(CodeGenOpt::Level Level) { OptLevel = Level; } }; } // namespace llvm diff --git a/include/llvm/Target/TargetMachine.h b/include/llvm/Target/TargetMachine.h index 11b0f5fb77f..91e4715eea3 100644 --- a/include/llvm/Target/TargetMachine.h +++ b/include/llvm/Target/TargetMachine.h @@ -75,8 +75,7 @@ protected: // Can only create subclasses. std::string TargetFS; /// CodeGenInfo - Low level target information such as relocation model. - /// Non-const to allow resetting optimization level per-function. - MCCodeGenInfo *CodeGenInfo; + const MCCodeGenInfo *CodeGenInfo; /// AsmInfo - Contains target specific asm information. /// @@ -214,9 +213,6 @@ public: /// Default, or Aggressive. CodeGenOpt::Level getOptLevel() const; - /// \brief Overrides the optimization level. - void setOptLevel(CodeGenOpt::Level Level) const; - void setFastISel(bool Enable) { Options.EnableFastISel = Enable; } bool shouldPrintMachineCode() const { return Options.PrintMachineCode; } diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index faca3ee823c..91cb125dc89 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -222,39 +222,6 @@ defaultListDAGScheduler("default", "Best scheduler for the target", createDefaultScheduler); namespace llvm { - //===--------------------------------------------------------------------===// - /// \brief This struct is used by SelectionDAGISel to temporarily override - /// the optimization level on a per-function basis. - class OptLevelChanger { - SelectionDAGISel &IS; - CodeGenOpt::Level SavedOptLevel; - - public: - OptLevelChanger(SelectionDAGISel &ISel, - CodeGenOpt::Level NewOptLevel) : IS(ISel) { - SavedOptLevel = IS.OptLevel; - if (NewOptLevel == SavedOptLevel) - return; - IS.OptLevel = NewOptLevel; - IS.TM.setOptLevel(NewOptLevel); - DEBUG(dbgs() << "\nChanging optimization level for Function " - << IS.MF->getFunction()->getName() << "\n"); - DEBUG(dbgs() << "\tBefore: -O" << SavedOptLevel - << " ; After: -O" << NewOptLevel << "\n"); - } - - ~OptLevelChanger() { - if (IS.OptLevel == SavedOptLevel) - return; - DEBUG(dbgs() << "\nRestoring optimization level for Function " - << IS.MF->getFunction()->getName() << "\n"); - DEBUG(dbgs() << "\tBefore: -O" << IS.OptLevel - << " ; After: -O" << SavedOptLevel << "\n"); - IS.OptLevel = SavedOptLevel; - IS.TM.setOptLevel(SavedOptLevel); - } - }; - //===--------------------------------------------------------------------===// /// createDefaultScheduler - This creates an instruction scheduler appropriate /// for the target. @@ -403,12 +370,6 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) { ST.resetSubtargetFeatures(MF); TM.resetTargetOptions(MF); - // Reset OptLevel to None for optnone functions. - CodeGenOpt::Level NewOptLevel = OptLevel; - if (Fn.hasFnAttribute(Attribute::OptimizeNone)) - NewOptLevel = CodeGenOpt::None; - OptLevelChanger OLC(*this, NewOptLevel); - DEBUG(dbgs() << "\n\n\n=== " << Fn.getName() << "\n"); SplitCriticalSideEffectEdges(const_cast(Fn), this); @@ -987,7 +948,7 @@ static void collectFailStats(const Instruction *I) { void SelectionDAGISel::SelectAllBasicBlocks(const Function &Fn) { // Initialize the Fast-ISel state, if needed. FastISel *FastIS = 0; - if (TM.Options.EnableFastISel || Fn.hasFnAttribute(Attribute::OptimizeNone)) + if (TM.Options.EnableFastISel) FastIS = getTargetLowering()->createFastISel(*FuncInfo, LibInfo); // Iterate over all basic blocks in the function. diff --git a/lib/Target/TargetMachine.cpp b/lib/Target/TargetMachine.cpp index cb42e8311b8..df4a03c9e8b 100644 --- a/lib/Target/TargetMachine.cpp +++ b/lib/Target/TargetMachine.cpp @@ -164,11 +164,6 @@ CodeGenOpt::Level TargetMachine::getOptLevel() const { return CodeGenInfo->getOptLevel(); } -void TargetMachine::setOptLevel(CodeGenOpt::Level Level) const { - if (CodeGenInfo) - CodeGenInfo->setOptLevel(Level); -} - bool TargetMachine::getAsmVerbosityDefault() { return AsmVerbosityDefault; } diff --git a/test/CodeGen/Generic/isel-optnone.ll b/test/CodeGen/Generic/isel-optnone.ll deleted file mode 100644 index f4916dafb84..00000000000 --- a/test/CodeGen/Generic/isel-optnone.ll +++ /dev/null @@ -1,32 +0,0 @@ -; RUN: llc -debug < %s -o /dev/null 2>&1 | FileCheck %s -; REQUIRES: asserts - -; Verify that the backend correctly overrides the optimization level -; of optnone functions during instruction selection. - -define float @foo(float %x) #0 { -entry: - %add = fadd fast float %x, %x - %add1 = fadd fast float %add, %x - ret float %add1 -} - -; CHECK-NOT: Changing optimization level for Function foo -; CHECK-NOT: Restoring optimization level for Function foo - -; Function Attrs: noinline optnone -define float @fooWithOptnone(float %x) #1 { -entry: - %add = fadd fast float %x, %x - %add1 = fadd fast float %add, %x - ret float %add1 -} - -; CHECK: Changing optimization level for Function fooWithOptnone -; CHECK-NEXT: Before: -O2 ; After: -O0 - -; CHECK: Restoring optimization level for Function fooWithOptnone -; CHECK-NEXT: Before: -O0 ; After: -O2 - -attributes #0 = { "unsafe-fp-math"="true" } -attributes #1 = { noinline optnone "unsafe-fp-math"="true" } -- 2.34.1