summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/Hexagon/runtime-stkchk.ll
diff options
context:
space:
mode:
authorKrzysztof Parzyszek <kparzysz@codeaurora.org>2016-03-24 20:20:07 +0000
committerKrzysztof Parzyszek <kparzysz@codeaurora.org>2016-03-24 20:20:07 +0000
commitc9d4caa32c02c8bfa29c1e5af610c28f7592df5b (patch)
tree1cc1aee57e5b6e51cf1a7f870b10d087d4f26d55 /llvm/test/CodeGen/Hexagon/runtime-stkchk.ll
parent3b0290570b031a579b17e5cfad0e381576779489 (diff)
downloadbcm5719-llvm-c9d4caa32c02c8bfa29c1e5af610c28f7592df5b.tar.gz
bcm5719-llvm-c9d4caa32c02c8bfa29c1e5af610c28f7592df5b.zip
[Hexagon] Add support for run-time stack overflow checking
Patch by Sundeep Kushwaha. llvm-svn: 264328
Diffstat (limited to 'llvm/test/CodeGen/Hexagon/runtime-stkchk.ll')
-rw-r--r--llvm/test/CodeGen/Hexagon/runtime-stkchk.ll44
1 files changed, 44 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/Hexagon/runtime-stkchk.ll b/llvm/test/CodeGen/Hexagon/runtime-stkchk.ll
new file mode 100644
index 00000000000..a4e8f117679
--- /dev/null
+++ b/llvm/test/CodeGen/Hexagon/runtime-stkchk.ll
@@ -0,0 +1,44 @@
+; RUN: llc -march=hexagon -mcpu=hexagonv55 -enable-stackovf-sanitizer < %s | FileCheck %s
+
+; CHECK-LABEL: foo_1
+; CHECK: __runtime_stack_check
+define i32 @foo_1(i32 %n) #0 {
+entry:
+ %local = alloca [1024 x i32], align 8
+ %0 = bitcast [1024 x i32]* %local to i8*
+ call void @llvm.lifetime.start(i64 4096, i8* %0) #1
+ %arraydecay = getelementptr inbounds [1024 x i32], [1024 x i32]* %local, i32 0, i32 0
+ call void @baz_1(i32* %arraydecay) #3
+ %arrayidx = getelementptr inbounds [1024 x i32], [1024 x i32]* %local, i32 0, i32 %n
+ %1 = load i32, i32* %arrayidx, align 4
+ call void @llvm.lifetime.end(i64 4096, i8* %0) #1
+ ret i32 %1
+}
+
+; CHECK-LABEL: foo_2
+; CHECK: __save_r16_through_r19_stkchk
+define i32 @foo_2(i32 %n, i32* %y) #0 {
+entry:
+ %local = alloca [2048 x i32], align 8
+ %0 = bitcast [2048 x i32]* %local to i8*
+ call void @llvm.lifetime.start(i64 8192, i8* %0) #1
+ %arraydecay = getelementptr inbounds [2048 x i32], [2048 x i32]* %local, i32 0, i32 0
+ call void @baz_2(i32* %y, i32* %arraydecay) #3
+ %1 = load i32, i32* %y, align 4
+ %add = add nsw i32 %n, %1
+ %arrayidx = getelementptr inbounds [2048 x i32], [2048 x i32]* %local, i32 0, i32 %add
+ %2 = load i32, i32* %arrayidx, align 4
+ call void @llvm.lifetime.end(i64 8192, i8* %0) #1
+ ret i32 %2
+}
+
+declare void @baz_1(i32*) #2
+declare void @baz_2(i32*, i32*) #2
+declare void @llvm.lifetime.start(i64, i8* nocapture) #1
+declare void @llvm.lifetime.end(i64, i8* nocapture) #1
+
+attributes #0 = { nounwind optsize "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #1 = { nounwind }
+attributes #2 = { optsize "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #3 = { optsize }
+
OpenPOWER on IntegriCloud