You've already forked linux-packaging-mono
Imported Upstream version 5.18.0.205
Former-commit-id: 7f59f7e792705db773f1caecdaa823092f4e2927
This commit is contained in:
parent
5cd5df71cc
commit
8e12397d70
20
external/llvm/test/Analysis/GlobalsModRef/2008-09-03-ReadGlobals.ll
vendored
Normal file
20
external/llvm/test/Analysis/GlobalsModRef/2008-09-03-ReadGlobals.ll
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
; RUN: opt < %s -globals-aa -gvn -S | FileCheck %s
|
||||
|
||||
@g = internal global i32 0 ; <i32*> [#uses=2]
|
||||
|
||||
define i32 @r() {
|
||||
%tmp = load i32, i32* @g ; <i32> [#uses=1]
|
||||
ret i32 %tmp
|
||||
}
|
||||
|
||||
define i32 @f() {
|
||||
; CHECK: call i32 @e()
|
||||
; CHECK: call i32 @e()
|
||||
entry:
|
||||
%tmp = call i32 @e( ) ; <i32> [#uses=1]
|
||||
store i32 %tmp, i32* @g
|
||||
%tmp2 = call i32 @e( ) ; <i32> [#uses=1]
|
||||
ret i32 %tmp2
|
||||
}
|
||||
|
||||
declare i32 @e() readonly ; might call @r
|
18
external/llvm/test/Analysis/GlobalsModRef/aliastest.ll
vendored
Normal file
18
external/llvm/test/Analysis/GlobalsModRef/aliastest.ll
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
; RUN: opt < %s -basicaa -globals-aa -gvn -S -enable-unsafe-globalsmodref-alias-results | FileCheck %s
|
||||
; RUN: opt < %s -aa-pipeline=basic-aa,globals-aa -passes="require<globals-aa>,function(gvn)" -S -enable-unsafe-globalsmodref-alias-results | FileCheck %s
|
||||
;
|
||||
; Note that this test relies on an unsafe feature of GlobalsModRef. While this
|
||||
; test is correct and safe, GMR's technique for handling this isn't generally.
|
||||
|
||||
@X = internal global i32 4 ; <i32*> [#uses=1]
|
||||
|
||||
define i32 @test(i32* %P) {
|
||||
; CHECK: @test
|
||||
; CHECK-NEXT: store i32 7, i32* %P
|
||||
; CHECK-NEXT: store i32 12, i32* @X
|
||||
; CHECK-NEXT: ret i32 7
|
||||
store i32 7, i32* %P
|
||||
store i32 12, i32* @X
|
||||
%V = load i32, i32* %P ; <i32> [#uses=1]
|
||||
ret i32 %V
|
||||
}
|
37
external/llvm/test/Analysis/GlobalsModRef/atomic-instrs.ll
vendored
Normal file
37
external/llvm/test/Analysis/GlobalsModRef/atomic-instrs.ll
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
; RUN: opt < %s -globals-aa -gvn -S | FileCheck %s
|
||||
|
||||
@X = internal global i32 4
|
||||
|
||||
define i32 @test_cmpxchg(i32* %P) {
|
||||
; CHECK-LABEL: @test_cmpxchg
|
||||
; CHECK-NEXT: store i32 12, i32* @X
|
||||
; CHECK-NEXT: call void @modrefX_cmpxchg()
|
||||
; CHECK-NEXT: %V = load i32, i32* @X
|
||||
; CHECK-NEXT: ret i32 %V
|
||||
store i32 12, i32* @X
|
||||
call void @modrefX_cmpxchg()
|
||||
%V = load i32, i32* @X
|
||||
ret i32 %V
|
||||
}
|
||||
|
||||
define void @modrefX_cmpxchg() {
|
||||
%1 = cmpxchg i32* @X, i32 0, i32 -1 monotonic monotonic
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @test_atomicrmw(i32* %P) {
|
||||
; CHECK-LABEL: @test_atomicrmw
|
||||
; CHECK-NEXT: store i32 12, i32* @X
|
||||
; CHECK-NEXT: call void @modrefXatomicrmw()
|
||||
; CHECK-NEXT: %V = load i32, i32* @X
|
||||
; CHECK-NEXT: ret i32 %V
|
||||
store i32 12, i32* @X
|
||||
call void @modrefXatomicrmw()
|
||||
%V = load i32, i32* @X
|
||||
ret i32 %V
|
||||
}
|
||||
|
||||
define void @modrefXatomicrmw() {
|
||||
%1 = atomicrmw add i32* @X, i32 1 acquire
|
||||
ret void
|
||||
}
|
24
external/llvm/test/Analysis/GlobalsModRef/chaining-analysis.ll
vendored
Normal file
24
external/llvm/test/Analysis/GlobalsModRef/chaining-analysis.ll
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
; RUN: opt < %s -basicaa -globals-aa -gvn -S | FileCheck %s
|
||||
|
||||
; This test requires the use of previous analyses to determine that
|
||||
; doesnotmodX does not modify X (because 'sin' doesn't).
|
||||
|
||||
@X = internal global i32 4 ; <i32*> [#uses=2]
|
||||
|
||||
declare double @sin(double) readnone
|
||||
|
||||
define i32 @test(i32* %P) {
|
||||
; CHECK: @test
|
||||
; CHECK-NEXT: store i32 12, i32* @X
|
||||
; CHECK-NEXT: call double @doesnotmodX(double 1.000000e+00)
|
||||
; CHECK-NEXT: ret i32 12
|
||||
store i32 12, i32* @X
|
||||
call double @doesnotmodX( double 1.000000e+00 ) ; <double>:1 [#uses=0]
|
||||
%V = load i32, i32* @X ; <i32> [#uses=1]
|
||||
ret i32 %V
|
||||
}
|
||||
|
||||
define double @doesnotmodX(double %V) {
|
||||
%V2 = call double @sin( double %V ) readnone ; <double> [#uses=1]
|
||||
ret double %V2
|
||||
}
|
21
external/llvm/test/Analysis/GlobalsModRef/comdat-ipo.ll
vendored
Normal file
21
external/llvm/test/Analysis/GlobalsModRef/comdat-ipo.ll
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
; RUN: opt < %s -basicaa -globals-aa -gvn -S | FileCheck %s
|
||||
|
||||
; See PR26774
|
||||
|
||||
@X = internal global i32 4
|
||||
|
||||
define i32 @test(i32* %P) {
|
||||
; CHECK: @test
|
||||
; CHECK-NEXT: store i32 12, i32* @X
|
||||
; CHECK-NEXT: call void @doesnotmodX()
|
||||
; CHECK-NEXT: %V = load i32, i32* @X
|
||||
; CHECK-NEXT: ret i32 %V
|
||||
store i32 12, i32* @X
|
||||
call void @doesnotmodX( )
|
||||
%V = load i32, i32* @X
|
||||
ret i32 %V
|
||||
}
|
||||
|
||||
define linkonce_odr void @doesnotmodX() {
|
||||
ret void
|
||||
}
|
54
external/llvm/test/Analysis/GlobalsModRef/dead-uses.ll
vendored
Normal file
54
external/llvm/test/Analysis/GlobalsModRef/dead-uses.ll
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
; RUN: opt < %s -instcombine -globals-aa -licm -S | FileCheck %s
|
||||
|
||||
; Make sure -globals-aa ignores dead uses of globals.
|
||||
|
||||
@a = internal global i32 0, align 4
|
||||
@c = common global i32 0, align 4
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define i32 @g() {
|
||||
; Make sure the load of @a is hoisted.
|
||||
; CHECK-LABEL: define i32 @g()
|
||||
; CHECK: entry:
|
||||
; CHECK-NEXT: load i32, i32* @a, align 4
|
||||
; CHECK-NEXT: br label %for.cond
|
||||
entry:
|
||||
br label %for.cond
|
||||
|
||||
for.cond: ; preds = %for.inc, %entry
|
||||
%i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
|
||||
%sum.0 = phi i32 [ 0, %entry ], [ %add, %for.inc ]
|
||||
%cmp = icmp slt i32 %i.0, 1000
|
||||
br i1 %cmp, label %for.body, label %for.end
|
||||
|
||||
for.body: ; preds = %for.cond
|
||||
%0 = load i32, i32* @a, align 4
|
||||
%add = add nsw i32 %sum.0, %0
|
||||
call void @f()
|
||||
br label %for.inc
|
||||
|
||||
for.inc: ; preds = %for.body
|
||||
%inc = add nsw i32 %i.0, 1
|
||||
br label %for.cond
|
||||
|
||||
for.end: ; preds = %for.cond
|
||||
ret i32 %sum.0
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define internal void @f() {
|
||||
entry:
|
||||
%tobool = icmp ne i32 0, 0
|
||||
br i1 %tobool, label %if.then, label %if.end
|
||||
|
||||
if.then: ; preds = %entry
|
||||
store i32 ptrtoint (i32* @a to i32), i32* @c, align 4
|
||||
br label %if.end
|
||||
|
||||
if.end: ; preds = %if.then, %entry
|
||||
%0 = load i32, i32* @c, align 4
|
||||
%inc = add nsw i32 %0, 1
|
||||
store i32 %inc, i32* @c, align 4
|
||||
ret void
|
||||
}
|
||||
|
31
external/llvm/test/Analysis/GlobalsModRef/func-memattributes.ll
vendored
Normal file
31
external/llvm/test/Analysis/GlobalsModRef/func-memattributes.ll
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
; RUN: opt < %s -disable-basicaa -globals-aa -dse -S | FileCheck %s
|
||||
|
||||
@X = internal global i32 4
|
||||
|
||||
define i32 @test0() {
|
||||
; CHECK-LABEL: @test0
|
||||
; CHECK: store i32 0, i32* @X
|
||||
; CHECK-NEXT: call i32 @func_readonly() #0
|
||||
; CHECK-NEXT: store i32 1, i32* @X
|
||||
store i32 0, i32* @X
|
||||
%x = call i32 @func_readonly() #0
|
||||
store i32 1, i32* @X
|
||||
ret i32 %x
|
||||
}
|
||||
|
||||
define i32 @test1() {
|
||||
; CHECK-LABEL: @test1
|
||||
; CHECK-NOT: store
|
||||
; CHECK: call i32 @func_read_argmem_only() #1
|
||||
; CHECK-NEXT: store i32 3, i32* @X
|
||||
store i32 2, i32* @X
|
||||
%x = call i32 @func_read_argmem_only() #1
|
||||
store i32 3, i32* @X
|
||||
ret i32 %x
|
||||
}
|
||||
|
||||
declare i32 @func_readonly() #0
|
||||
declare i32 @func_read_argmem_only() #1
|
||||
|
||||
attributes #0 = { readonly nounwind }
|
||||
attributes #1 = { readonly argmemonly nounwind }
|
54
external/llvm/test/Analysis/GlobalsModRef/global-used-by-global.ll
vendored
Normal file
54
external/llvm/test/Analysis/GlobalsModRef/global-used-by-global.ll
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
; RUN: opt < %s -globals-aa -gvn -S | FileCheck %s
|
||||
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
|
||||
@a = internal global i32* null, align 8
|
||||
@b = global i32** @a, align 8
|
||||
@c = global i32** @a, align 8
|
||||
@d = common global i32 0, align 4
|
||||
|
||||
; Make sure we globals-aa doesn't get confused and allow hoisting
|
||||
; the load from @a out of the loop.
|
||||
|
||||
; CHECK-LABEL: define i32 @main()
|
||||
; CHECK: for.body:
|
||||
; CHECK-NEXT: %2 = load i32**, i32*** @b, align 8
|
||||
; CHECK-NEXT: store i32* @d, i32** %2, align 8
|
||||
; CHECK-NEXT: %3 = load i32*, i32** @a, align 8
|
||||
; CHECK-NEXT: %cmp1 = icmp ne i32* %3, @d
|
||||
; CHECK-NEXT: br i1 %cmp1, label %if.then, label %if.end
|
||||
|
||||
define i32 @main() {
|
||||
entry:
|
||||
%0 = load i32, i32* @d, align 4
|
||||
br label %for.cond
|
||||
|
||||
for.cond: ; preds = %if.end, %entry
|
||||
%1 = phi i32 [ %inc, %if.end ], [ %0, %entry ]
|
||||
%cmp = icmp slt i32 %1, 1
|
||||
br i1 %cmp, label %for.body, label %for.end
|
||||
|
||||
for.body: ; preds = %for.cond
|
||||
%2 = load i32**, i32*** @b, align 8
|
||||
store i32* @d, i32** %2, align 8
|
||||
%3 = load i32*, i32** @a, align 8
|
||||
%cmp1 = icmp ne i32* %3, @d
|
||||
br i1 %cmp1, label %if.then, label %if.end
|
||||
|
||||
if.then: ; preds = %for.body
|
||||
br label %return
|
||||
|
||||
if.end: ; preds = %for.body
|
||||
%4 = load i32, i32* @d, align 4
|
||||
%inc = add nsw i32 %4, 1
|
||||
store i32 %inc, i32* @d, align 4
|
||||
br label %for.cond
|
||||
|
||||
for.end: ; preds = %for.cond
|
||||
br label %return
|
||||
|
||||
return: ; preds = %for.end, %if.then
|
||||
%retval.0 = phi i32 [ 1, %if.then ], [ 0, %for.end ]
|
||||
ret i32 %retval.0
|
||||
}
|
||||
|
21
external/llvm/test/Analysis/GlobalsModRef/inaccessiblememonly.ll
vendored
Normal file
21
external/llvm/test/Analysis/GlobalsModRef/inaccessiblememonly.ll
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
; RUN: opt -O3 -S < %s | FileCheck %s
|
||||
|
||||
target datalayout = "e-i64:64-f80:128-n8:16:32:64"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
define void @donteliminate() {
|
||||
; CHECK-LABEL: donteliminate
|
||||
; CHECK-NEXT: tail call noalias i8* @allocmemory()
|
||||
; CHECK-NEXT: tail call noalias i8* @allocmemory()
|
||||
; CHECK-NEXT: tail call noalias i8* @allocmemory()
|
||||
; CHECK-NEXT: ret void
|
||||
%1 = tail call noalias i8* @allocmemory()
|
||||
%2 = tail call noalias i8* @allocmemory()
|
||||
%3 = tail call noalias i8* @allocmemory()
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: inaccessiblememonly
|
||||
declare noalias i8* @allocmemory() #0
|
||||
|
||||
attributes #0 = { inaccessiblememonly }
|
26
external/llvm/test/Analysis/GlobalsModRef/indirect-global.ll
vendored
Normal file
26
external/llvm/test/Analysis/GlobalsModRef/indirect-global.ll
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
; RUN: opt < %s -basicaa -globals-aa -gvn -instcombine -S -enable-unsafe-globalsmodref-alias-results | FileCheck %s
|
||||
; RUN: opt < %s -aa-pipeline=basic-aa,globals-aa -passes="require<globals-aa>,function(gvn,instcombine)" -S -enable-unsafe-globalsmodref-alias-results | FileCheck %s
|
||||
;
|
||||
; Note that this test relies on an unsafe feature of GlobalsModRef. While this
|
||||
; test is correct and safe, GMR's technique for handling this isn't generally.
|
||||
|
||||
@G = internal global i32* null ; <i32**> [#uses=3]
|
||||
|
||||
declare i8* @malloc(i32)
|
||||
define void @test() {
|
||||
%a = call i8* @malloc(i32 4)
|
||||
%A = bitcast i8* %a to i32*
|
||||
store i32* %A, i32** @G
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @test1(i32* %P) {
|
||||
; CHECK: ret i32 0
|
||||
%g1 = load i32*, i32** @G ; <i32*> [#uses=2]
|
||||
%h1 = load i32, i32* %g1 ; <i32> [#uses=1]
|
||||
store i32 123, i32* %P
|
||||
%g2 = load i32*, i32** @G ; <i32*> [#uses=0]
|
||||
%h2 = load i32, i32* %g1 ; <i32> [#uses=1]
|
||||
%X = sub i32 %h1, %h2 ; <i32> [#uses=1]
|
||||
ret i32 %X
|
||||
}
|
65
external/llvm/test/Analysis/GlobalsModRef/memset-escape.ll
vendored
Normal file
65
external/llvm/test/Analysis/GlobalsModRef/memset-escape.ll
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
; RUN: opt < %s -O1 -S | FileCheck %s
|
||||
|
||||
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-apple-macosx10.10.0"
|
||||
|
||||
@a = internal global [3 x i32] zeroinitializer, align 4
|
||||
@b = common global i32 0, align 4
|
||||
|
||||
; The important thing we're checking for here is the reload of (some element of)
|
||||
; @a after the memset.
|
||||
|
||||
; CHECK-LABEL: @main
|
||||
; CHECK: call void @llvm.memset.p0i8.i64{{.*}} @a
|
||||
; CHECK: store i32 3
|
||||
; CHECK: load i32, i32* getelementptr {{.*}} @a
|
||||
; CHECK: icmp eq i32
|
||||
; CHECK: br i1
|
||||
|
||||
define i32 @main() {
|
||||
entry:
|
||||
%retval = alloca i32, align 4
|
||||
%c = alloca [1 x i32], align 4
|
||||
store i32 0, i32* %retval, align 4
|
||||
%0 = bitcast [1 x i32]* %c to i8*
|
||||
call void @llvm.memset.p0i8.i64(i8* %0, i8 0, i64 4, i32 4, i1 false)
|
||||
store i32 1, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @a, i64 0, i64 2), align 4
|
||||
store i32 0, i32* @b, align 4
|
||||
br label %for.cond
|
||||
|
||||
for.cond: ; preds = %for.inc, %entry
|
||||
%1 = load i32, i32* @b, align 4
|
||||
%cmp = icmp slt i32 %1, 3
|
||||
br i1 %cmp, label %for.body, label %for.end
|
||||
|
||||
for.body: ; preds = %for.cond
|
||||
%2 = load i32, i32* @b, align 4
|
||||
%idxprom = sext i32 %2 to i64
|
||||
%arrayidx = getelementptr inbounds [3 x i32], [3 x i32]* @a, i64 0, i64 %idxprom
|
||||
store i32 0, i32* %arrayidx, align 4
|
||||
br label %for.inc
|
||||
|
||||
for.inc: ; preds = %for.body
|
||||
%3 = load i32, i32* @b, align 4
|
||||
%inc = add nsw i32 %3, 1
|
||||
store i32 %inc, i32* @b, align 4
|
||||
br label %for.cond
|
||||
|
||||
for.end: ; preds = %for.cond
|
||||
%4 = load i32, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @a, i64 0, i64 2), align 4
|
||||
%cmp1 = icmp ne i32 %4, 0
|
||||
br i1 %cmp1, label %if.then, label %if.end
|
||||
|
||||
if.then: ; preds = %for.end
|
||||
call void @abort() #3
|
||||
unreachable
|
||||
|
||||
if.end: ; preds = %for.end
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind argmemonly
|
||||
declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) nounwind argmemonly
|
||||
|
||||
; Function Attrs: noreturn nounwind
|
||||
declare void @abort() noreturn nounwind
|
18
external/llvm/test/Analysis/GlobalsModRef/modreftest.ll
vendored
Normal file
18
external/llvm/test/Analysis/GlobalsModRef/modreftest.ll
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
; RUN: opt < %s -basicaa -globals-aa -gvn -S | FileCheck %s
|
||||
|
||||
@X = internal global i32 4 ; <i32*> [#uses=2]
|
||||
|
||||
define i32 @test(i32* %P) {
|
||||
; CHECK: @test
|
||||
; CHECK-NEXT: store i32 12, i32* @X
|
||||
; CHECK-NEXT: call void @doesnotmodX()
|
||||
; CHECK-NEXT: ret i32 12
|
||||
store i32 12, i32* @X
|
||||
call void @doesnotmodX( )
|
||||
%V = load i32, i32* @X ; <i32> [#uses=1]
|
||||
ret i32 %V
|
||||
}
|
||||
|
||||
define void @doesnotmodX() {
|
||||
ret void
|
||||
}
|
65
external/llvm/test/Analysis/GlobalsModRef/no-escape.ll
vendored
Normal file
65
external/llvm/test/Analysis/GlobalsModRef/no-escape.ll
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
; RUN: opt < %s -basicaa -globals-aa -S -licm | FileCheck %s
|
||||
|
||||
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-apple-macosx10.10.0"
|
||||
|
||||
@b = common global i32 0, align 4
|
||||
@c = internal global i32 0, align 4
|
||||
@d = common global i32 0, align 4
|
||||
@e = common global i32* null, align 4
|
||||
|
||||
define void @foo(i32* %P) noinline {
|
||||
; CHECK: define void @foo
|
||||
%loadp = load i32, i32* %P, align 4
|
||||
store i32 %loadp, i32* @d, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @bar() noinline {
|
||||
; CHECK: define void @bar
|
||||
%loadp = load i32, i32* @d, align 4
|
||||
store i32 %loadp, i32* @c, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main() {
|
||||
entry:
|
||||
%retval = alloca i32, align 4
|
||||
%c = alloca [1 x i32], align 4
|
||||
store i32 0, i32* %retval, align 4
|
||||
call void @bar()
|
||||
store i32 0, i32* @b, align 4
|
||||
br label %for.cond
|
||||
;; Check that @c is LICM'ed out.
|
||||
; CHECK: load i32, i32* @c
|
||||
for.cond: ; preds = %for.inc, %entry
|
||||
; CHECK-LABEL: for.cond:
|
||||
; CHECK: load i32, i32* @b
|
||||
%a1 = load i32, i32* @b, align 4
|
||||
%aa2 = load i32, i32* @c, align 4
|
||||
%add = add nsw i32 %a1, %aa2
|
||||
%p1 = load i32*, i32** @e, align 4
|
||||
call void @foo(i32* %p1)
|
||||
%cmp = icmp slt i32 %add, 3
|
||||
br i1 %cmp, label %for.body, label %for.end
|
||||
|
||||
for.body: ; preds = %for.cond
|
||||
%a2 = load i32, i32* @b, align 4
|
||||
%idxprom = sext i32 %a2 to i64
|
||||
br label %for.inc
|
||||
|
||||
for.inc: ; preds = %for.body
|
||||
%a3 = load i32, i32* @b, align 4
|
||||
%inc = add nsw i32 %a3, 1
|
||||
store i32 %inc, i32* @b, align 4
|
||||
br label %for.cond
|
||||
|
||||
for.end: ; preds = %for.cond
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind argmemonly
|
||||
declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) nounwind argmemonly
|
||||
|
||||
; Function Attrs: noreturn nounwind
|
||||
declare void @abort() noreturn nounwind
|
116
external/llvm/test/Analysis/GlobalsModRef/nonescaping-noalias.ll
vendored
Normal file
116
external/llvm/test/Analysis/GlobalsModRef/nonescaping-noalias.ll
vendored
Normal file
@ -0,0 +1,116 @@
|
||||
; RUN: opt < %s -globals-aa -gvn -S | FileCheck %s
|
||||
;
|
||||
; This tests the safe no-alias conclusions of GMR -- when there is
|
||||
; a non-escaping global as one indentified underlying object and some pointer
|
||||
; that would inherently have escaped any other function as the other underlying
|
||||
; pointer of an alias query.
|
||||
|
||||
@g1 = internal global i32 0
|
||||
|
||||
define i32 @test1(i32* %param) {
|
||||
; Ensure that we can fold a store to a load of a global across a store to
|
||||
; a parameter when the global is non-escaping.
|
||||
;
|
||||
; CHECK-LABEL: @test1(
|
||||
; CHECK: store i32 42, i32* @g1
|
||||
; CHECK-NOT: load i32
|
||||
; CHECK: ret i32 42
|
||||
entry:
|
||||
store i32 42, i32* @g1
|
||||
store i32 7, i32* %param
|
||||
%v = load i32, i32* @g1
|
||||
ret i32 %v
|
||||
}
|
||||
|
||||
declare i32* @f()
|
||||
|
||||
define i32 @test2() {
|
||||
; Ensure that we can fold a store to a load of a global across a store to
|
||||
; the pointer returned by a function call. Since the global could not escape,
|
||||
; this function cannot be returning its address.
|
||||
;
|
||||
; CHECK-LABEL: @test2(
|
||||
; CHECK: store i32 42, i32* @g1
|
||||
; CHECK-NOT: load i32
|
||||
; CHECK: ret i32 42
|
||||
entry:
|
||||
%ptr = call i32* @f() readnone
|
||||
store i32 42, i32* @g1
|
||||
store i32 7, i32* %ptr
|
||||
%v = load i32, i32* @g1
|
||||
ret i32 %v
|
||||
}
|
||||
|
||||
@g2 = external global i32*
|
||||
|
||||
define i32 @test3() {
|
||||
; Ensure that we can fold a store to a load of a global across a store to
|
||||
; the pointer loaded from that global. Because the global does not escape, it
|
||||
; cannot alias a pointer loaded out of a global.
|
||||
;
|
||||
; CHECK-LABEL: @test3(
|
||||
; CHECK: store i32 42, i32* @g1
|
||||
; CHECK: store i32 7, i32*
|
||||
; CHECK-NOT: load i32
|
||||
; CHECK: ret i32 42
|
||||
entry:
|
||||
store i32 42, i32* @g1
|
||||
%ptr1 = load i32*, i32** @g2
|
||||
store i32 7, i32* %ptr1
|
||||
%v = load i32, i32* @g1
|
||||
ret i32 %v
|
||||
}
|
||||
|
||||
@g3 = internal global i32 1
|
||||
@g4 = internal global [10 x i32*] zeroinitializer
|
||||
|
||||
define i32 @test4(i32* %param, i32 %n, i1 %c1, i1 %c2, i1 %c3) {
|
||||
; Ensure that we can fold a store to a load of a global across a store to
|
||||
; the pointer loaded from that global even when the load is behind PHIs and
|
||||
; selects, and there is a mixture of a load and another global or argument.
|
||||
; Note that we can't eliminate the load here because it is used in a PHI and
|
||||
; GVN doesn't try to do real DCE. The store is still forwarded by GVN though.
|
||||
;
|
||||
; CHECK-LABEL: @test4(
|
||||
; CHECK: store i32 42, i32* @g1
|
||||
; CHECK: store i32 7, i32*
|
||||
; CHECK: ret i32 42
|
||||
entry:
|
||||
%call = call i32* @f()
|
||||
store i32 42, i32* @g1
|
||||
%ptr1 = load i32*, i32** @g2
|
||||
%ptr2 = select i1 %c1, i32* %ptr1, i32* %param
|
||||
%ptr3 = select i1 %c3, i32* %ptr2, i32* @g3
|
||||
br label %loop
|
||||
|
||||
loop:
|
||||
%iv = phi i32 [ 0, %entry ], [ %inc, %loop ]
|
||||
%ptr = phi i32* [ %ptr3, %entry ], [ %ptr5, %loop ]
|
||||
store i32 7, i32* %ptr
|
||||
%ptr4 = load i32*, i32** getelementptr ([10 x i32*], [10 x i32*]* @g4, i32 0, i32 1)
|
||||
%ptr5 = select i1 %c2, i32* %ptr4, i32* %call
|
||||
%inc = add i32 %iv, 1
|
||||
%test = icmp slt i32 %inc, %n
|
||||
br i1 %test, label %loop, label %exit
|
||||
|
||||
exit:
|
||||
%v = load i32, i32* @g1
|
||||
ret i32 %v
|
||||
}
|
||||
|
||||
define i32 @test5(i32** %param) {
|
||||
; Ensure that we can fold a store to a load of a global across a store to
|
||||
; a parameter that has been dereferenced when the global is non-escaping.
|
||||
;
|
||||
; CHECK-LABEL: @test5(
|
||||
; CHECK: %p = load i32*
|
||||
; CHECK: store i32 42, i32* @g1
|
||||
; CHECK-NOT: load i32
|
||||
; CHECK: ret i32 42
|
||||
entry:
|
||||
%p = load i32*, i32** %param
|
||||
store i32 42, i32* @g1
|
||||
store i32 7, i32* %p
|
||||
%v = load i32, i32* @g1
|
||||
ret i32 %v
|
||||
}
|
33
external/llvm/test/Analysis/GlobalsModRef/pr12351.ll
vendored
Normal file
33
external/llvm/test/Analysis/GlobalsModRef/pr12351.ll
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
; RUN: opt < %s -basicaa -globals-aa -gvn -S -disable-verify | FileCheck %s
|
||||
|
||||
declare void @llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1)
|
||||
define void @foo(i8* %x, i8* %y) {
|
||||
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %x, i8* %y, i32 1, i32 1, i1 false);
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @bar(i8* %y, i8* %z) {
|
||||
%x = alloca i8
|
||||
call void @foo(i8* %x, i8* %y)
|
||||
%t = load i8, i8* %x
|
||||
store i8 %t, i8* %y
|
||||
; CHECK: store i8 %t, i8* %y
|
||||
ret void
|
||||
}
|
||||
|
||||
|
||||
define i32 @foo2() {
|
||||
%foo = alloca i32
|
||||
call void @bar2(i32* %foo)
|
||||
%t0 = load i32, i32* %foo, align 4
|
||||
; CHECK: %t0 = load i32, i32* %foo, align 4
|
||||
ret i32 %t0
|
||||
}
|
||||
|
||||
define void @bar2(i32* %foo) {
|
||||
store i32 0, i32* %foo, align 4
|
||||
tail call void @llvm.dbg.value(metadata !{}, i64 0, metadata !{}, metadata !{})
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
|
27
external/llvm/test/Analysis/GlobalsModRef/pr25309.ll
vendored
Normal file
27
external/llvm/test/Analysis/GlobalsModRef/pr25309.ll
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
; RUN: opt -globals-aa -gvn < %s -S | FileCheck %s
|
||||
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
; @o and @m are initialized to @i, so they should not be classed as
|
||||
; indirect globals referring only to allocation functions.
|
||||
@o = internal global i32* @i, align 8
|
||||
@m = internal global i32* @i, align 8
|
||||
@i = internal global i32 0, align 4
|
||||
|
||||
; CHECK-LABEL: @f
|
||||
define i1 @f() {
|
||||
entry:
|
||||
%0 = load i32*, i32** @o, align 8
|
||||
store i32 0, i32* %0, align 4
|
||||
%1 = load volatile i32*, i32** @m, align 8
|
||||
store i32 1, i32* %1, align 4
|
||||
; CHECK: %[[a:.*]] = load i32*
|
||||
%2 = load i32*, i32** @o, align 8
|
||||
; CHECK: %[[b:.*]] = load i32, i32* %[[a]]
|
||||
%3 = load i32, i32* %2, align 4
|
||||
; CHECK: %[[c:.*]] = icmp ne i32 %[[b]], 0
|
||||
%tobool.i = icmp ne i32 %3, 0
|
||||
; CHECK: ret i1 %[[c]]
|
||||
ret i1 %tobool.i
|
||||
}
|
27
external/llvm/test/Analysis/GlobalsModRef/purecse.ll
vendored
Normal file
27
external/llvm/test/Analysis/GlobalsModRef/purecse.ll
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
; Test that pure functions are cse'd away
|
||||
; RUN: opt < %s -disable-basicaa -globals-aa -gvn -instcombine -S | FileCheck %s
|
||||
|
||||
define i32 @pure(i32 %X) {
|
||||
%Y = add i32 %X, 1 ; <i32> [#uses=1]
|
||||
ret i32 %Y
|
||||
}
|
||||
|
||||
define i32 @test1(i32 %X) {
|
||||
; CHECK: %A = call i32 @pure(i32 %X)
|
||||
; CHECK-NEXT: ret i32 0
|
||||
%A = call i32 @pure( i32 %X ) ; <i32> [#uses=1]
|
||||
%B = call i32 @pure( i32 %X ) ; <i32> [#uses=1]
|
||||
%C = sub i32 %A, %B ; <i32> [#uses=1]
|
||||
ret i32 %C
|
||||
}
|
||||
|
||||
define i32 @test2(i32 %X, i32* %P) {
|
||||
; CHECK: %A = call i32 @pure(i32 %X)
|
||||
; CHECK-NEXT: store i32 %X, i32* %P
|
||||
; CHECK-NEXT: ret i32 0
|
||||
%A = call i32 @pure( i32 %X ) ; <i32> [#uses=1]
|
||||
store i32 %X, i32* %P ;; Does not invalidate 'pure' call.
|
||||
%B = call i32 @pure( i32 %X ) ; <i32> [#uses=1]
|
||||
%C = sub i32 %A, %B ; <i32> [#uses=1]
|
||||
ret i32 %C
|
||||
}
|
30
external/llvm/test/Analysis/GlobalsModRef/volatile-instrs.ll
vendored
Normal file
30
external/llvm/test/Analysis/GlobalsModRef/volatile-instrs.ll
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
; RUN: opt < %s -basicaa -dse -S | FileCheck %s
|
||||
|
||||
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-apple-macosx10.8.0"
|
||||
|
||||
%struct.anon = type { i32, i32, i32 }
|
||||
@b = global %struct.anon { i32 1, i32 0, i32 0 }, align 4
|
||||
@c = common global i32 0, align 4
|
||||
@a = common global %struct.anon zeroinitializer, align 4
|
||||
@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
|
||||
|
||||
declare i32 @printf(i8* nocapture, ...) nounwind
|
||||
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
|
||||
|
||||
|
||||
; Make sure that the initial memcpy call does not go away
|
||||
; because the volatile load is in the way. PR12899
|
||||
|
||||
; CHECK: main_entry:
|
||||
; CHECK-NEXT: tail call void @llvm.memcpy.p0i8.p0i8.i64
|
||||
|
||||
define i32 @main() nounwind uwtable ssp {
|
||||
main_entry:
|
||||
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* bitcast (%struct.anon* @b to i8*), i8* bitcast (%struct.anon* @a to i8*), i64 12, i32 4, i1 false)
|
||||
%0 = load volatile i32, i32* getelementptr inbounds (%struct.anon, %struct.anon* @b, i64 0, i32 0), align 4
|
||||
store i32 %0, i32* @c, align 4
|
||||
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* bitcast (%struct.anon* @b to i8*), i8* bitcast (%struct.anon* @a to i8*), i64 12, i32 4, i1 false) nounwind
|
||||
%call = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %0) nounwind
|
||||
ret i32 0
|
||||
}
|
24
external/llvm/test/Analysis/GlobalsModRef/weak-interposition.ll
vendored
Normal file
24
external/llvm/test/Analysis/GlobalsModRef/weak-interposition.ll
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
; RUN: opt -S -O1 < %s | FileCheck %s
|
||||
|
||||
@a = common global i32 0, align 4
|
||||
|
||||
; @hook_me is weak, so GMR must not eliminate the reload of @a in @f,
|
||||
; even though @hook_me doesn't mod or ref @a.
|
||||
|
||||
; Function Attrs: nounwind ssp uwtable
|
||||
define weak i32 @hook_me() {
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind ssp uwtable
|
||||
define i32 @f() {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 4, i32* @a, align 4
|
||||
%2 = call i32 @hook_me()
|
||||
; CHECK: load i32, i32* @a, align 4
|
||||
%3 = load i32, i32* @a, align 4
|
||||
%4 = add nsw i32 %3, %2
|
||||
store i32 %4, i32* @a, align 4
|
||||
%5 = load i32, i32* %1
|
||||
ret i32 %5
|
||||
}
|
Reference in New Issue
Block a user