exact usage of HotColdSplit pass and impact on ll files

Hi there!

Recently I saw a presentation with title “Hot Cold Splitting Optimization Pass In LLVM” on youtube about hotcoldsplit LLVM pass .

I want to use this built-in pass to optimize my IR but I don’t know how it can optimize my code, I didn’t find any result and contacted to the developer and he advised me to use test at LLVM for testing this pass .

I tried opt.ll from llvm/test/intstrumentation/BoundsChecking and :

opt -S -hotcoldsplit opt.ll -o opt1.ll

The result is not what I expect because I used a diffing tool and see just some sorts of the following has been removed from the original source :

; CHECK: mul i64 {{.*}}, 4
; CHECK: sub i64 4000, %
; CHECK-NEXT: icmp ult i64 {{.*}}, 4
; CHECK-NEXT: or i1
; CHECK: trap

; CHECK: mul i64 {{.*}}, 8
; CHECK: mul i64 {{.*}}, 4
; CHECK: add i64
; CHECK: sub i64 16, %
; CHECK-NEXT: icmp ult i64 16, %
; CHECK-NEXT: icmp ult i64 {{.*}}, 4
; CHECK-NEXT: or i1
; CHECK: trap

Btw, I attached the source and output file as the result .

As in my own code, I do not use these " ; CHECK : " things, I see no change on my own code after using hotcoldsplit and in fact I do expect this built-in pass to have impact on the real code but I didn’t find this .

Can someone please clarify how this hotcoldsplit pass , affect the real code and how exactly does it working and how I can use this built-in pass in the proper way to optimize my code?

Thanks
Azim

opt1.ll (13.9 KB)

opt.ll (15.1 KB)