aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Seaborn <mseaborn@chromium.org>2013-05-30 13:14:50 -0700
committerMark Seaborn <mseaborn@chromium.org>2013-05-30 13:14:50 -0700
commit381b0fb87f1fe806d678af8c48b67b4e0dc3a43b (patch)
tree3f6d52d5fafbf9a2c952b8e723f832644b1d99f0
parentf72e0b53e25548d6db9220a03a303e589c9773a4 (diff)
PNaCl ABI checker: Disallow llvm.lifetime.start/end intrinsics
Run StripDeadPrototypes as a final pass to ensure that the prototypes for lifetime.start/end are removed. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3443 TEST=PNaCl toolchain trybots Review URL: https://codereview.chromium.org/16063005
-rw-r--r--lib/Analysis/NaCl/PNaClABIVerifyModule.cpp9
-rw-r--r--lib/Transforms/NaCl/PNaClABISimplify.cpp8
-rw-r--r--test/NaCl/PNaClABI/intrinsics.ll13
3 files changed, 18 insertions, 12 deletions
diff --git a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp
index 0e406e6512..9b2def5ac4 100644
--- a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp
+++ b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp
@@ -163,8 +163,6 @@ bool PNaClABIVerifyModule::isWhitelistedIntrinsic(const Function *F,
case Intrinsic::bswap: return isWhitelistedBswap(F);
case Intrinsic::invariant_end:
case Intrinsic::invariant_start:
- case Intrinsic::lifetime_end:
- case Intrinsic::lifetime_start:
case Intrinsic::memcpy:
case Intrinsic::memmove:
case Intrinsic::memset:
@@ -210,6 +208,13 @@ bool PNaClABIVerifyModule::isWhitelistedIntrinsic(const Function *F,
case Intrinsic::usub_with_overflow:
case Intrinsic::smul_with_overflow:
case Intrinsic::umul_with_overflow:
+ // Disallow lifetime.start/end because the semantics of what
+ // arguments they accept are not very well defined, and because it
+ // would be better to do merging of stack slots in the user
+ // toolchain than in the PNaCl translator.
+ // See https://code.google.com/p/nativeclient/issues/detail?id=3443
+ case Intrinsic::lifetime_end:
+ case Intrinsic::lifetime_start:
return false;
// (3) Dev intrinsics.
diff --git a/lib/Transforms/NaCl/PNaClABISimplify.cpp b/lib/Transforms/NaCl/PNaClABISimplify.cpp
index 8c945800af..74a9f0730e 100644
--- a/lib/Transforms/NaCl/PNaClABISimplify.cpp
+++ b/lib/Transforms/NaCl/PNaClABISimplify.cpp
@@ -39,9 +39,6 @@ void llvm::PNaClABISimplifyAddPreOptPasses(PassManager &PM) {
// GlobalCleanup needs to run after ExpandTls because
// __tls_template_start etc. are extern_weak before expansion
PM.add(createGlobalCleanupPass());
- // Strip dead prototytes to appease the intrinsic ABI checks
- // (ExpandVarArgs leaves around var-arg intrinsics).
- PM.add(createStripDeadPrototypesPass());
}
void llvm::PNaClABISimplifyAddPostOptPasses(PassManager &PM) {
@@ -78,4 +75,9 @@ void llvm::PNaClABISimplifyAddPostOptPasses(PassManager &PM) {
// ReplacePtrsWithInts assumes that getelementptr instructions and
// ConstantExprs have already been expanded out.
PM.add(createReplacePtrsWithIntsPass());
+
+ // Strip dead prototytes to appease the intrinsic ABI checks.
+ // ExpandVarArgs leaves around vararg intrinsics, and
+ // ReplacePtrsWithInts leaves the lifetime.start/end intrinsics.
+ PM.add(createStripDeadPrototypesPass());
}
diff --git a/test/NaCl/PNaClABI/intrinsics.ll b/test/NaCl/PNaClABI/intrinsics.ll
index d54a9fe863..e5fe6116ed 100644
--- a/test/NaCl/PNaClABI/intrinsics.ll
+++ b/test/NaCl/PNaClABI/intrinsics.ll
@@ -21,13 +21,6 @@ declare i8* @llvm.returnaddress(i32 %level)
; ===================================
; Always allowed intrinsics.
-; CHECK-NOT: Function llvm.lifetime.start is a disallowed LLVM intrinsic
-; DBG-NOT: Function llvm.lifetime.start is a disallowed LLVM intrinsic
-; DEV-NOT: Function llvm.lifetime.start is a disallowed LLVM intrinsic
-declare void @llvm.lifetime.start(i64, i8* nocapture)
-
-; CHECK-NOT: Function llvm.lifetime.start is a disallowed LLVM intrinsic
-declare void @llvm.lifetime.end(i64, i8* nocapture)
; CHECK-NOT: Function llvm.memcpy.p0i8.p0i8.i32 is a disallowed LLVM intrinsic
declare void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src,
@@ -75,3 +68,9 @@ declare i1 @llvm.bswap.1(i1)
; CHECK: Function llvm.bswap.8 is a disallowed LLVM intrinsic
declare i8 @llvm.bswap.8(i8)
+
+; CHECK: Function llvm.lifetime.start is a disallowed LLVM intrinsic
+declare void @llvm.lifetime.start(i64, i8* nocapture)
+
+; CHECK: Function llvm.lifetime.end is a disallowed LLVM intrinsic
+declare void @llvm.lifetime.end(i64, i8* nocapture)