[PATCH] D45225: [WIP] Add IR function attributes to represent codegen optimization level

Chad Rosier via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 3 13:51:37 PDT 2018


mcrosier added inline comments.


================
Comment at: lib/IR/Module.cpp:91
 
+CodeGenOpt::Level Module::getCodeGenOptLevel() const {
+  if (FunctionList.empty())
----------------
efriedma wrote:
> This doesn't make any sense.  If it's a per-function attribute, we should be computing it per function.  The maximum level set on any function doesn't have any useful meaning.
The goal here is to approximate the codegen optimization level during LTO based on function level attributes.  Per the RFC, after r324557 the codegen optimization level for LTO is always CodeGenOpt::Default and is not configurable AFAICT.  However, the codegen optimization level has implications on how the codegen pipelines works (e.g., fast-isel vs selection dag, greedy vs. fast register allocator), which is at least one reason to try an approximate the codegen opt level (see the use of this function in lib/LTO/LTO.cpp).

On why I pick the max.. my thought is that if we're compiling with LTO the user is probably willing to aggressively optimize, so the heuristic chooses the highest optimization level...





https://reviews.llvm.org/D45225





More information about the llvm-commits mailing list