aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Transforms/NaCl/ExpandVarArgs.cpp15
-rw-r--r--lib/Transforms/NaCl/PNaClABISimplify.cpp5
2 files changed, 18 insertions, 2 deletions
diff --git a/lib/Transforms/NaCl/ExpandVarArgs.cpp b/lib/Transforms/NaCl/ExpandVarArgs.cpp
index 578ea4cc0e..089a8170d9 100644
--- a/lib/Transforms/NaCl/ExpandVarArgs.cpp
+++ b/lib/Transforms/NaCl/ExpandVarArgs.cpp
@@ -66,6 +66,11 @@ INITIALIZE_PASS(ExpandVarArgs, "expand-varargs",
"Expand out variable argument function definitions and calls",
false, false)
+static bool isEmscriptenJSArgsFunc(StringRef Name) {
+ return Name.equals("emscripten_asm_const_int") ||
+ Name.equals("emscripten_asm_const_double");
+}
+
static void ExpandVarArgFunc(Function *Func) {
Type *PtrType = Type::getInt8PtrTy(Func->getContext());
@@ -179,6 +184,13 @@ static bool ExpandVarArgCall(InstType *Call, DataLayout *DL) {
if (!FuncType->isFunctionVarArg())
return false;
+
+ // EMSCRIPTEN: use js varargs for special instrinsics
+ const Value *CV = Call->getCalledValue();
+ if (isa<Function>(CV) && isEmscriptenJSArgsFunc(CV->getName())) {
+ return false;
+ }
+
LLVMContext *Context = &Call->getContext();
SmallVector<AttributeSet, 8> Attrs;
@@ -326,7 +338,8 @@ bool ExpandVarArgs::runOnModule(Module &M) {
}
}
- if (Func->isVarArg()) {
+ // EMSCRIPTEN: use js varargs for special instrinsics
+ if (Func->isVarArg() && !isEmscriptenJSArgsFunc(Func->getName())) {
Changed = true;
ExpandVarArgFunc(Func);
}
diff --git a/lib/Transforms/NaCl/PNaClABISimplify.cpp b/lib/Transforms/NaCl/PNaClABISimplify.cpp
index c9fbc7df42..013c03550d 100644
--- a/lib/Transforms/NaCl/PNaClABISimplify.cpp
+++ b/lib/Transforms/NaCl/PNaClABISimplify.cpp
@@ -87,8 +87,9 @@ void llvm::PNaClABISimplifyAddPostOptPasses(PassManager &PM) {
// some optimizations undo its changes. Note that
// ExpandSmallArguments requires that ExpandVarArgs has already been
// run.
+#if 0 // EMSCRIPTEN: we don't need to worry about the issue this works around
PM.add(createExpandSmallArgumentsPass());
-
+#endif
PM.add(createPromoteI1OpsPass());
// Optimization passes and ExpandByVal introduce
@@ -129,7 +130,9 @@ void llvm::PNaClABISimplifyAddPostOptPasses(PassManager &PM) {
// analyses add attributes to reflect their results.
// StripAttributes must come after ExpandByVal and
// ExpandSmallArguments.
+#if 0 // EMSCRIPTEN: we don't need to worry about the issue this works around
PM.add(createStripAttributesPass());
+#endif
// Strip dead prototytes to appease the intrinsic ABI checks.
// ExpandVarArgs leaves around vararg intrinsics, and