mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
39c48b9d3e
This patch implements Chandler's idea [0] for supporting languages that require support for infinite loops with side effects, such as Rust, providing part of a solution to bug 965 [1]. Specifically, it adds an `llvm.sideeffect()` intrinsic, which has no actual effect, but which appears to optimization passes to have obscure side effects, such that they don't optimize away loops containing it. It also teaches several optimization passes to ignore this intrinsic, so that it doesn't significantly impact optimization in most cases. As discussed on llvm-dev [2], this patch is the first of two major parts. The second part, to change LLVM's semantics to have defined behavior on infinite loops by default, with a function attribute for opting into potential-undefined-behavior, will be implemented and posted for review in a separate patch. [0] http://lists.llvm.org/pipermail/llvm-dev/2015-July/088103.html [1] https://bugs.llvm.org/show_bug.cgi?id=965 [2] http://lists.llvm.org/pipermail/llvm-dev/2017-October/118632.html Differential Revision: https://reviews.llvm.org/D38336 llvm-svn: 317729
57 lines
1.4 KiB
LLVM
57 lines
1.4 KiB
LLVM
; RUN: llc < %s
|
|
; RUN: llc -O0 < %s
|
|
|
|
;; SQRT
|
|
declare float @llvm.sqrt.f32(float)
|
|
|
|
declare double @llvm.sqrt.f64(double)
|
|
|
|
define double @test_sqrt(float %F) {
|
|
%G = call float @llvm.sqrt.f32( float %F ) ; <float> [#uses=1]
|
|
%H = fpext float %G to double ; <double> [#uses=1]
|
|
%I = call double @llvm.sqrt.f64( double %H ) ; <double> [#uses=1]
|
|
ret double %I
|
|
}
|
|
|
|
|
|
; SIN
|
|
declare float @sinf(float) readonly
|
|
|
|
declare double @sin(double) readonly
|
|
|
|
define double @test_sin(float %F) {
|
|
%G = call float @sinf( float %F ) ; <float> [#uses=1]
|
|
%H = fpext float %G to double ; <double> [#uses=1]
|
|
%I = call double @sin( double %H ) ; <double> [#uses=1]
|
|
ret double %I
|
|
}
|
|
|
|
|
|
; COS
|
|
declare float @cosf(float) readonly
|
|
|
|
declare double @cos(double) readonly
|
|
|
|
define double @test_cos(float %F) {
|
|
%G = call float @cosf( float %F ) ; <float> [#uses=1]
|
|
%H = fpext float %G to double ; <double> [#uses=1]
|
|
%I = call double @cos( double %H ) ; <double> [#uses=1]
|
|
ret double %I
|
|
}
|
|
|
|
declare i8* @llvm.invariant.group.barrier(i8*)
|
|
|
|
define i8* @barrier(i8* %p) {
|
|
%q = call i8* @llvm.invariant.group.barrier(i8* %p)
|
|
ret i8* %q
|
|
}
|
|
|
|
; sideeffect
|
|
|
|
declare void @llvm.sideeffect()
|
|
|
|
define void @test_sideeffect() {
|
|
call void @llvm.sideeffect()
|
|
ret void
|
|
}
|