Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1425)

Unified Diff: test/Transforms/NaCl/expand-alloca.ll

Issue 29743003: Add passes for applying SFI sandboxing at the LLVM IR level Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Retry upload Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/Transforms/NaCl/allocate-data-segment-size.ll ('k') | test/Transforms/NaCl/flatten-globals.ll » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/Transforms/NaCl/expand-alloca.ll
diff --git a/test/Transforms/NaCl/expand-alloca.ll b/test/Transforms/NaCl/expand-alloca.ll
new file mode 100644
index 0000000000000000000000000000000000000000..e4a1575f4810206950b9bd93ce14d9cbfeffc67c
--- /dev/null
+++ b/test/Transforms/NaCl/expand-alloca.ll
@@ -0,0 +1,45 @@
+; RUN: opt %s -expand-allocas -S | FileCheck %s
+
+declare void @foo()
+declare void @external_func(i8*, i8*)
+
+
+; CHECK: @__sfi_stack = internal global i32 1073741824
+
+define void @alloca() {
+ call void @foo()
+ %var1 = alloca i8, i32 10
+ %var2 = alloca i8, i32 20
+ call void @external_func(i8* %var1, i8* %var2)
+ ret void
+}
+; CHECK: define void @alloca()
+; CHECK-NEXT: %frame_top = load i32* @__sfi_stack{{$}}
+; CHECK-NEXT: %frame_bottom = add i32 %frame_top, -30
+; CHECK-NEXT: store i32 %frame_bottom, i32* @__sfi_stack
+; CHECK-NEXT: call void @foo()
+; CHECK-NEXT: %1 = add i32 %frame_top, -10
+; CHECK-NEXT: %var1 = inttoptr i32 %1 to i8*
+; CHECK-NEXT: %2 = add i32 %frame_top, -30
+; CHECK-NEXT: %var2 = inttoptr i32 %2 to i8*
+; CHECK-NEXT: call void @external_func(i8* %var1, i8* %var2)
+; CHECK-NEXT: store i32 %frame_top, i32* @__sfi_stack
+; CHECK-NEXT: ret void
+
+
+; Check that all functions refer to the same __sfi_stack variable.
+define void @second_function() {
+ alloca i8, i32 10
+ ret void
+}
+; CHECK: define void @second_function()
+; CHECK-NEXT: %frame_top = load i32* @__sfi_stack{{$}}
+
+
+; If a function contains no allocas, it doesn't need to modify and
+; restore __sfi_stack.
+define void @func_without_alloca() {
+ ret void
+}
+; CHECK: define void @func_without_alloca() {
+; CHECK-NEXT: ret void
« no previous file with comments | « test/Transforms/NaCl/allocate-data-segment-size.ll ('k') | test/Transforms/NaCl/flatten-globals.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698