llvm-project/clang/test/CodeGen/linking-bitcode-postopt.cpp
Jacob Lambert 11a6799740
[clang][CodeGen] Omit pre-opt link when post-opt is link requested (#85672)
Currently, when the -relink-builtin-bitcodes-postop option is used we
link builtin bitcodes twice: once before optimization, and again after
optimization.

With this change, we omit the pre-opt linking when the option is set,
and we rename the option to the following:

  -Xclang -mlink-builtin-bitcodes-postopt
 (-Xclang -mno-link-builtin-bitcodes-postopt) 

The goal of this change is to reduce compile time. We do lose the
theoretical benefits of pre-opt linking, but in practice these are small
than the overhead of linking twice. However we may be able to address
this in a future patch by adjusting the position of the builtin-bitcode
linking pass.

Compilations not setting the option are unaffected
2024-05-08 08:11:15 -07:00

32 lines
1.1 KiB
C++

// REQUIRES: amdgpu-registered-target
// Test that -mlink-bitcode-postopt correctly enables LinkInModulesPass
// RUN: %clang_cc1 -triple amdgcn-- -emit-llvm-bc -o /dev/null \
// RUN: -mllvm -print-pipeline-passes \
// RUN: %s 2>&1 | FileCheck --check-prefixes=DEFAULT %s
// DEFAULT-NOT: LinkInModulesPass
// RUN: %clang_cc1 -triple amdgcn-- -emit-llvm-bc -o /dev/null \
// RUN: -mllvm -print-pipeline-passes \
// RUN: -mlink-builtin-bitcode-postopt \
// RUN: %s 2>&1 | FileCheck --check-prefixes=OPTION-POSITIVE %s
// OPTION-POSITIVE: LinkInModulesPass
// RUN: %clang_cc1 -triple amdgcn-- -emit-llvm-bc -o /dev/null \
// RUN: -mllvm -print-pipeline-passes \
// RUN: -mno-link-builtin-bitcode-postopt \
// RUN: %s 2>&1 | FileCheck --check-prefixes=OPTION-NEGATIVE %s
// OPTION-NEGATIVE-NOT: LinkInModulesPass
// RUN: %clang_cc1 -triple amdgcn-- -emit-llvm-bc -o /dev/null \
// RUN: -mllvm -print-pipeline-passes \
// RUN: -mlink-builtin-bitcode-postopt \
// RUN: -mno-link-builtin-bitcode-postopt \
// RUN: %s 2>&1 | FileCheck --check-prefixes=OPTION-POSITIVE-NEGATIVE %s
// OPTION-POSITIVE-NEGATIVE-NOT: LinkInModulesPass