diff options
Diffstat (limited to 'lib/Transforms/NaCl/ExpandVarArgs.cpp')
-rw-r--r-- | lib/Transforms/NaCl/ExpandVarArgs.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/Transforms/NaCl/ExpandVarArgs.cpp b/lib/Transforms/NaCl/ExpandVarArgs.cpp index 99c200c9f0..1b605b79ee 100644 --- a/lib/Transforms/NaCl/ExpandVarArgs.cpp +++ b/lib/Transforms/NaCl/ExpandVarArgs.cpp @@ -283,9 +283,14 @@ static bool ExpandVarArgCall(InstType *Call, DataLayout *DL) { ArgTypes.push_back(VarArgsTy->getPointerTo()); FunctionType *NFTy = FunctionType::get(FuncType->getReturnType(), ArgTypes, false); - Value *CastFunc = - CopyDebug(new BitCastInst(Call->getCalledValue(), NFTy->getPointerTo(), - "vararg_func", Call), Call); + /// XXX EMSCRIPTEN: Handle Constants as well as Instructions, since we + /// don't run the ConstantExpr lowering pass. + Value *CastFunc; + if (Constant *C = dyn_cast<Constant>(Call->getCalledValue())) + CastFunc = ConstantExpr::getBitCast(C, NFTy->getPointerTo()); + else + CastFunc = CopyDebug(new BitCastInst(Call->getCalledValue(), NFTy->getPointerTo(), + "vararg_func", Call), Call); // Create the converted function call. FixedArgs.push_back(Buf); |