llvm-project/llvm
Hongtao Yu d0e42037bf [CSSPGO] MIR target-independent pseudo instruction for pseudo-probe intrinsic
This change introduces a MIR target-independent pseudo instruction corresponding to the IR intrinsic llvm.pseudoprobe for pseudo-probe block instrumentation. Please refer to https://reviews.llvm.org/D86193 for the whole story.

An `llvm.pseudoprobe` intrinsic call will be lowered into a target-independent operation named `PSEUDO_PROBE`. Given the following instrumented IR,

```
define internal void @foo2(i32 %x, void (i32)* %f) !dbg !4 {
bb0:
   %cmp = icmp eq i32 %x, 0
   call void @llvm.pseudoprobe(i64 837061429793323041, i64 1)
   br i1 %cmp, label %bb1, label %bb2
bb1:
   call void @llvm.pseudoprobe(i64 837061429793323041, i64 2)
   br label %bb3
bb2:
   call void @llvm.pseudoprobe(i64 837061429793323041, i64 3)
   br label %bb3
bb3:
   call void @llvm.pseudoprobe(i64 837061429793323041, i64 4)
   ret void
}
```
the corresponding MIR is shown below. Note that block `bb3` is duplicated into `bb1` and `bb2` where its probe is duplicated too. This allows for an accurate execution count to be collected for `bb3`, which is basically the sum of the counts of `bb1` and `bb2`.

```
bb.0.bb0:
   frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp
   TEST32rr killed renamable $edi, renamable $edi, implicit-def $eflags
   PSEUDO_PROBE 837061429793323041, 1, 0
   $edi = MOV32ri 1, debug-location !13; test.c:0
   JCC_1 %bb.1, 4, implicit $eflags

bb.2.bb2:
   PSEUDO_PROBE 837061429793323041, 3, 0
   PSEUDO_PROBE 837061429793323041, 4, 0
   $rax = frame-destroy POP64r implicit-def $rsp, implicit $rsp
   RETQ

bb.1.bb1:
   PSEUDO_PROBE 837061429793323041, 2, 0
   PSEUDO_PROBE 837061429793323041, 4, 0
   $rax = frame-destroy POP64r implicit-def $rsp, implicit $rsp
   RETQ
```

The target op PSEUDO_PROBE will be converted into a piece of binary data by the object emitter with no machine instructions generated. This is done in a different patch.

Reviewed By: wmi

Differential Revision: https://reviews.llvm.org/D86495
2020-11-20 10:52:43 -08:00
..
benchmarks
bindings Revert "[IR] add fn attr for no_stack_protector; prevent inlining on mismatch" 2020-11-17 17:27:14 -08:00
cmake [CMake] Fix ExtensionDependencies.inc with multiple extensions 2020-11-17 17:24:47 -08:00
docs Add a default address space for globals to DataLayout 2020-11-20 15:46:52 +00:00
examples llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
include [CSSPGO] MIR target-independent pseudo instruction for pseudo-probe intrinsic 2020-11-20 10:52:43 -08:00
lib [CSSPGO] MIR target-independent pseudo instruction for pseudo-probe intrinsic 2020-11-20 10:52:43 -08:00
projects llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
resources
runtimes
test [CSSPGO] MIR target-independent pseudo instruction for pseudo-probe intrinsic 2020-11-20 10:52:43 -08:00
tools [llvm-readelf/obj] - Improve error reporting when dumping group sections. 2020-11-20 12:40:23 +03:00
unittests [AMDGPU] Set the default globals address space to 1 2020-11-20 15:46:53 +00:00
utils [gn build] Port 8adc4d1ec7 2020-11-20 00:15:31 +00:00
.clang-format
.clang-tidy
.gitattributes
.gitignore
CMakeLists.txt llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
CODE_OWNERS.TXT [CODE_OWNERS.TXT] Update to include yours truly as the TableGen owner 2020-11-12 09:49:00 -05:00
CREDITS.TXT
LICENSE.TXT
README.txt
RELEASE_TESTERS.TXT
configure
llvm.spec.in

README.txt

The LLVM Compiler Infrastructure
================================

This directory and its subdirectories contain source code for LLVM,
a toolkit for the construction of highly optimized compilers,
optimizers, and runtime environments.

LLVM is open source software. You may freely distribute it under the terms of
the license agreement found in LICENSE.txt.

Please see the documentation provided in docs/ for further
assistance with LLVM, and in particular docs/GettingStarted.rst for getting
started with LLVM and docs/README.txt for an overview of LLVM's
documentation setup.

If you are writing a package for LLVM, see docs/Packaging.rst for our
suggestions.