• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -basicaa -globals-aa -gvn -instcombine -S -enable-unsafe-globalsmodref-alias-results | FileCheck %s
2; RUN: opt < %s -aa-pipeline=basic-aa,globals-aa -passes="require<globals-aa>,function(gvn,instcombine)" -S -enable-unsafe-globalsmodref-alias-results | FileCheck %s
3;
4; Note that this test relies on an unsafe feature of GlobalsModRef. While this
5; test is correct and safe, GMR's technique for handling this isn't generally.
6
7@G = internal global i32* null		; <i32**> [#uses=3]
8
9declare i8* @malloc(i32)
10define void @test() {
11	%a = call i8* @malloc(i32 4)
12        %A = bitcast i8* %a to i32*
13	store i32* %A, i32** @G
14	ret void
15}
16
17define i32 @test1(i32* %P) {
18; CHECK: ret i32 0
19	%g1 = load i32*, i32** @G		; <i32*> [#uses=2]
20	%h1 = load i32, i32* %g1		; <i32> [#uses=1]
21	store i32 123, i32* %P
22	%g2 = load i32*, i32** @G		; <i32*> [#uses=0]
23	%h2 = load i32, i32* %g1		; <i32> [#uses=1]
24	%X = sub i32 %h1, %h2		; <i32> [#uses=1]
25	ret i32 %X
26}
27