[Lldb-commits] [clang] [libcxx] [lldb] [llvm] [mlir] [BOLT][BAT] Add entries for deleted basic blocks (PR #91906)

2024-05-24 Thread Rafael Auler via lldb-commits

rafaelauler wrote:

Oh I see, thanks!

https://github.com/llvm/llvm-project/pull/91906
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [libcxx] [lldb] [llvm] [mlir] [BOLT][BAT] Add entries for deleted basic blocks (PR #91906)

2024-05-24 Thread Amir Ayupov via lldb-commits

aaupov wrote:

The entries for deleted basic blocks won't participate in 
`BAT::getFallthroughsInTrace` because trace boundary is looked up by output 
offsets: 
https://github.com/llvm/llvm-project/blob/098c6dfa8157681699a71fce9e3d94515e66311f/bolt/lib/Profile/BoltAddressTranslation.cpp#L529-L540

But deleted blocks will be used in `writeBATYAML` where we lookup containing 
blocks by input offsets: 
https://github.com/llvm/llvm-project/blob/098c6dfa8157681699a71fce9e3d94515e66311f/bolt/lib/Profile/DataAggregator.cpp#L2358-L2367

https://github.com/llvm/llvm-project/pull/91906
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [libcxx] [lldb] [llvm] [mlir] [BOLT][BAT] Add entries for deleted basic blocks (PR #91906)

2024-05-24 Thread Rafael Auler via lldb-commits

rafaelauler wrote:

Thanks for the detailed explanation.

So essentially the output offset is not important because these deleted blocks 
are only useful for their input offset, which will be used in 
BoltAddressTranslation::getFallthroughsInTrace() to create traffic in this 
to-be deleted block, is that right?

https://github.com/llvm/llvm-project/pull/91906
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [libcxx] [lldb] [llvm] [mlir] [BOLT][BAT] Add entries for deleted basic blocks (PR #91906)

2024-05-23 Thread Amir Ayupov via lldb-commits

https://github.com/aaupov closed https://github.com/llvm/llvm-project/pull/91906
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [libcxx] [lldb] [llvm] [mlir] [BOLT][BAT] Add entries for deleted basic blocks (PR #91906)

2024-05-23 Thread Amir Ayupov via lldb-commits

aaupov wrote:

> Could you elaborate a bit better on why do we need a deleted block to be 
> present in the table? My memory fails me, aren't we using the translation 
> table just to map samples collected on the bolted binary? Where do the 
> deleted blocks become a problem?
> 
> Other than the motivation, the implementation itself looks good to me.

We need deleted blocks to correctly map optimized tail calls to containing 
basic blocks. Because we expand tail calls during CFG construction, and attach 
the profile to that CFG, we need those intermediate blocks to be present in the 
profile. bb

-with-two-tail-calls offers a good example:
after building CFG (details omitted):
```
.LBB00 (1 instructions, align : 1)
:   je  .Ltmp0 # Offset: 0

.LFT0 (2 instructions, align : 1)
0002:   ja  .Ltmp1 # Offset: 2
0004:   jmp .Ltmp2 # Offset: 4

.Ltmp0 (1 instructions, align : 1)
0006:   retq # Offset: 6

.Ltmp1 (1 instructions, align : 1)
0007:   jmp e # TAILCALL  # Offset: 7

.Ltmp2 (2 instructions, align : 1)
000c:   nop # Offset: 12 # Size: 1 # NOP: 1
000d:   jmp f # TAILCALL  # Offset: 13
```

after SCTC, we normally write out BAT from that state:
```
.LBB00 (1 instructions, align : 1)
:   je  .Ltmp0 # Offset: 0

.LFT0 (2 instructions, align : 1)
0002:   ja  e # TAILCALL  # Offset: 7 # CTCTakenCount: 4
0004:   jmp f # TAILCALL  # Offset: 13

.Ltmp0 (1 instructions, align : 1)
0009:   retq # Offset: 6
```

So in order to map this branch
```
0004:   jmp f # TAILCALL  # Offset: 13
```

to its block Ltmp2 we need to preserve the block entry in BAT, although it's 
removed from CFG.

https://github.com/llvm/llvm-project/pull/91906
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [libcxx] [lldb] [llvm] [mlir] [BOLT][BAT] Add entries for deleted basic blocks (PR #91906)

2024-05-21 Thread Rafael Auler via lldb-commits

https://github.com/rafaelauler approved this pull request.

Could you elaborate a bit better on why do we need a deleted block to be 
present in the table? My memory fails me, aren't we using the translation table 
just to map samples collected on the bolted binary? Where do the deleted blocks 
become a problem?

Other than the motivation, the implementation itself looks good to me.

https://github.com/llvm/llvm-project/pull/91906
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [libcxx] [lldb] [llvm] [mlir] [BOLT][BAT] Add entries for deleted basic blocks (PR #91906)

2024-05-16 Thread Amir Ayupov via lldb-commits

https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/91906
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits