diff options
-rw-r--r-- | lib/Analysis/NaCl/PNaClABIVerifyModule.cpp | 6 | ||||
-rw-r--r-- | lib/Transforms/NaCl/PNaClABISimplify.cpp | 3 | ||||
-rw-r--r-- | test/NaCl/PNaClABI/intrinsics.ll | 12 |
3 files changed, 12 insertions, 9 deletions
diff --git a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp index 16d51ed609..b68ac29a9e 100644 --- a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp +++ b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp @@ -228,6 +228,9 @@ bool PNaClABIVerifyModule::isWhitelistedIntrinsic(const Function *F, case Intrinsic::log2: // Rounding not defined: support with fast-math? case Intrinsic::log10: // Rounding not defined: support with fast-math? case Intrinsic::sin: // Rounding not defined: support with fast-math? + // We run -lower-expect to convert Intrinsic::expect into branch weights + // and consume in the middle-end. The backend just ignores llvm.expect. + case Intrinsic::expect: return false; // (3) Dev intrinsics. @@ -237,9 +240,6 @@ bool PNaClABIVerifyModule::isWhitelistedIntrinsic(const Function *F, case Intrinsic::ctlz: // Support via compiler_rt if arch doesn't have it? case Intrinsic::ctpop: // Support via compiler_rt if arch doesn't have it? case Intrinsic::cttz: // Support via compiler_rt if arch doesn't have it? - // Can run -lower-expect, and consume in the middle-end. - // Selection-DAG just treats it as a pass-through. - case Intrinsic::expect: // From __builtin_expect. case Intrinsic::flt_rounds: // For FLT_ROUNDS macro from float.h. // We do not have fesetround() in newlib, can we return a // consistent rounding mode though? diff --git a/lib/Transforms/NaCl/PNaClABISimplify.cpp b/lib/Transforms/NaCl/PNaClABISimplify.cpp index e50112c741..0fd7176ed9 100644 --- a/lib/Transforms/NaCl/PNaClABISimplify.cpp +++ b/lib/Transforms/NaCl/PNaClABISimplify.cpp @@ -22,6 +22,9 @@ using namespace llvm; void llvm::PNaClABISimplifyAddPreOptPasses(PassManager &PM) { + // LowerExpect converts Intrinsic::expect into branch weights, + // which can then be removed after BlockPlacement. + PM.add(createLowerExpectIntrinsicPass()); // LowerInvoke prevents use of C++ exception handling, which is not // yet supported in the PNaCl ABI. PM.add(createLowerInvokePass()); diff --git a/test/NaCl/PNaClABI/intrinsics.ll b/test/NaCl/PNaClABI/intrinsics.ll index e5fe6116ed..e8624fe813 100644 --- a/test/NaCl/PNaClABI/intrinsics.ll +++ b/test/NaCl/PNaClABI/intrinsics.ll @@ -13,12 +13,6 @@ ; DEV-NOT: Function llvm.dbg.value is a disallowed LLVM intrinsic declare void @llvm.dbg.value(metadata, i64, metadata) -; CHECK: Function llvm.frameaddress is a disallowed LLVM intrinsic -declare i8* @llvm.frameaddress(i32 %level) - -; CHECK: Function llvm.returnaddress is a disallowed LLVM intrinsic -declare i8* @llvm.returnaddress(i32 %level) - ; =================================== ; Always allowed intrinsics. @@ -74,3 +68,9 @@ 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) + +; CHECK: Function llvm.frameaddress is a disallowed LLVM intrinsic +declare i8* @llvm.frameaddress(i32 %level) + +; CHECK: Function llvm.returnaddress is a disallowed LLVM intrinsic +declare i8* @llvm.returnaddress(i32 %level) |