[LLVMdev] Missing optimizations (again -> pass ordering)

Hal Finkel hfinkel at anl.gov
Tue Aug 19 16:47:00 PDT 2014


----- Original Message -----
> From: "Carl-Philip Hänsch" <cphaensch at gmail.com>
> To: llvmdev at cs.uiuc.edu
> Sent: Monday, August 18, 2014 3:11:10 PM
> Subject: [LLVMdev] Missing optimizations (again -> pass ordering)
> 
> Hi,
> 
> I'm here again with an other issue with pass ordering:
> 
> Take a look at the following code.
> #include <stdio.h>
> #include <functional>
> 
> int main() {
> std::function<void(const char*)> hello = [](const char
> *name){printf("Hello %s\n", name);};
> hello("World");
> return 0;
> }
> 
> When I compile it with -O3 the optimizer does not recognize all
> optimizations. Instead I get 143 lines of complicated landing pad
> code, allocas etc..
> 
> When I put this code into an other opt -O3 process, I get much better
> code: 23 lines of code where the main function simply consists of a
> single printf call. (1 line) -> optimal code that I would write in
> C.
> 
> So, when using sophisticated stl data structures like std::function,
> std::vector, std::string, they are not molten down to their C
> equivalents until the optimizer runs twice, there is something wrong
> with pass ordering. Existing passes are okay, but they are not
> called often enough to remove all overhead. I hope there will be
> further work on rerunning passes.

There certainly will be further work in this area. However, we really need to make sure that we understand what's going on here, and why the existing pass manager configuration misses this. Rerunning the entire optimization pipeline is certainly a heavy hammer, and we'll need a more-targeted approach. Please file a bug report about this!

 -Hal

> 
> Cheers
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
> 

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory




More information about the llvm-dev mailing list