aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Transforms/NaCl/PNaClABISimplify.cpp2
-rw-r--r--test/CodeGen/JS/expect-intrinsics.ll26
2 files changed, 28 insertions, 0 deletions
diff --git a/lib/Transforms/NaCl/PNaClABISimplify.cpp b/lib/Transforms/NaCl/PNaClABISimplify.cpp
index a78bf3ef40..5678ffaa7f 100644
--- a/lib/Transforms/NaCl/PNaClABISimplify.cpp
+++ b/lib/Transforms/NaCl/PNaClABISimplify.cpp
@@ -60,7 +60,9 @@ void llvm::PNaClABISimplifyAddPreOptPasses(PassManager &PM) {
// LowerExpect converts Intrinsic::expect into branch weights,
// which can then be removed after BlockPlacement.
+#if 0 // XXX EMSCRIPTEN: We support the expect intrinsic.
PM.add(createLowerExpectIntrinsicPass());
+#endif
#if 0 // XXX EMSCRIPTEN: We don't need this.
// Rewrite unsupported intrinsics to simpler and portable constructs.
PM.add(createRewriteLLVMIntrinsicsPass());
diff --git a/test/CodeGen/JS/expect-intrinsics.ll b/test/CodeGen/JS/expect-intrinsics.ll
new file mode 100644
index 0000000000..b061f52967
--- /dev/null
+++ b/test/CodeGen/JS/expect-intrinsics.ll
@@ -0,0 +1,26 @@
+; RUN: llc -march=js < %s | FileCheck %s
+
+; Handle the llvm.expect intrinsic.
+
+; CHECK: $expval = $x;
+; CHECK: $tobool = ($expval|0)!=(0);
+define void @foo(i32 %x) {
+entry:
+ %expval = call i32 @llvm.expect.i32(i32 %x, i32 0)
+ %tobool = icmp ne i32 %expval, 0
+ br i1 %tobool, label %if.then, label %if.end
+
+if.then:
+ call void @callee()
+ br label %if.end
+
+if.end:
+ ret void
+}
+
+; Function Attrs: nounwind readnone
+declare i32 @llvm.expect.i32(i32, i32) #0
+
+declare void @callee()
+
+attributes #0 = { nounwind readnone }