Add support for generating and saving the optimization record. Optimization record lists the optimizations performed by LLVM. This patch enables the flag in Flang. Clang handles this functionality using the BackendConsumer which Flang doesn't have, hence, was implemented in CodeGenAction::executeAction FlangOption added to all variants of fsave-optimization-record in clang/include/clang/Driver/Options.td . Clang handles it the same way. opt_record_file, opt_record_passes and opt_record_format flags in Options.td were moved out of the group [CC1Option, NoDriverOption] to allow flang -fc1 support. The renderRemarksOptions and willEmitRemarks functions in clang/lib/Driver/ToolChains/Flang.cpp follow same syntax as clang. In flang/lib/Frontend/CompilerInvocation.cpp we update the field OptRecordFile with the provided optimization file value. Clang doesn't do this as it processes the Options.td, mapping the OptRecordFile earlier on. Reviewed By: awarzynski, tblah Differential Revision: https://reviews.llvm.org/D155452
60 lines
1.6 KiB
Fortran
60 lines
1.6 KiB
Fortran
! Tests for the '-f[no-]save-optimization-record[=<format>]' flag.
|
|
|
|
! Test opt_record flags get generated for fc1
|
|
! RUN: %flang -### %s 2>&1 \
|
|
! RUN: -foptimization-record-file=%t.opt.yaml \
|
|
! RUN: | FileCheck --check-prefix=YAML %s
|
|
|
|
! RUN: %flang -### %s 2>&1 \
|
|
! RUN: -fsave-optimization-record \
|
|
! RUN: | FileCheck --check-prefix=YAML %s
|
|
|
|
|
|
! Test -foptimization-record-file produces YAML file with given content
|
|
! RUN: rm -f %t.opt.yaml
|
|
! RUN: %flang -foptimization-record-file=%t.opt.yaml -c %s
|
|
! RUN: cat %t.opt.yaml | FileCheck %s
|
|
|
|
|
|
! Test -fsave-optimization-record produces YAML file with given content
|
|
! RUN: rm -f %t.opt.yaml
|
|
! RUN: %flang -fsave-optimization-record -c -o %t.o %s
|
|
! RUN: cat %t.opt.yaml | FileCheck %s
|
|
|
|
! RUN: rm -f %t.opt.yaml
|
|
! RUN: %flang -fsave-optimization-record -S -o %t.s %s
|
|
! RUN: cat %t.opt.yaml | FileCheck %s
|
|
|
|
|
|
! Produces an empty file
|
|
! RUN: rm -f %t.opt.yaml
|
|
! RUN: %flang -fsave-optimization-record -S -emit-llvm -o %t.ll %s
|
|
! RUN: cat %t.opt.yaml
|
|
|
|
|
|
!Test unknown format produces error
|
|
! RUN: not %flang -fsave-optimization-record=hello %s 2>&1 \
|
|
! RUN: | FileCheck --check-prefix=CHECK-FORMAT-ERROR %s
|
|
|
|
|
|
! YAML: "-opt-record-file" "{{.+}}.opt.yaml"
|
|
! YAML: "-opt-record-format" "yaml"
|
|
|
|
! CHECK: --- !Analysis
|
|
! CHECK: Pass: prologepilog
|
|
! CHECK: Name: StackSize
|
|
! CHECK: Function: _QQmain
|
|
! CHECK: Pass: asm-printer
|
|
! CHECK: Name: InstructionMix
|
|
! CHECK: Name: InstructionCount
|
|
|
|
! CHECK-FORMAT-ERROR: error: unknown remark serializer format: 'hello'
|
|
|
|
program forttest
|
|
implicit none
|
|
integer :: n
|
|
|
|
n = 1 * 1
|
|
|
|
end program forttest
|