[PGO] Change ThinLTO test for targets with loop unrolling disabled
authorSherwin da Cruz <59867245+sherwin-dc@users.noreply.github.com>
Thu, 16 Sep 2021 10:07:21 +0000 (11:07 +0100)
committerThomas Preud'homme <thomasp@graphcore.ai>
Thu, 16 Sep 2021 10:13:16 +0000 (11:13 +0100)
commit005fc11ebdd6e1af29efee3d7c5da86f56138414
treef4897bb045055a7e63547e403005f923f6920ef9
parent86a58f10284dea118703ecde0ef5b9a4f6e4d8be
[PGO] Change ThinLTO test for targets with loop unrolling disabled

I am working on a target in a downstream LLVM repo, and it seems that if a target backend chooses to disable loop unrolling this test would fail. A solution would be to modify the test to search for a different string instead.

The specific test checks for `if.true.direct_targ` which appears in the output when thinlto is not used (ie samplepgo). The same is true for `if.false.orig_indirect`.

However, if a target disables loop unrolling in the backend, the test fails as  `if.true.direct_targ` no longer appears, though `if.false.orig_indirect` still does. This can be seen by using a clang pragma to disable loop unrolling in the `unroll()` function.

For reference, the following files are the outputs of the last 2 test functions being compiled as the test case does, with and without thinlto, and with and without loop unrolling on the latest x86 clang build. The loop unrolling pragma was used to simulate the loop unrolling being disabled in a backend.
```
// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o out.ll
// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o out.ll
```

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D109234
clang/test/CodeGen/pgo-sample-thinlto-summary.c