[clang] Correctly link and optimize device libraries with -mlink-builtin-bitcode (PR #69371)

Jacob Lambert via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 6 09:41:26 PST 2023


================
@@ -1035,6 +1043,13 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
     }
   }
 
+  // Re-link against any bitcodes supplied via the -mlink-builtin-bitcode option
+  // Some optimizations may generate new function calls that would not have
+  // been linked pre-optimization (i.e. fused sincos calls generated by
+  // AMDGPULibCalls::fold_sincos.)
+  if (ClRelinkBuiltinBitcodePostop)
----------------
lamb-j wrote:

Also, the reason for LinkInModules pass is that we need to insert the second linking step into the RunOptimizationPipeline, specifically _after_ the AMDGPULibCalls pass, but _before_ the BitcodeWriter pass

https://github.com/llvm/llvm-project/pull/69371


More information about the cfe-commits mailing list