1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00
llvm-mirror/test/Transforms/HotColdSplit/assumption-cache-invalidation.ll
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

51 lines
1.1 KiB
LLVM

; REQUIRES: asserts
; RUN: opt -S -instsimplify -hotcoldsplit -debug < %s 2>&1 | FileCheck %s
; RUN: opt -instcombine -hotcoldsplit -instsimplify %s -o /dev/null
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64"
%a = type { i64, i64 }
%b = type { i64 }
; CHECK: @f
; CHECK-LABEL: codeRepl:
; CHECK-NOT: @llvm.assume
; CHECK: }
; CHECK: declare {{.*}}@llvm.assume
; CHECK: define {{.*}}@f.cold.1(i64 %0)
; CHECK-LABEL: newFuncRoot:
; CHECK: %1 = icmp eq i64 %0, 0
; CHECK-NOT: call void @llvm.assume
define void @f() {
entry:
%0 = getelementptr inbounds %a, %a* null, i64 0, i32 1
br label %label
label:
%1 = bitcast i64* %0 to %b**
%2 = load %b*, %b** %1, align 8
%3 = getelementptr inbounds %b, %b* %2, i64 undef, i32 0
%4 = load i64, i64* %3, align 8
%5 = icmp ugt i64 %4, 1
br i1 %5, label %if.then, label %if.else
if.then:
unreachable
if.else:
call void @g(i8* undef)
%6 = load i64, i64* undef, align 8
%7 = and i64 %6, -16
%8 = inttoptr i64 %7 to i8*
%9 = icmp eq i64 %4, 0
call void @llvm.assume(i1 %9)
unreachable
}
declare void @g(i8*)
declare void @llvm.assume(i1)