diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-12-12 16:41:40 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-12-12 16:41:55 -0800 |
commit | a2a9a7bc14f2e5f9e1989dc6f96095d2333a75bd (patch) | |
tree | 52c15d7ae39cb79f6316571fa81f62243557931c | |
parent | dc9f227a0fef61e246fff0de4d742940002243e0 (diff) |
horrble wip - support legalizing indirect calls
-rw-r--r-- | lib/Transforms/NaCl/ExpandI64.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/Transforms/NaCl/ExpandI64.cpp b/lib/Transforms/NaCl/ExpandI64.cpp index 3f6de3b168..7710e3aee4 100644 --- a/lib/Transforms/NaCl/ExpandI64.cpp +++ b/lib/Transforms/NaCl/ExpandI64.cpp @@ -374,14 +374,18 @@ dump("CE"); dumpIR(CE); dump("CV"); dumpIR(CV); } dump("CE2"); - Function *F = dyn_cast<Function>(CV); - if (!F) { + FunctionType *FT = NULL; + if (Function *F = dyn_cast<Function>(CV)) { + FT = F->getFunctionType(); + } else if (PointerType *PT = dyn_cast<PointerType>(CV->getType())) { + FT = cast<FunctionType>(PT->getElementType()); + } else { dump("CI"); dumpIR(CI); dump("V"); dumpIR(CI->getCalledValue()); dump("CV"); dumpIR(CV); - assert(0); // TODO: handle indirect i64-returning functions, varargs i64 functions, etc. + dump("CV T"); dumpIR(CV->getType()); + assert(0); // TODO: handle varargs i64 functions, etc. } - FunctionType *FT = F->getFunctionType(); // create a call with space for legal args SmallVector<Value *, 0> Args; // XXX @@ -398,8 +402,8 @@ dump(" illegal!"); Args.push_back(Zero); } } -dumpv("calling with %d args, to something hasing %d args", Args.size(), F->getFunctionType()->getNumParams()); - Instruction *L = CopyDebug(CallInst::Create(F, Args, "", I), I); +dumpv("calling with %d args, to something hasing %d args", Args.size(), FT->getNumParams()); + Instruction *L = CopyDebug(CallInst::Create(CV, Args, "", I), I); dump("CE3"); Instruction *H = NULL; // legalize return value as well, if necessary |