[llvm] r195339 - Revert r195317 (and r195333), "Teach ISel not to optimize 'optnone' functions."

NAKAMURA Takumi geek4civic at gmail.com
Thu Nov 21 02:55:15 PST 2013


Author: chapuni
Date: Thu Nov 21 04:55:15 2013
New Revision: 195339

URL: http://llvm.org/viewvc/llvm-project?rev=195339&view=rev
Log:
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".

Removed:
    llvm/trunk/test/CodeGen/Generic/isel-optnone.ll
Modified:
    llvm/trunk/include/llvm/MC/MCCodeGenInfo.h
    llvm/trunk/include/llvm/Target/TargetMachine.h
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
    llvm/trunk/lib/Target/TargetMachine.cpp

Modified: llvm/trunk/include/llvm/MC/MCCodeGenInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCCodeGenInfo.h?rev=195339&r1=195338&r2=195339&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCCodeGenInfo.h (original)
+++ llvm/trunk/include/llvm/MC/MCCodeGenInfo.h Thu Nov 21 04:55:15 2013
@@ -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
 

Modified: llvm/trunk/include/llvm/Target/TargetMachine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetMachine.h?rev=195339&r1=195338&r2=195339&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetMachine.h (original)
+++ llvm/trunk/include/llvm/Target/TargetMachine.h Thu Nov 21 04:55:15 2013
@@ -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; }

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=195339&r1=195338&r2=195339&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Thu Nov 21 04:55:15 2013
@@ -223,39 +223,6 @@ defaultListDAGScheduler("default", "Best
 
 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.
   ScheduleDAGSDNodes* createDefaultScheduler(SelectionDAGISel *IS,
@@ -403,12 +370,6 @@ bool SelectionDAGISel::runOnMachineFunct
   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<Function&>(Fn), this);
@@ -987,7 +948,7 @@ static void collectFailStats(const Instr
 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.

Modified: llvm/trunk/lib/Target/TargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetMachine.cpp?rev=195339&r1=195338&r2=195339&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/TargetMachine.cpp Thu Nov 21 04:55:15 2013
@@ -164,11 +164,6 @@ CodeGenOpt::Level TargetMachine::getOptL
   return CodeGenInfo->getOptLevel();
 }
 
-void TargetMachine::setOptLevel(CodeGenOpt::Level Level) const {
-  if (CodeGenInfo)
-    CodeGenInfo->setOptLevel(Level);
-}
-
 bool TargetMachine::getAsmVerbosityDefault() {
   return AsmVerbosityDefault;
 }

Removed: llvm/trunk/test/CodeGen/Generic/isel-optnone.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Generic/isel-optnone.ll?rev=195338&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Generic/isel-optnone.ll (original)
+++ llvm/trunk/test/CodeGen/Generic/isel-optnone.ll (removed)
@@ -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" }





More information about the llvm-commits mailing list