From 2ad0c779c3ea2104913a6d92d9d98f00b41c5adb Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Tue, 6 Jul 2010 05:18:56 +0000 Subject: Fix up -fstack-protector on linux to use the segment registers. Split out testcases per architecture and os now. Patch from Nelson Elhage. llvm-svn: 107640 --- llvm/test/CodeGen/Generic/stack-protector.ll | 25 ----------------------- llvm/test/CodeGen/PowerPC/stack-protector.ll | 25 +++++++++++++++++++++++ llvm/test/CodeGen/X86/stack-protector-linux.ll | 28 ++++++++++++++++++++++++++ llvm/test/CodeGen/X86/stack-protector.ll | 25 +++++++++++++++++++++++ 4 files changed, 78 insertions(+), 25 deletions(-) delete mode 100644 llvm/test/CodeGen/Generic/stack-protector.ll create mode 100644 llvm/test/CodeGen/PowerPC/stack-protector.ll create mode 100644 llvm/test/CodeGen/X86/stack-protector-linux.ll create mode 100644 llvm/test/CodeGen/X86/stack-protector.ll (limited to 'llvm/test') diff --git a/llvm/test/CodeGen/Generic/stack-protector.ll b/llvm/test/CodeGen/Generic/stack-protector.ll deleted file mode 100644 index a59c649781d..00000000000 --- a/llvm/test/CodeGen/Generic/stack-protector.ll +++ /dev/null @@ -1,25 +0,0 @@ -; RUN: llc < %s -o - | grep {__stack_chk_guard} -; RUN: llc < %s -o - | grep {__stack_chk_fail} - -@"\01LC" = internal constant [11 x i8] c"buf == %s\0A\00" ; <[11 x i8]*> [#uses=1] - -define void @test(i8* %a) nounwind ssp { -entry: - %a_addr = alloca i8* ; [#uses=2] - %buf = alloca [8 x i8] ; <[8 x i8]*> [#uses=2] - %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] - store i8* %a, i8** %a_addr - %buf1 = bitcast [8 x i8]* %buf to i8* ; [#uses=1] - %0 = load i8** %a_addr, align 4 ; [#uses=1] - %1 = call i8* @strcpy(i8* %buf1, i8* %0) nounwind ; [#uses=0] - %buf2 = bitcast [8 x i8]* %buf to i8* ; [#uses=1] - %2 = call i32 (i8*, ...)* @printf(i8* getelementptr ([11 x i8]* @"\01LC", i32 0, i32 0), i8* %buf2) nounwind ; [#uses=0] - br label %return - -return: ; preds = %entry - ret void -} - -declare i8* @strcpy(i8*, i8*) nounwind - -declare i32 @printf(i8*, ...) nounwind diff --git a/llvm/test/CodeGen/PowerPC/stack-protector.ll b/llvm/test/CodeGen/PowerPC/stack-protector.ll new file mode 100644 index 00000000000..20203612502 --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/stack-protector.ll @@ -0,0 +1,25 @@ +; RUN: llc -march=ppc32 < %s -o - | grep {__stack_chk_guard} +; RUN: llc -march=ppc32 < %s -o - | grep {__stack_chk_fail} + +@"\01LC" = internal constant [11 x i8] c"buf == %s\0A\00" ; <[11 x i8]*> [#uses=1] + +define void @test(i8* %a) nounwind ssp { +entry: + %a_addr = alloca i8* ; [#uses=2] + %buf = alloca [8 x i8] ; <[8 x i8]*> [#uses=2] + %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] + store i8* %a, i8** %a_addr + %buf1 = bitcast [8 x i8]* %buf to i8* ; [#uses=1] + %0 = load i8** %a_addr, align 4 ; [#uses=1] + %1 = call i8* @strcpy(i8* %buf1, i8* %0) nounwind ; [#uses=0] + %buf2 = bitcast [8 x i8]* %buf to i8* ; [#uses=1] + %2 = call i32 (i8*, ...)* @printf(i8* getelementptr ([11 x i8]* @"\01LC", i32 0, i32 0), i8* %buf2) nounwind ; [#uses=0] + br label %return + +return: ; preds = %entry + ret void +} + +declare i8* @strcpy(i8*, i8*) nounwind + +declare i32 @printf(i8*, ...) nounwind diff --git a/llvm/test/CodeGen/X86/stack-protector-linux.ll b/llvm/test/CodeGen/X86/stack-protector-linux.ll new file mode 100644 index 00000000000..fe2a9c5d57a --- /dev/null +++ b/llvm/test/CodeGen/X86/stack-protector-linux.ll @@ -0,0 +1,28 @@ +; RUN: llc -mtriple=i386-pc-linux-gnu < %s -o - | grep %gs: +; RUN: llc -mtriple=x86_64-pc-linux-gnu < %s -o - | grep %fs: +; RUN: llc -code-model=kernel -mtriple=x86_64-pc-linux-gnu < %s -o - | grep %gs: +; RUN: llc -mtriple=x86_64-apple-darwin < %s -o - | grep {__stack_chk_guard} +; RUN: llc -mtriple=x86_64-apple-darwin < %s -o - | grep {__stack_chk_fail} + +@"\01LC" = internal constant [11 x i8] c"buf == %s\0A\00" ; <[11 x i8]*> [#uses=1] + +define void @test(i8* %a) nounwind ssp { +entry: + %a_addr = alloca i8* ; [#uses=2] + %buf = alloca [8 x i8] ; <[8 x i8]*> [#uses=2] + %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] + store i8* %a, i8** %a_addr + %buf1 = bitcast [8 x i8]* %buf to i8* ; [#uses=1] + %0 = load i8** %a_addr, align 4 ; [#uses=1] + %1 = call i8* @strcpy(i8* %buf1, i8* %0) nounwind ; [#uses=0] + %buf2 = bitcast [8 x i8]* %buf to i8* ; [#uses=1] + %2 = call i32 (i8*, ...)* @printf(i8* getelementptr ([11 x i8]* @"\01LC", i32 0, i32 0), i8* %buf2) nounwind ; [#uses=0] + br label %return + +return: ; preds = %entry + ret void +} + +declare i8* @strcpy(i8*, i8*) nounwind + +declare i32 @printf(i8*, ...) nounwind diff --git a/llvm/test/CodeGen/X86/stack-protector.ll b/llvm/test/CodeGen/X86/stack-protector.ll new file mode 100644 index 00000000000..f0fc4ddbd65 --- /dev/null +++ b/llvm/test/CodeGen/X86/stack-protector.ll @@ -0,0 +1,25 @@ +; RUN: llc -march=x86 < %s -o - | grep {__stack_chk_guard} +; RUN: llc -march=x86 < %s -o - | grep {__stack_chk_fail} + +@"\01LC" = internal constant [11 x i8] c"buf == %s\0A\00" ; <[11 x i8]*> [#uses=1] + +define void @test(i8* %a) nounwind ssp { +entry: + %a_addr = alloca i8* ; [#uses=2] + %buf = alloca [8 x i8] ; <[8 x i8]*> [#uses=2] + %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] + store i8* %a, i8** %a_addr + %buf1 = bitcast [8 x i8]* %buf to i8* ; [#uses=1] + %0 = load i8** %a_addr, align 4 ; [#uses=1] + %1 = call i8* @strcpy(i8* %buf1, i8* %0) nounwind ; [#uses=0] + %buf2 = bitcast [8 x i8]* %buf to i8* ; [#uses=1] + %2 = call i32 (i8*, ...)* @printf(i8* getelementptr ([11 x i8]* @"\01LC", i32 0, i32 0), i8* %buf2) nounwind ; [#uses=0] + br label %return + +return: ; preds = %entry + ret void +} + +declare i8* @strcpy(i8*, i8*) nounwind + +declare i32 @printf(i8*, ...) nounwind -- cgit v1.2.3