[llvm-bugs] [Bug 27509] New: Function Passes inadvertently skipped

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Apr 25 05:07:59 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=27509

            Bug ID: 27509
           Summary: Function Passes inadvertently skipped
           Product: tools
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: opt
          Assignee: unassignedbugs at nondot.org
          Reporter: jesper.antonsson at ericsson.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

In opt.cpp, if there are any passes specified in the argument list after an
optimizaton level is specified, the OptLevelO<x> is set to false by code like
this:

    if (OptLevelO3 && OptLevelO3.getPosition() < PassList.getPosition(i)) {
      AddOptimizationPasses(Passes, *FPasses, 3, 0);
      OptLevelO3 = false;
    }

This seems to be done to avoid rerunning AddOptimizationPasses(). But later,
FPasses is run only if any of these OptLevels are true:

  if (OptLevelO1 || OptLevelO2 || OptLevelOs || OptLevelOz || OptLevelO3) {
    FPasses->doInitialization();
    for (Function &F : *M)
      FPasses->run(F);
    FPasses->doFinalization();
  }

Thus FPasses is not run and I consider that a bug. My suggestion for a bugfix
is simple:

--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -598,7 +598,7 @@ int main(int argc, char **argv) {
   if (OptLevelO3)
     AddOptimizationPasses(Passes, *FPasses, 3, 0);

-  if (OptLevelO1 || OptLevelO2 || OptLevelOs || OptLevelOz || OptLevelO3) {
+  if (FPasses) {
     FPasses->doInitialization();
     for (Function &F : *M)
       FPasses->run(F);


BR,
Jesper Antonsson, Ericsson AB

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160425/5c05703c/attachment.html>


More information about the llvm-bugs mailing list