~pali/+junk/llvm-toolchain-3.7

« back to all changes in this revision

Viewing changes to test/Analysis/BasicAA/nocapture.ll

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2015-07-15 17:51:08 UTC
  • Revision ID: package-import@ubuntu.com-20150715175108-l8mynwovkx4zx697
Tags: upstream-3.7~+rc2
ImportĀ upstreamĀ versionĀ 3.7~+rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
; RUN: opt < %s -basicaa -gvn -instcombine -S | FileCheck %s
 
2
 
 
3
declare i32* @test(i32* nocapture)
 
4
 
 
5
define i32 @test2() {
 
6
; CHECK: ret i32 0
 
7
       %P = alloca i32
 
8
       %Q = call i32* @test(i32* %P)
 
9
       %a = load i32, i32* %P
 
10
       store i32 4, i32* %Q   ;; cannot clobber P since it is nocapture.
 
11
       %b = load i32, i32* %P
 
12
       %c = sub i32 %a, %b
 
13
       ret i32 %c
 
14
}
 
15
 
 
16
declare void @test3(i32** %p, i32* %q) nounwind
 
17
 
 
18
define i32 @test4(i32* noalias nocapture %p) nounwind {
 
19
; CHECK: call void @test3
 
20
; CHECK: store i32 0, i32* %p
 
21
; CHECK: store i32 1, i32* %x
 
22
; CHECK: %y = load i32, i32* %p
 
23
; CHECK: ret i32 %y
 
24
entry:
 
25
       %q = alloca i32*
 
26
       ; Here test3 might store %p to %q. This doesn't violate %p's nocapture
 
27
       ; attribute since the copy doesn't outlive the function.
 
28
       call void @test3(i32** %q, i32* %p) nounwind
 
29
       store i32 0, i32* %p
 
30
       %x = load i32*, i32** %q
 
31
       ; This store might write to %p and so we can't eliminate the subsequent
 
32
       ; load
 
33
       store i32 1, i32* %x
 
34
       %y = load i32, i32* %p
 
35
       ret i32 %y
 
36
}