1; RUN: opt < %s -O1 -S -enable-non-lto-gmr=true | FileCheck %s 2 3target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 4target triple = "x86_64-apple-macosx10.10.0" 5 6@a = internal global [3 x i32] zeroinitializer, align 4 7@b = common global i32 0, align 4 8 9; The important thing we're checking for here is the reload of (some element of) 10; @a after the memset. 11 12; CHECK-LABEL: @main 13; CHECK: call void @llvm.memset.p0i8.i64{{.*}} @a 14; CHECK: store i32 3 15; CHECK: load i32, i32* getelementptr {{.*}} @a 16; CHECK: icmp eq i32 17; CHECK: br i1 18 19define i32 @main() { 20entry: 21 %retval = alloca i32, align 4 22 %c = alloca [1 x i32], align 4 23 store i32 0, i32* %retval, align 4 24 %0 = bitcast [1 x i32]* %c to i8* 25 call void @llvm.memset.p0i8.i64(i8* %0, i8 0, i64 4, i32 4, i1 false) 26 store i32 1, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @a, i64 0, i64 2), align 4 27 store i32 0, i32* @b, align 4 28 br label %for.cond 29 30for.cond: ; preds = %for.inc, %entry 31 %1 = load i32, i32* @b, align 4 32 %cmp = icmp slt i32 %1, 3 33 br i1 %cmp, label %for.body, label %for.end 34 35for.body: ; preds = %for.cond 36 %2 = load i32, i32* @b, align 4 37 %idxprom = sext i32 %2 to i64 38 %arrayidx = getelementptr inbounds [3 x i32], [3 x i32]* @a, i64 0, i64 %idxprom 39 store i32 0, i32* %arrayidx, align 4 40 br label %for.inc 41 42for.inc: ; preds = %for.body 43 %3 = load i32, i32* @b, align 4 44 %inc = add nsw i32 %3, 1 45 store i32 %inc, i32* @b, align 4 46 br label %for.cond 47 48for.end: ; preds = %for.cond 49 %4 = load i32, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @a, i64 0, i64 2), align 4 50 %cmp1 = icmp ne i32 %4, 0 51 br i1 %cmp1, label %if.then, label %if.end 52 53if.then: ; preds = %for.end 54 call void @abort() #3 55 unreachable 56 57if.end: ; preds = %for.end 58 ret i32 0 59} 60 61; Function Attrs: nounwind argmemonly 62declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) nounwind argmemonly 63 64; Function Attrs: noreturn nounwind 65declare void @abort() noreturn nounwind 66