1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -basic-aa -memcpyopt -S < %s -enable-memcpyopt-memoryssa=0 | FileCheck %s 3; RUN: opt -basic-aa -memcpyopt -S < %s -enable-memcpyopt-memoryssa=1 -verify-memoryssa | FileCheck %s 4 5target 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" 6target triple = "x86_64-apple-macosx10.7.0" 7 8@x = global i32 0 9 10declare void @otherf(i32*) 11 12declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i1) nounwind 13 14; memcpyopt should not touch atomic ops 15define void @test1() nounwind uwtable ssp { 16; CHECK-LABEL: @test1( 17; CHECK-NEXT: [[X:%.*]] = alloca [101 x i32], align 16 18; CHECK-NEXT: [[BC:%.*]] = bitcast [101 x i32]* [[X]] to i8* 19; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 16 [[BC]], i8 0, i64 400, i1 false) 20; CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds [101 x i32], [101 x i32]* [[X]], i32 0, i32 100 21; CHECK-NEXT: store atomic i32 0, i32* [[GEP1]] unordered, align 4 22; CHECK-NEXT: [[GEP2:%.*]] = getelementptr inbounds [101 x i32], [101 x i32]* [[X]], i32 0, i32 0 23; CHECK-NEXT: call void @otherf(i32* [[GEP2]]) 24; CHECK-NEXT: ret void 25; 26 %x = alloca [101 x i32], align 16 27 %bc = bitcast [101 x i32]* %x to i8* 28 call void @llvm.memset.p0i8.i64(i8* align 16 %bc, i8 0, i64 400, i1 false) 29 %gep1 = getelementptr inbounds [101 x i32], [101 x i32]* %x, i32 0, i32 100 30 store atomic i32 0, i32* %gep1 unordered, align 4 31 %gep2 = getelementptr inbounds [101 x i32], [101 x i32]* %x, i32 0, i32 0 32 call void @otherf(i32* %gep2) 33 ret void 34} 35 36; memcpyopt across unordered store 37define void @test2() nounwind uwtable ssp { 38; CHECK-LABEL: @test2( 39; CHECK-NEXT: [[OLD:%.*]] = alloca i32, align 4 40; CHECK-NEXT: [[NEW:%.*]] = alloca i32, align 4 41; CHECK-NEXT: call void @otherf(i32* nocapture [[NEW]]) 42; CHECK-NEXT: store atomic i32 0, i32* @x unordered, align 4 43; CHECK-NEXT: call void @otherf(i32* nocapture [[NEW]]) 44; CHECK-NEXT: ret void 45; 46 %old = alloca i32 47 %new = alloca i32 48 call void @otherf(i32* nocapture %old) 49 store atomic i32 0, i32* @x unordered, align 4 50 %v = load i32, i32* %old 51 store i32 %v, i32* %new 52 call void @otherf(i32* nocapture %new) 53 ret void 54} 55 56