aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Voung <jvoung@chromium.org>2013-07-22 10:44:21 -0700
committerJan Voung <jvoung@chromium.org>2013-07-22 10:44:21 -0700
commit9b2942831f43dd9a5802565b9996bdf2c0bfd896 (patch)
treeff2e17be3f7b1cb805543e436624e4d04e13a70f
parent1856bd7d7cb47f7ae32b7c848a8df5c28281e424 (diff)
Disallow dev/private intrinsics by default (only llvm.nacl.target.arch remains)
BUG=https://code.google.com/p/nativeclient/issues/detail?id=3525 R=jfb@chromium.org Review URL: https://codereview.chromium.org/19668004
-rw-r--r--lib/Analysis/NaCl/PNaClABIVerifyModule.cpp18
-rw-r--r--test/NaCl/PNaClABI/abi-debug-info.ll7
-rw-r--r--test/NaCl/PNaClABI/intrinsics.ll24
3 files changed, 31 insertions, 18 deletions
diff --git a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp
index 2793d2ec96..f1359866bd 100644
--- a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp
+++ b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp
@@ -39,8 +39,8 @@ PNaClABIAllowDebugMetadata("pnaclabi-allow-debug-metadata",
static cl::opt<bool>
PNaClABIAllowDevIntrinsics("pnaclabi-allow-dev-intrinsics",
- cl::desc("Allow all LLVM intrinsics during PNaCl ABI verification."),
- cl::init(true)); // TODO(jvoung): Make this false by default.
+ cl::desc("Allow dev LLVM intrinsics during PNaCl ABI verification."),
+ cl::init(false));
namespace {
// This pass should not touch function bodies, to stay streaming-friendly
@@ -234,8 +234,10 @@ bool AllowedIntrinsics::isAllowed(const Function *Func) {
// Keep 3 categories of intrinsics for now.
// (1) Allowed always, provided the exact name and type match.
// (2) Never allowed.
- // (3) "Dev" intrinsics, which may or may not be allowed.
- // "Dev" intrinsics are controlled by the PNaClABIAllowDevIntrinsics flag.
+ // (3) "Dev": intrinsics in the development or prototype stage,
+ // or private intrinsics used for building special programs.
+ // (4) Debug info intrinsics.
+ //
// Please keep these sorted or grouped in a sensible way, within
// each category.
@@ -312,11 +314,13 @@ bool AllowedIntrinsics::isAllowed(const Function *Func) {
return false;
// (3) Dev intrinsics.
- case Intrinsic::dbg_declare:
- case Intrinsic::dbg_value:
- return PNaClABIAllowDevIntrinsics || PNaClABIAllowDebugMetadata;
case Intrinsic::nacl_target_arch: // Used by translator self-build.
return PNaClABIAllowDevIntrinsics;
+
+ // (4) Debug info intrinsics.
+ case Intrinsic::dbg_declare:
+ case Intrinsic::dbg_value:
+ return PNaClABIAllowDebugMetadata;
}
}
diff --git a/test/NaCl/PNaClABI/abi-debug-info.ll b/test/NaCl/PNaClABI/abi-debug-info.ll
index 49b31bab91..884cdc224f 100644
--- a/test/NaCl/PNaClABI/abi-debug-info.ll
+++ b/test/NaCl/PNaClABI/abi-debug-info.ll
@@ -1,10 +1,7 @@
-; RUN: pnacl-abicheck -pnaclabi-allow-dev-intrinsics=0 < %s | FileCheck %s
-; RUN: pnacl-abicheck -pnaclabi-allow-dev-intrinsics=0 \
-; RUN: -pnaclabi-allow-debug-metadata < %s | FileCheck %s --check-prefix=DBG
-; RUN: pnacl-abicheck -pnaclabi-allow-dev-intrinsics=1 < %s | \
+; RUN: pnacl-abicheck < %s | FileCheck %s
+; RUN: pnacl-abicheck -pnaclabi-allow-debug-metadata < %s | \
; RUN: FileCheck %s --check-prefix=DBG
-
; DBG-NOT: disallowed
diff --git a/test/NaCl/PNaClABI/intrinsics.ll b/test/NaCl/PNaClABI/intrinsics.ll
index 9e02511794..3e9d830623 100644
--- a/test/NaCl/PNaClABI/intrinsics.ll
+++ b/test/NaCl/PNaClABI/intrinsics.ll
@@ -1,17 +1,29 @@
-; RUN: pnacl-abicheck -pnaclabi-allow-dev-intrinsics=0 < %s | FileCheck %s
-; RUN: pnacl-abicheck -pnaclabi-allow-dev-intrinsics=0 \
-; RUN: -pnaclabi-allow-debug-metadata < %s | FileCheck %s --check-prefix=DBG
-; RUN: pnacl-abicheck -pnaclabi-allow-dev-intrinsics=1 < %s | \
+; RUN: pnacl-abicheck < %s | FileCheck %s
+; RUN: pnacl-abicheck -pnaclabi-allow-debug-metadata < %s | \
+; RUN: FileCheck %s --check-prefix=DBG
+; RUN: pnacl-abicheck -pnaclabi-allow-dev-intrinsics < %s | \
; RUN: FileCheck %s --check-prefix=DEV
; Test that only white-listed intrinsics are allowed.
; ===================================
-; Some disallowed "Dev" intrinsics.
+; Some "Dev" intrinsics which are disallowed by default.
+
+; CHECK: Function llvm.nacl.target.arch is a disallowed LLVM intrinsic
+; DEV-NOT: Function llvm.nacl.target.arch is a disallowed LLVM intrinsic
+declare i32 @llvm.nacl.target.arch()
+
+
+; ===================================
+; Debug info intrinsics, which are disallowed by default.
+
; CHECK: Function llvm.dbg.value is a disallowed LLVM intrinsic
; DBG-NOT: Function llvm.dbg.value is a disallowed LLVM intrinsic
-; DEV-NOT: Function llvm.dbg.value is a disallowed LLVM intrinsic
declare void @llvm.dbg.value(metadata, i64, metadata)
+; CHECK: Function llvm.dbg.declare is a disallowed LLVM intrinsic
+; DBG-NOT: Function llvm.dbg.declare is a disallowed LLVM intrinsic
+declare void @llvm.dbg.declare(metadata, metadata)
+
; ===================================
; Always allowed intrinsics.