summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/SafeStack/ret.ll
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2015-11-13 21:21:42 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2015-11-13 21:21:42 +0000
commit447bbdb17134e9463e45d41610b9e0dd73323dcf (patch)
treedaacd7b2b19af7c297869891ff364609fdc66d07 /llvm/test/Transforms/SafeStack/ret.ll
parent7f5562b87e48bdde22749b22aada5ab5f31d5a76 (diff)
downloadbcm5719-llvm-447bbdb17134e9463e45d41610b9e0dd73323dcf.tar.gz
bcm5719-llvm-447bbdb17134e9463e45d41610b9e0dd73323dcf.zip
[safestack] Rewrite isAllocaSafe using SCEV.
Use ScalarEvolution to calculate memory access bounds. Handle function calls based on readnone/nocapture attributes. Handle memory intrinsics with constant size. This change improves both recall and precision of IsAllocaSafe. See the new tests (ex. BitCastWide) for the kind of code that was wrongly classified as safe. SCEV efficiency seems to be limited by the fact the SafeStack runs late (in CodeGenPrepare), and many loops are unrolled or otherwise not in LCSSA. llvm-svn: 253083
Diffstat (limited to 'llvm/test/Transforms/SafeStack/ret.ll')
-rw-r--r--llvm/test/Transforms/SafeStack/ret.ll17
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/test/Transforms/SafeStack/ret.ll b/llvm/test/Transforms/SafeStack/ret.ll
new file mode 100644
index 00000000000..b2b8e566529
--- /dev/null
+++ b/llvm/test/Transforms/SafeStack/ret.ll
@@ -0,0 +1,17 @@
+; RUN: opt -safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s
+; RUN: opt -safe-stack -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s
+
+@.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1
+
+; Returns an alloca address.
+; Requires protector.
+
+define i64 @foo() nounwind readnone safestack {
+entry:
+ ; CHECK-LABEL: define i64 @foo(
+ ; CHECK: __safestack_unsafe_stack_ptr
+ ; CHECK: ret i64
+ %x = alloca [100 x i32], align 16
+ %0 = ptrtoint [100 x i32]* %x to i64
+ ret i64 %0
+}
OpenPOWER on IntegriCloud