Thin and full LTO modes use different pre-link pipelines compared to regular compilation. This patch adds support for calling those pipelines. This patch closely mimics Clang's implementation with the exception that I changed the codegen option name from `PrepareForLTO` to `PrepareForFullLTO` to be more precise. With this patch: - Compilation for full LTO should be as we expect (except possibly missing optimizations enabled by module summaries which we do not produce yet). - thinLTO uses the correct prelink pipeline but will use the postlink backend for fullLTO due to missing metadata and summary in the llvm module. I have added a warning regarding this: `flang-new: warning: the option '-flto=thin' is a work in progress`. Differential Revision: https://reviews.llvm.org/D142420 Change-Id: I6b94b775b5b8e93340e520c5cd4bf60834b2e209
41 lines
2.5 KiB
Fortran
41 lines
2.5 KiB
Fortran
! Verify that`-O{n}` is indeed taken into account when defining the LLVM optimization/middle-end pass pipeline.
|
|
|
|
! RUN: %flang -S -O0 %s -Xflang -fdebug-pass-manager -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-O0
|
|
! RUN: %flang -S -O0 %s -flto -Xflang -fdebug-pass-manager -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-O0-ANYLTO
|
|
! RUN: %flang -S -O0 %s -flto=thin -Xflang -fdebug-pass-manager -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-O0-ANYLTO
|
|
! RUN: %flang_fc1 -S -O0 %s -fdebug-pass-manager -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-O0
|
|
! RUN: %flang_fc1 -S -O0 %s -flto=full -fdebug-pass-manager -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-O0-ANYLTO
|
|
! RUN: %flang_fc1 -S -O0 %s -flto=thin -fdebug-pass-manager -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-O0-ANYLTO
|
|
|
|
! RUN: %flang -S -O2 %s -Xflang -fdebug-pass-manager -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-O2
|
|
! RUN: %flang -S -O2 %s -flto -Xflang -fdebug-pass-manager -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-O2-LTO
|
|
! RUN: %flang -S -O2 %s -flto=thin -Xflang -fdebug-pass-manager -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-O2-THINLTO
|
|
! RUN: %flang_fc1 -S -O2 %s -fdebug-pass-manager -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-O2
|
|
! RUN: %flang_fc1 -S -O2 %s -flto=full -fdebug-pass-manager -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-O2-LTO
|
|
! RUN: %flang_fc1 -S -O2 %s -flto=thin -fdebug-pass-manager -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-O2-THINLTO
|
|
|
|
! Verify that only the left-most `-O{n}` is used
|
|
! RUN: %flang -S -O2 -O0 %s -Xflang -fdebug-pass-manager -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-O0
|
|
! RUN: %flang_fc1 -S -O2 -O0 %s -fdebug-pass-manager -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-O0
|
|
|
|
! CHECK-O0-NOT: Running pass: SimplifyCFGPass on simple_loop_
|
|
! CHECK-O0: Running analysis: TargetLibraryAnalysis on simple_loop_
|
|
! CHECK-O0-ANYLTO: Running pass: CanonicalizeAliasesPass on [module]
|
|
! CHECK-O0-ANYLTO: Running pass: NameAnonGlobalPass on [module]
|
|
|
|
! CHECK-O2: Running pass: SimplifyCFGPass on simple_loop_
|
|
|
|
! CHECK-O2-LTO-NOT: Running pass: EliminateAvailableExternallyPass
|
|
! CHECK-O2-LTO: Running pass: CanonicalizeAliasesPass on [module]
|
|
! CHECK-O2-LTO: Running pass: NameAnonGlobalPass on [module]
|
|
|
|
! CHECK-O2-THINLTO-NOT: Running pass: LoopVectorizePass
|
|
! CHECK-O2-THINLTO: Running pass: CanonicalizeAliasesPass on [module]
|
|
! CHECK-O2-THINLTO: Running pass: NameAnonGlobalPass on [module]
|
|
|
|
subroutine simple_loop
|
|
integer :: i
|
|
do i=1,5
|
|
end do
|
|
end subroutine
|