diff options
author | Mark Seaborn <mseaborn@chromium.org> | 2013-07-01 10:28:53 -0700 |
---|---|---|
committer | Mark Seaborn <mseaborn@chromium.org> | 2013-07-01 10:28:53 -0700 |
commit | ec8e5bad316e85ea87716793b499dd6f204d78c0 (patch) | |
tree | 13dd719731e000aee8e143be96378b32fd3f7311 /test | |
parent | 5ea800923b912c6c34cbb8e2db8a47101fe74700 (diff) |
PNaCl ABI checker: Check for exact names and types of whitelisted intrinsics
This makes the checker stricter, so that it will reject names such as
"@llvm.memcpy.foo".
Reuse Intrinsic::getName() and Intrinsic::getType() for checking the
exact function name and type that we should expect for whitelisted
intrinsics. This is simpler than writing code to check each argument
type separately.
intrinsics.ll test: Add some tests. Simplify existing tests by
replacing multiple CHECK-NOTs with a single "CHECK-NOT: disallowed",
which is stricter because it is less specific.
BUG=https://code.google.com/p/nativeclient/issues/detail?id=3530
TEST=*.ll tests + PNaCl toolchain trybots
Review URL: https://codereview.chromium.org/18302002
Diffstat (limited to 'test')
-rw-r--r-- | test/NaCl/PNaClABI/abi-bad-intrinsic.ll | 10 | ||||
-rw-r--r-- | test/NaCl/PNaClABI/intrinsics.ll | 32 |
2 files changed, 23 insertions, 19 deletions
diff --git a/test/NaCl/PNaClABI/abi-bad-intrinsic.ll b/test/NaCl/PNaClABI/abi-bad-intrinsic.ll new file mode 100644 index 0000000000..644394038d --- /dev/null +++ b/test/NaCl/PNaClABI/abi-bad-intrinsic.ll @@ -0,0 +1,10 @@ +; RUN: pnacl-abicheck < %s | FileCheck %s + +; This intrinsic is declared with the wrong type, using i32* arguments +; instead of i8*. Check that the ABI verifier rejects this. This +; must be tested in a separate .ll file from the correct intrinsic +; declarations. + +declare void @llvm.memcpy.p0i8.p0i8.i32(i32* %dest, i32* %src, + i32 %len, i32 %align, i1 %isvolatile) +; CHECK: Function llvm.memcpy.p0i8.p0i8.i32 is a disallowed LLVM intrinsic diff --git a/test/NaCl/PNaClABI/intrinsics.ll b/test/NaCl/PNaClABI/intrinsics.ll index 57edd4031f..1c28cfd967 100644 --- a/test/NaCl/PNaClABI/intrinsics.ll +++ b/test/NaCl/PNaClABI/intrinsics.ll @@ -16,49 +16,38 @@ declare void @llvm.dbg.value(metadata, i64, metadata) ; =================================== ; Always allowed intrinsics. -; CHECK-NOT: Function llvm.memcpy.p0i8.p0i8.i32 is a disallowed LLVM intrinsic declare void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 %len, i32 %align, i1 %isvolatile) -; CHECK-NOT: Function llvm.memmove.p0i8.p0i8.i32 is a disallowed LLVM intrinsic declare void @llvm.memmove.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 %len, i32 %align, i1 %isvolatile) -; CHECK-NOT: Function llvm.memset.p0i8.i32 is a disallowed LLVM intrinsic declare void @llvm.memset.p0i8.i32(i8* %dest, i8 %val, i32 %len, i32 %align, i1 %isvolatile) -; CHECK-NOT: Function llvm.nacl.read.tp is a disallowed LLVM intrinsic declare i8* @llvm.nacl.read.tp() -; CHECK-NOT: Function llvm.bswap.i16 is a disallowed LLVM intrinsic declare i16 @llvm.bswap.i16(i16) - -; CHECK-NOT: Function llvm.bswap.i32 is a disallowed LLVM intrinsic declare i32 @llvm.bswap.i32(i32) - -; CHECK-NOT: Function llvm.bswap.i64 is a disallowed LLVM intrinsic declare i64 @llvm.bswap.i64(i64) -; CHECK-NOT: Function llvm.cttz.i32 is a disallowed LLVM intrinsic declare i32 @llvm.cttz.i32(i32, i1) - -; CHECK-NOT: Function llvm.cttz.i64 is a disallowed LLVM intrinsic declare i64 @llvm.cttz.i64(i64, i1) -; CHECK-NOT: Function llvm.ctlz.i32 is a disallowed LLVM intrinsic declare i32 @llvm.ctlz.i32(i32, i1) - -; CHECK-NOT: Function llvm.ctlz.i64 is a disallowed LLVM intrinsic declare i64 @llvm.ctlz.i64(i64, i1) -; CHECK-NOT: Function llvm.ctpop.i32 is a disallowed LLVM intrinsic declare i32 @llvm.ctpop.i32(i32) - -; CHECK-NOT: Function llvm.ctpop.i64 is a disallowed LLVM intrinsic declare i64 @llvm.ctpop.i64(i64) -; CHECK-NOT: Function llvm.trap is a disallowed LLVM intrinsic declare void @llvm.trap() +declare i8* @llvm.stacksave() +declare void @llvm.stackrestore(i8*) + +declare void @llvm.nacl.longjmp(i8*, i32) +declare i32 @llvm.nacl.setjmp(i8*) + +; CHECK-NOT: disallowed + ; =================================== ; Always disallowed intrinsics. @@ -119,3 +108,8 @@ declare void @llvm.memmove.p0i8.p0i8.i64(i8* %dest, i8* %src, ; CHECK: Function llvm.memset.p0i8.i64 is a disallowed LLVM intrinsic declare void @llvm.memset.p0i8.i64(i8* %dest, i8 %val, i64 %len, i32 %align, i1 %isvolatile) + +; Test that the ABI checker checks the full function name. +; CHECK: Function llvm.memset.foo is a disallowed LLVM intrinsic +declare void @llvm.memset.foo(i8* %dest, i8 %val, + i64 %len, i32 %align, i1 %isvolatile) |