[all-commits] [llvm/llvm-project] c49b60: [Remarks] Emit remarks for "auto-init" !annotations

Visoiu Mistrih Francis via All-commits all-commits at lists.llvm.org
Thu Feb 25 15:14:49 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c49b600b2f8242612f60637ca9bdbc4e2b31f800
      https://github.com/llvm/llvm-project/commit/c49b600b2f8242612f60637ca9bdbc4e2b31f800
  Author: Francis Visoiu Mistrih <francisvm at yahoo.com>
  Date:   2021-02-25 (Thu, 25 Feb 2021)

  Changed paths:
    M llvm/lib/Transforms/Scalar/AnnotationRemarks.cpp
    A llvm/test/Transforms/Util/trivial-auto-var-init-call.ll
    A llvm/test/Transforms/Util/trivial-auto-var-init-store.ll
    A llvm/test/Transforms/Util/trivial-auto-var-init-unknown.ll

  Log Message:
  -----------
  [Remarks] Emit remarks for "auto-init" !annotations

Using the !annotation metadata, emit remarks pointing to code added by
`-ftrivial-auto-var-init` that survived the optimizer.

Example:

```
auto-init.c:4:7: remark: Initialization inserted by -ftrivial-auto-var-init. [-Rpass-missed=annotation-remarks]
  int buf[1024];
      ^
```

The tests are testing various situations like calls/stores/other
instructions, with debug locations, and extra debug information on
purpose: more patches will come to improve the reporting to make it more
user-friendly, and these tests will show how the reporting evolves.

Differential Revision: https://reviews.llvm.org/D97405


  Commit: 4753a69a316b7705fc1b1442ad88afac059d542f
      https://github.com/llvm/llvm-project/commit/4753a69a316b7705fc1b1442ad88afac059d542f
  Author: Francis Visoiu Mistrih <francisvm at yahoo.com>
  Date:   2021-02-25 (Thu, 25 Feb 2021)

  Changed paths:
    A llvm/include/llvm/Transforms/Utils/AutoInitRemark.h
    M llvm/lib/Transforms/Scalar/AnnotationRemarks.cpp
    A llvm/lib/Transforms/Utils/AutoInitRemark.cpp
    M llvm/lib/Transforms/Utils/CMakeLists.txt
    M llvm/test/Transforms/Util/trivial-auto-var-init-store.ll

  Log Message:
  -----------
  [Remarks] Provide more information about auto-init stores

This adds support for analyzing the instruction with the !annotation
"auto-init" in order to generate a more user-friendly remark.

For now, support the store size, and whether it's atomic/volatile.

Example:

```
auto-init.c:4:7: remark: Store inserted by -ftrivial-auto-var-init.Store size: 4 bytes. [-Rpass-missed=annotation-remarks]
  int var;
      ^
```

Differential Revision: https://reviews.llvm.org/D97412


  Commit: fee9abe69c0eb5529984f5573cf6a5d881f80649
      https://github.com/llvm/llvm-project/commit/fee9abe69c0eb5529984f5573cf6a5d881f80649
  Author: Francis Visoiu Mistrih <francisvm at yahoo.com>
  Date:   2021-02-25 (Thu, 25 Feb 2021)

  Changed paths:
    M llvm/include/llvm/Transforms/Utils/AutoInitRemark.h
    M llvm/lib/Transforms/Scalar/AnnotationRemarks.cpp
    M llvm/lib/Transforms/Utils/AutoInitRemark.cpp
    M llvm/test/Other/new-pm-O0-defaults.ll
    M llvm/test/Transforms/Util/trivial-auto-var-init-call.ll
    M llvm/test/Transforms/Util/trivial-auto-var-init-unknown.ll

  Log Message:
  -----------
  [Remarks] Provide more information about auto-init calls

This now analyzes calls to both intrinsics and functions.

For intrinsics, grab the ones we know and care about (mem* family) and
analyze the arguments.

For calls, use TLI to get more information about the libcalls, then
analyze the arguments if known.

```
auto-init.c:4:7: remark: Call to memset inserted by -ftrivial-auto-var-init. Memory operation size: 4096 bytes. [-Rpass-missed=annotation-remarks]
  int var[1024];
      ^
```

Differential Revision: https://reviews.llvm.org/D97489


Compare: https://github.com/llvm/llvm-project/compare/00b3f2f310b4...fee9abe69c0e


More information about the All-commits mailing list