aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Target/JSBackend/JSBackend.cpp30
-rw-r--r--lib/Transforms/NaCl/PNaClABISimplify.cpp2
-rw-r--r--test/CodeGen/JS/dead-prototypes.ll9
-rw-r--r--test/CodeGen/JS/invariant-intrinsics.ll17
-rw-r--r--test/CodeGen/JS/lifetime-intrinsics.ll17
5 files changed, 60 insertions, 15 deletions
diff --git a/lib/Target/JSBackend/JSBackend.cpp b/lib/Target/JSBackend/JSBackend.cpp
index eb3a6d1929..f9f3633bcd 100644
--- a/lib/Target/JSBackend/JSBackend.cpp
+++ b/lib/Target/JSBackend/JSBackend.cpp
@@ -1887,21 +1887,6 @@ void JSWriter::printModuleBody() {
nl(Out) << "// EMSCRIPTEN_START_FUNCTIONS"; nl(Out);
for (Module::const_iterator I = TheModule->begin(), E = TheModule->end();
I != E; ++I) {
- // Ignore intrinsics that are always no-ops. We don't emit any code for
- // them, so we don't need to declare them.
- if (I->isIntrinsic()) {
- switch (I->getIntrinsicID()) {
- case Intrinsic::dbg_declare:
- case Intrinsic::dbg_value:
- case Intrinsic::lifetime_start:
- case Intrinsic::lifetime_end:
- case Intrinsic::invariant_start:
- case Intrinsic::invariant_end:
- case Intrinsic::prefetch:
- continue;
- }
- }
-
if (!I->isDeclaration()) printFunction(I);
}
Out << "function runPostSets() {\n";
@@ -1934,6 +1919,21 @@ void JSWriter::printModuleBody() {
for (Module::const_iterator I = TheModule->begin(), E = TheModule->end();
I != E; ++I) {
if (I->isDeclaration() && !I->use_empty()) {
+ // Ignore intrinsics that are always no-ops. We don't emit any code for
+ // them, so we don't need to declare them.
+ if (I->isIntrinsic()) {
+ switch (I->getIntrinsicID()) {
+ case Intrinsic::dbg_declare:
+ case Intrinsic::dbg_value:
+ case Intrinsic::lifetime_start:
+ case Intrinsic::lifetime_end:
+ case Intrinsic::invariant_start:
+ case Intrinsic::invariant_end:
+ case Intrinsic::prefetch:
+ continue;
+ }
+ }
+
if (first) {
first = false;
} else {
diff --git a/lib/Transforms/NaCl/PNaClABISimplify.cpp b/lib/Transforms/NaCl/PNaClABISimplify.cpp
index 27dd45e1ea..a78bf3ef40 100644
--- a/lib/Transforms/NaCl/PNaClABISimplify.cpp
+++ b/lib/Transforms/NaCl/PNaClABISimplify.cpp
@@ -158,7 +158,9 @@ void llvm::PNaClABISimplifyAddPostOptPasses(PassManager &PM) {
// Strip dead prototytes to appease the intrinsic ABI checks.
// ExpandVarArgs leaves around vararg intrinsics, and
// ReplacePtrsWithInts leaves the lifetime.start/end intrinsics.
+#if 0 // XXX EMSCRIPTEN: We just ignore dead prototypes.
PM.add(createStripDeadPrototypesPass());
+#endif
// Eliminate simple dead code that the post-opt passes could have
// created.
diff --git a/test/CodeGen/JS/dead-prototypes.ll b/test/CodeGen/JS/dead-prototypes.ll
new file mode 100644
index 0000000000..2a723ed61e
--- /dev/null
+++ b/test/CodeGen/JS/dead-prototypes.ll
@@ -0,0 +1,9 @@
+; RUN: llc -march=js < %s | not grep printf
+
+; llc shouldn't emit any code or bookkeeping for unused declarations.
+
+define void @foo() {
+ ret void
+}
+
+declare i32 @printf(i8* nocapture, ...)
diff --git a/test/CodeGen/JS/invariant-intrinsics.ll b/test/CodeGen/JS/invariant-intrinsics.ll
new file mode 100644
index 0000000000..dc156a9ffb
--- /dev/null
+++ b/test/CodeGen/JS/invariant-intrinsics.ll
@@ -0,0 +1,17 @@
+; RUN: llc -march=js < %s | not grep invariant
+
+; llc currently emits no code or bookkeeping for invariant intrinsic calls
+; or declarations.
+
+declare void @bar(i8*)
+
+define void @foo() {
+ %p = alloca i8
+ %i = call {}* @llvm.invariant.start(i64 1, i8* %p)
+ call void @bar(i8* %p)
+ call void @llvm.invariant.end({}* %i, i64 1, i8* %p)
+ ret void
+}
+
+declare {}* @llvm.invariant.start(i64, i8* nocapture)
+declare void @llvm.invariant.end({}*, i64, i8* nocapture)
diff --git a/test/CodeGen/JS/lifetime-intrinsics.ll b/test/CodeGen/JS/lifetime-intrinsics.ll
new file mode 100644
index 0000000000..e3d8560e30
--- /dev/null
+++ b/test/CodeGen/JS/lifetime-intrinsics.ll
@@ -0,0 +1,17 @@
+; RUN: llc -march=js < %s | not grep lifetime
+
+; llc currently emits no code or bookkeeping for lifetime intrinsic calls
+; or declarations.
+
+declare void @bar(i8*)
+
+define void @foo() {
+ %p = alloca i8
+ call void @llvm.lifetime.start(i64 1, i8* %p)
+ call void @bar(i8* %p)
+ call void @llvm.lifetime.end(i64 1, i8* %p)
+ ret void
+}
+
+declare void @llvm.lifetime.start(i64, i8* nocapture)
+declare void @llvm.lifetime.end(i64, i8* nocapture)