blob: 0493edc8d090ded8d5672540ee8394e012109ab7 [file] [log] [blame]
Jakob Stoklund Olesen20850892010-05-28 17:06:30 +00001; RUN: llc -O0 -regalloc=linearscan < %s -march=x86-64 | FileCheck %s -check-prefix=X64
Mike Stumpf8a74fc2009-11-09 23:10:49 +00002
3; ModuleID = 'ts.c'
4target 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"
5target triple = "x86_64-apple-darwin10.0"
6
7@p = common global i8* null, align 8 ; <i8**> [#uses=4]
8@.str = private constant [3 x i8] c"Hi\00" ; <[3 x i8]*> [#uses=1]
9
10define void @bar() nounwind ssp {
11entry:
12 %tmp = load i8** @p ; <i8*> [#uses=1]
Eric Christopherfdb33452009-12-23 02:51:48 +000013 %0 = call i64 @llvm.objectsize.i64(i8* %tmp, i1 0) ; <i64> [#uses=1]
Mike Stumpf8a74fc2009-11-09 23:10:49 +000014 %cmp = icmp ne i64 %0, -1 ; <i1> [#uses=1]
Eric Christopher304f13c2010-03-11 06:20:22 +000015; X64: movabsq $-1, %rax
Mike Stumpf8a74fc2009-11-09 23:10:49 +000016; X64: cmpq $-1, %rax
17 br i1 %cmp, label %cond.true, label %cond.false
18
19cond.true: ; preds = %entry
20 %tmp1 = load i8** @p ; <i8*> [#uses=1]
21 %tmp2 = load i8** @p ; <i8*> [#uses=1]
Eric Christopherfdb33452009-12-23 02:51:48 +000022 %1 = call i64 @llvm.objectsize.i64(i8* %tmp2, i1 1) ; <i64> [#uses=1]
Mike Stumpf8a74fc2009-11-09 23:10:49 +000023 %call = call i8* @__strcpy_chk(i8* %tmp1, i8* getelementptr inbounds ([3 x i8]* @.str, i32 0, i32 0), i64 %1) ssp ; <i8*> [#uses=1]
24 br label %cond.end
25
26cond.false: ; preds = %entry
27 %tmp3 = load i8** @p ; <i8*> [#uses=1]
28 %call4 = call i8* @__inline_strcpy_chk(i8* %tmp3, i8* getelementptr inbounds ([3 x i8]* @.str, i32 0, i32 0)) ssp ; <i8*> [#uses=1]
29 br label %cond.end
30
31cond.end: ; preds = %cond.false, %cond.true
32 %cond = phi i8* [ %call, %cond.true ], [ %call4, %cond.false ] ; <i8*> [#uses=0]
33 ret void
34}
35
Eric Christopherfdb33452009-12-23 02:51:48 +000036declare i64 @llvm.objectsize.i64(i8*, i1) nounwind readonly
Mike Stumpf8a74fc2009-11-09 23:10:49 +000037
38declare i8* @__strcpy_chk(i8*, i8*, i64) ssp
39
40define internal i8* @__inline_strcpy_chk(i8* %__dest, i8* %__src) nounwind ssp {
41entry:
42 %retval = alloca i8* ; <i8**> [#uses=2]
43 %__dest.addr = alloca i8* ; <i8**> [#uses=3]
44 %__src.addr = alloca i8* ; <i8**> [#uses=2]
45 store i8* %__dest, i8** %__dest.addr
46 store i8* %__src, i8** %__src.addr
47 %tmp = load i8** %__dest.addr ; <i8*> [#uses=1]
48 %tmp1 = load i8** %__src.addr ; <i8*> [#uses=1]
49 %tmp2 = load i8** %__dest.addr ; <i8*> [#uses=1]
Eric Christopherfdb33452009-12-23 02:51:48 +000050 %0 = call i64 @llvm.objectsize.i64(i8* %tmp2, i1 1) ; <i64> [#uses=1]
Mike Stumpf8a74fc2009-11-09 23:10:49 +000051 %call = call i8* @__strcpy_chk(i8* %tmp, i8* %tmp1, i64 %0) ssp ; <i8*> [#uses=1]
52 store i8* %call, i8** %retval
53 %1 = load i8** %retval ; <i8*> [#uses=1]
54 ret i8* %1
55}