1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-02-01 05:01:59 +01:00
Vedant Kumar 7bbbffcf9e [CodeExtractor] Remove stale llvm.assume calls from extracted region
During extraction, stale llvm.assume handles may be retained in the
original function. The setup is:

1) CodeExtractor unregisters assumptions in the blocks that are to be
   extracted.

2) Extraction happens. There are now two functions: f1 and f1.extracted.

3) Leftover assumptions in f1 (/not/ removed as they were not in the set of
   blocks to be extracted) now have affected-value llvm.assume handles in
   f1.extracted.

When assumptions for a value used in f1 are looked up, ValueTracking can assert
as some of the handles are in the wrong function. To fix this, simply erase the
llvm.assume calls in the extracted function.

Alternatives include flushing the assumption cache in the original function, or
walking all values used in the original function to prune stale affected-value
handles. Both seem more expensive.

Testing: check-llvm, LNT run with -mllvm -hot-cold-split enabled

rdar://58460728
2020-01-28 17:18:01 -08:00

30 lines
759 B
LLVM

; RUN: opt -passes="function(slp-vectorizer),module(hotcoldsplit),function(slp-vectorizer,print<assumptions>)" -disable-output %s 2>&1 | FileCheck %s
;
; Make sure this compiles. Check that function assumption cache is refreshed
; after extracting blocks with assume calls from the function.
; CHECK: Cached assumptions for function: fun
; CHECK-NEXT: Cached assumptions for function: fun.cold
; CHECK-NOT: icmp uge
declare void @fun2(i32) #0
define void @fun(i32 %x) {
entry:
br i1 undef, label %if.then, label %if.else
if.then:
ret void
if.else:
%cmp = icmp uge i32 %x, 64
call void @llvm.assume(i1 %cmp)
call void @fun2(i32 %x)
unreachable
}
declare void @llvm.assume(i1) #1
attributes #0 = { alwaysinline }
attributes #1 = { nounwind }