[PATCH] D30920: Do not pass -Os and -Oz to the Gold plugin

Mehdi AMINI via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 16 15:34:17 PDT 2017


mehdi_amini added a comment.

The fundamental difference, is that Os/Oz especially are treated as `optimizations directive` that are independent of the pass pipeline: instructing that "loop unroll should not increase size" is independent of *where* is loop unroll inserted in the pipeline.

The issue with https://reviews.llvm.org/owners/package/1/ vs https://reviews.llvm.org/owners/package/2/ is that the *ordering* of the passes changes, not only the threshold to apply. For some of the differences we could get away with adding the level as a function attribute for instance, and have the PassManager itself skipping passes depending on the level. For instance the API for the pass manager could be

  PM.add(createLoopUnroll(), /* "shouldRun()" callback */ [] (Function &F) { return F.getAttribute("opt_level") > 1; });

And the PM would call back the lambda and actually skip the LoopUnroll when the level is <2, in way that the client can customize with the position in the pipeline. But this can be very hard to setup a pipeline this way when we'd do more than just skipping but having different pass ordering entirely.

Also this wouldn't work with an SCC pass, as different functions in the SCC can have different level, it gets quite tricky. It also becomes problematic for any module level pass: `Dead Global Elimination` would need to leave out global variable that comes from a module compiled with https://reviews.llvm.org/owners/package/1/, same with `Merge Duplicate Global Constants` (I think the issue with `GlobalVariable` affects also Os/Oz by the way).


https://reviews.llvm.org/D30920





More information about the cfe-commits mailing list