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

Unified Diff: test/Transforms/NaCl/sandbox-memory-accesses.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/sandbox-indirect-calls.ll ('k') | test/Transforms/NaCl/strip-tls.ll » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/Transforms/NaCl/sandbox-memory-accesses.ll
diff --git a/test/Transforms/NaCl/sandbox-memory-accesses.ll b/test/Transforms/NaCl/sandbox-memory-accesses.ll
new file mode 100644
index 0000000000000000000000000000000000000000..e4dd7f080d602d751cbbb0c41d36e495b3976e69
--- /dev/null
+++ b/test/Transforms/NaCl/sandbox-memory-accesses.ll
@@ -0,0 +1,39 @@
+; RUN: opt %s -sandbox-memory-accesses -S | FileCheck %s
+
+
+; CHECK: @__sfi_memory_base = external global i64
+
+define void @func(i32* %ptr) {
+ %val = load i32* %ptr
+ ret void
+}
+; CHECK: define void @func(i32* %ptr) {
+; CHECK-NEXT: %mem_base = load i64* @__sfi_memory_base
+; CHECK-NEXT: %1 = ptrtoint i32* %ptr to i32
+; CHECK-NEXT: %2 = zext i32 %1 to i64
+; CHECK-NEXT: %3 = add i64 %mem_base, %2
+; CHECK-NEXT: %4 = inttoptr i64 %3 to i32*
+; CHECK-NEXT: %val = load i32* %4
+
+define void @func2(i32* %ptr) {
+ %val = load i32* %ptr
+ store i32 %val, i32* %ptr
+ ret void
+}
+; TODO...
+
+define void @ptr_with_addend(i32 %ptr) {
+ %add = add i32 %ptr, 1234
+ %add.p = inttoptr i32 %add to i32*
+ %val = load i32* %add.p
+ ret void
+}
+; CHECK: define void @ptr_with_addend(i32 %ptr) {
+; CHECK-NEXT: %mem_base = load i64* @__sfi_memory_base
+; CHECK-NEXT: %add = add i32 %ptr, 1234
+; CHECK-NEXT: %add.p = inttoptr i32 %add to i32*
+; CHECK-NEXT: %1 = zext i32 %ptr to i64
+; CHECK-NEXT: %2 = add i64 %mem_base, %1
+; CHECK-NEXT: %3 = add i64 %2, 1234
+; CHECK-NEXT: %4 = inttoptr i64 %3 to i32*
+; CHECK-NEXT: %val = load i32* %4
« no previous file with comments | « test/Transforms/NaCl/sandbox-indirect-calls.ll ('k') | test/Transforms/NaCl/strip-tls.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698