hanchenye-llvm-project/clang/test/Misc
Michael Kruse 7244852557 [Unroll/UnrollAndJam/Vectorizer/Distribute] Add followup loop attributes.
When multiple loop transformation are defined in a loop's metadata, their order of execution is defined by the order of their respective passes in the pass pipeline. For instance, e.g.

    #pragma clang loop unroll_and_jam(enable)
    #pragma clang loop distribute(enable)

is the same as

    #pragma clang loop distribute(enable)
    #pragma clang loop unroll_and_jam(enable)

and will try to loop-distribute before Unroll-And-Jam because the LoopDistribute pass is scheduled after UnrollAndJam pass. UnrollAndJamPass only supports one inner loop, i.e. it will necessarily fail after loop distribution. It is not possible to specify another execution order. Also,t the order of passes in the pipeline is subject to change between versions of LLVM, optimization options and which pass manager is used.

This patch adds 'followup' attributes to various loop transformation passes. These attributes define which attributes the resulting loop of a transformation should have. For instance,

    !0 = !{!0, !1, !2}
    !1 = !{!"llvm.loop.unroll_and_jam.enable"}
    !2 = !{!"llvm.loop.unroll_and_jam.followup_inner", !3}
    !3 = !{!"llvm.loop.distribute.enable"}

defines a loop ID (!0) to be unrolled-and-jammed (!1) and then the attribute !3 to be added to the jammed inner loop, which contains the instruction to distribute the inner loop.

Currently, in both pass managers, pass execution is in a fixed order and UnrollAndJamPass will not execute again after LoopDistribute. We hope to fix this in the future by allowing pass managers to run passes until a fixpoint is reached, use Polly to perform these transformations, or add a loop transformation pass which takes the order issue into account.

For mandatory/forced transformations (e.g. by having been declared by #pragma omp simd), the user must be notified when a transformation could not be performed. It is not possible that the responsible pass emits such a warning because the transformation might be 'hidden' in a followup attribute when it is executed, or it is not present in the pipeline at all. For this reason, this patche introduces a WarnMissedTransformations pass, to warn about orphaned transformations.

Since this changes the user-visible diagnostic message when a transformation is applied, two test cases in the clang repository need to be updated.

To ensure that no other transformation is executed before the intended one, the attribute `llvm.loop.disable_nonforced` can be added which should disable transformation heuristics before the intended transformation is applied. E.g. it would be surprising if a loop is distributed before a #pragma unroll_and_jam is applied.

With more supported code transformations (loop fusion, interchange, stripmining, offloading, etc.), transformations can be used as building blocks for more complex transformations (e.g. stripmining+stripmining+interchange -> tiling).

Reviewed By: hfinkel, dmgreen

Differential Revision: https://reviews.llvm.org/D49281
Differential Revision: https://reviews.llvm.org/D55288

llvm-svn: 348944
2018-12-12 17:32:52 +00:00
..
Inputs Move AST tests into their own test directory; NFC. 2018-11-30 18:43:02 +00:00
amdgcn.languageOptsOpenCL.cl
attr-source-range.cpp
backend-optimization-failure-nodbg.cpp [Unroll/UnrollAndJam/Vectorizer/Distribute] Add followup loop attributes. 2018-12-12 17:32:52 +00:00
backend-optimization-failure.cpp [Unroll/UnrollAndJam/Vectorizer/Distribute] Add followup loop attributes. 2018-12-12 17:32:52 +00:00
backend-resource-limit-diagnostics.cl
backend-stack-frame-diagnostics-fallback.cpp
backend-stack-frame-diagnostics.cpp
caret-diags-macros.c
caret-diags-multiline.cpp
caret-diags-scratch-buffer.c
cc1as-asm.s
cc1as-compress.s
cc1as-split-dwarf.s
dev-fd-fs.c
diag-aka-types.cpp
diag-format.c
diag-greatergreater.cpp
diag-line-wrapping.cpp
diag-macro-backtrace.c
diag-macro-backtrace2.c DR1687: When overload resolution selects a built-in operator, implicit 2018-06-27 20:30:34 +00:00
diag-mapping.c
diag-mapping2.c
diag-null-bytes-in-line.cpp
diag-presumed.c
diag-special-chars.c
diag-template-diffing-color.cpp
diag-template-diffing-cxx98.cpp
diag-template-diffing.cpp
diag-trailing-null-bytes.cpp
diag-verify.cpp
diagnostic-crash.cpp
driver-verify.c
emit-html-insert.c
emit-html.c
error-limit-multiple-notes.cpp
error-limit.c
find-diagnostic-id.c
freebsd-arm-size_t.c
include-stack-for-note-flag.cpp
integer-literal-printing.cpp
interpreter.c
languageOptsOpenCL.cl
macro-backtrace.c
message-length.c
nvptx.languageOptsOpenCL.cl
permissions.cpp
pr32207.c
pragma-attribute-cxx.cpp
pragma-attribute-objc.m
pragma-attribute-strict-subjects.c
pragma-attribute-supported-attributes-list.test NFC: Make this test kinder on downstream forks 2018-12-04 00:31:31 +00:00
predefines.c
r600.languageOptsOpenCL.cl
reduced-diags-macros-backtrace.cpp
reduced-diags-macros.cpp
remap-file.c
serialized-diags-bcanalyzer.c
serialized-diags-driver.c
serialized-diags-frontend.c
serialized-diags-no-category.c
serialized-diags-no-issue.c
serialized-diags-really-long-text.cpp
serialized-diags-single-issue.c
serialized-diags-stable.c
serialized-diags.c
serialized-diags.h
serialized-diags.m
show-diag-options.c
tabstop.c
target-invalid-cpu-note.c [X86] Add -march=cascadelake support in clang. 2018-11-27 18:05:14 +00:00
target-parser.c
unnecessary-elipses.cpp
unprintable.c
verify.c
warn-in-system-header.c
warn-in-system-header.h
warn-sysheader.cpp
warning-flags-enabled.c
warning-flags-tree.c
warning-flags.c Create a diagnostic group for warn_call_to_pure_virtual_member_function_from_ctor_dtor, so it can be turned into an error using Werror 2018-11-26 14:29:48 +00:00
win32-macho.c
working-directory.c
wrong-encoding.c
wrong-encoding2.c