aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Seaborn <mseaborn@chromium.org>2013-04-10 09:39:53 -0700
committerMark Seaborn <mseaborn@chromium.org>2013-04-10 09:39:53 -0700
commit4aa5c4891346e228e17c09dcb449d5fa0702d80b (patch)
treebb884dc75bed614d10727de66c0ec43a61d7cd39
parent76cd6aea1dd6e7a446f1e21ac05bc822a50d48ac (diff)
PNaCl ABI checker: Disallow the GetElementPtr instruction
This instruction is removed by ExpandGetElementPtr. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3343 TEST=test/NaCl/PNaClABI/instructions.ll + PNaCl toolchain trybots Review URL: https://codereview.chromium.org/14071005
-rw-r--r--lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp3
-rw-r--r--test/NaCl/PNaClABI/instructions.ll2
2 files changed, 4 insertions, 1 deletions
diff --git a/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp b/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp
index 55269dc9fe..5e773e9751 100644
--- a/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp
+++ b/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp
@@ -65,6 +65,8 @@ bool PNaClABIVerifyFunctions::runOnFunction(Function &F) {
switch (BBI->getOpcode()) {
// Disallowed instructions. Default is to disallow.
default:
+ // We expand GetElementPtr out into arithmetic.
+ case Instruction::GetElementPtr:
// indirectbr may interfere with streaming
case Instruction::IndirectBr:
// No vector instructions yet
@@ -112,7 +114,6 @@ bool PNaClABIVerifyFunctions::runOnFunction(Function &F) {
case Instruction::Fence:
case Instruction::AtomicCmpXchg:
case Instruction::AtomicRMW:
- case Instruction::GetElementPtr:
// Conversion operations
case Instruction::Trunc:
case Instruction::ZExt:
diff --git a/test/NaCl/PNaClABI/instructions.ll b/test/NaCl/PNaClABI/instructions.ll
index 3bd95c8e0f..49585b1fca 100644
--- a/test/NaCl/PNaClABI/instructions.ll
+++ b/test/NaCl/PNaClABI/instructions.ll
@@ -71,6 +71,8 @@ define void @memory() {
fence acq_rel
%a3 = cmpxchg i32* undef, i32 undef, i32 undef acq_rel
%a4 = atomicrmw add i32* undef, i32 1 acquire
+; CHECK-NOT: disallowed
+; CHECK: Function memory has disallowed instruction: getelementptr
%a5 = getelementptr { i32, i32}* undef
ret void
}