mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-26 21:32:10 +00:00
3d03d60ca8
This adds a set of utility functions for collecting 'ephemeral' values. These are LLVM IR values that are used only by @llvm.assume intrinsics (directly or indirectly), and thus will be removed prior to code generation, implying that they should be considered free for certain purposes (like inlining). The inliner's cost analysis, and a few other passes, have been updated to account for ephemeral values using the provided functionality. This functionality is important for the usability of @llvm.assume, because it limits the "non-local" side-effects of adding llvm.assume on inlining, loop unrolling, etc. (these are hints, and do not generate code, so they should not directly contribute to estimates of execution cost). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217335 91177308-0d34-0410-b5e6-96231b3b80d8
33 lines
720 B
LLVM
33 lines
720 B
LLVM
; RUN: opt -S -Oz %s | FileCheck %s
|
|
|
|
@a = global i32 4
|
|
|
|
define i1 @inner() {
|
|
%a1 = load volatile i32* @a
|
|
%x1 = add i32 %a1, %a1
|
|
%c = icmp eq i32 %x1, 0
|
|
|
|
; Here are enough instructions to prevent inlining, but because they are used
|
|
; only by the @llvm.assume intrinsic, they're free (and, thus, inlining will
|
|
; still happen).
|
|
%a2 = mul i32 %a1, %a1
|
|
%a3 = sub i32 %a1, 5
|
|
%a4 = udiv i32 %a3, -13
|
|
%a5 = mul i32 %a4, %a4
|
|
%a6 = add i32 %a5, %x1
|
|
%ca = icmp sgt i32 %a6, -7
|
|
tail call void @llvm.assume(i1 %ca)
|
|
|
|
ret i1 %c
|
|
}
|
|
|
|
; @inner() should be inlined for -Oz.
|
|
; CHECK-NOT: call i1 @inner
|
|
define i1 @outer() optsize {
|
|
%r = call i1 @inner()
|
|
ret i1 %r
|
|
}
|
|
|
|
declare void @llvm.assume(i1) nounwind
|
|
|