[cfe-dev] Adding extra line unexpectedly breaks optimization remark test

Leonard Chan via cfe-dev cfe-dev at lists.llvm.org
Tue Jun 11 17:52:43 PDT 2019


I was updating some tests to work with the new pass manager and I ran into
something weird
with clang/test/Frontend/optimization-remark-with-hotness.c. If you add a
comment (or even just an empty line) before an `expected-remark` in the
test, it fails and makes the expected diagnostic not appear anymore.

Original:
```
 56 void bar(int x) {
...
 63   // expected-remark at +1 {{foo inlined into bar with (cost=always):
always inliner (hotness:}}
 64   sum += foo(x, x - 2);
 65 }
```

Breaking:
```
 56 void bar(int x) {
...
 63   // random comment
 64   // expected-remark at +1 {{foo inlined into bar with (cost=always):
always inliner (hotness:}}
 65   sum += foo(x, x - 2);
 66 }
```

with error:

```
error: 'remark' diagnostics expected but not seen:
  File
/usr/local/google/home/leonardchan/llvm-monorepo/llvm-project-2/clang/test/Frontend/optimization-remark-with-hotness.c
Line 65 (directive at
/usr/local/google/home/leonardchan/llvm-monorepo/llvm-project-2/clang/test/Frontend/optimization-remark-with-hotness.c:65):
foo inlined into bar with (cost=always): always inliner (hotness:
1 error generated.
```

This appears to be the case even if the added text is just a newline, or
anywhere else within function bar(). I don't think this has to due with
changing anything `-verify` checks for since the remark doesn't appear
still even without `-verify`.

The run that breaks is:
```
19 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
 20 // RUN:     optimization-remark-with-hotness.c %s -emit-llvm-only \
 21 // RUN:     -fprofile-sample-use=%t-sample.profdata -Rpass=inline \
 22 // RUN:     -Rpass-analysis=inline -Rpass-missed=inline \
 23 // RUN:     -fdiagnostics-show-hotness
-fdiagnostics-hotness-threshold=10 \
 24 // RUN:     -verify
```

The test seems to pass and diagnostic appears if I remove
`-fdiagnostics-hotness-threshold=10`. Is it possible that this is intended
and extra comments affects hotness?

Thanks,
Leonard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190611/6218f3cc/attachment.html>


More information about the cfe-dev mailing list