[PATCH] gold, libLTO: Add new flags to support bit set lowering.

Duncan P. N. Exon Smith dexonsmith at apple.com
Tue Mar 17 17:14:31 PDT 2015


> On 2015-Mar-17, at 16:03, Rafael Ávila de Espíndola <rafael.espindola at gmail.com> wrote:
> 
> ================
> Comment at: lib/Transforms/IPO/PassManagerBuilder.cpp:530
> @@ +529,3 @@
> +    // Clean up after the bit set lowering pass.
> +    PM.add(createCFGSimplificationPass());
> +
> ----------------
> Should these still be enabled at -O0?
> 
> ================
> Comment at: tools/gold/gold-plugin.cpp:98
> @@ -97,1 +97,3 @@
>   static std::string mcpu;
> +  static bool disable_opt = false;
> +  static bool lowerbitsets = false;
> ----------------
> DisableOpt.
> LowerBitSets.
> 
> http://reviews.llvm.org/D8401
> 
> EMAIL PREFERENCES
>  http://reviews.llvm.org/settings/panel/emailpreferences/
> 
> 

> Index: lib/Transforms/IPO/PassManagerBuilder.cpp
> ===================================================================
> --- lib/Transforms/IPO/PassManagerBuilder.cpp
> +++ lib/Transforms/IPO/PassManagerBuilder.cpp
> @@ -99,6 +99,7 @@
>      VerifyOutput = false;
>      StripDebug = false;
>      MergeFunctions = false;
> +    LowerBitSets = false;
>  }
>  
>  PassManagerBuilder::~PassManagerBuilder() {
> @@ -493,9 +494,6 @@
>  
>    PM.add(createJumpThreadingPass());
>  
> -  // Lower bitset metadata to bitsets.
> -  PM.add(createLowerBitSetsPass());
> -
>    // Delete basic blocks, which optimization passes may have killed.
>    PM.add(createCFGSimplificationPass());
>  
> @@ -524,6 +522,18 @@
>    if (OptLevel != 0)
>      addLTOOptimizationPasses(PM);
>  
> +  if (LowerBitSets) {
> +    // Lower bitset metadata to bitsets.
> +    PM.add(createLowerBitSetsPass());
> +
> +    // Clean up after the bit set lowering pass.
> +    PM.add(createCFGSimplificationPass());

Why are you running CFG simplification at -O0?

> +
> +    // Discard unused entities if we haven't already done so.
> +    if (OptLevel == 0)
> +      PM.add(createGlobalDCEPass());
> +  }
> +
>    if (VerifyOutput) {
>      PM.add(createVerifierPass());
>      PM.add(createDebugInfoVerifierPass());
> 

This will fail to run the (mandatory, as I understand it?) pass if using
`lto_codegen_compile_optimized()`.  Also, adding command-line options to
libLTO.dylib isn't really useful.  They're not supported, and are only
used for debugging.

Any reason you can't just add this to
`LTOCodeGenerator::compileOptimized()`, next to
`createObjCArcContractPass()`?

If optimizations are on, it'll run twice, but (looking at the code) the
second time will be free.

If optimizations are off, it'll run once, and won't get CFG cleanups
(which it shouldn't anyway, since optimizations are off).

Then you can keep this logic inside `addLTOOptimizationPasses()` and
avoid duplicating the -simplify-cfg and -dce runs.






More information about the llvm-commits mailing list