aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-12-13 13:25:29 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-12-13 13:25:29 -0800
commita0885bc3c598b0cbb13321f5bb65f2f9f13550c3 (patch)
treeebdf61b7a1aa47f1b0e9fdb126bd2d690cee0950 /lib/Transforms
parentf5034614a516dc530f89397ac376b80a1141859a (diff)
horrible wip fixes and breaks
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/NaCl/ExpandI64.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/lib/Transforms/NaCl/ExpandI64.cpp b/lib/Transforms/NaCl/ExpandI64.cpp
index 2bdafc1bab..6c00900fb8 100644
--- a/lib/Transforms/NaCl/ExpandI64.cpp
+++ b/lib/Transforms/NaCl/ExpandI64.cpp
@@ -389,14 +389,27 @@ void ExpandI64::splitInst(Instruction *I, DataLayout& DL) {
case Instruction::Call: {
CallInst *CI = dyn_cast<CallInst>(I);
Value *CV = CI->getCalledValue();
+dump("========I========");
+dumpIR(I);
dump("CE1");
+dumpIR(CV);
+ FunctionType *OFT = NULL;
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) {
+ assert(CE);
assert(CE->getOpcode() == Instruction::BitCast);
-dump("CE"); dumpIR(CE);
+ OFT = cast<FunctionType>(cast<PointerType>(CE->getType())->getElementType());
CV = CE->getOperand(0); // we are legalizing the arguments now, so no need to bitcast any more
dump("CV"); dumpIR(CV);
- }
dump("CE2");
+ } else {
+ // this is a function pointer call
+dump("FP call1");
+ OFT = cast<FunctionType>(cast<PointerType>(CV->getType())->getElementType());
+dump("FP call2");
+ // we need to add a bitcast
+ CV = new BitCastInst(CV, getLegalizedFunctionType(OFT)->getPointerTo(), "", I);
+dumpIR(CV);
+ }
FunctionType *FT = NULL;
if (Function *F = dyn_cast<Function>(CV)) {
FT = F->getFunctionType();
@@ -412,20 +425,24 @@ dump("CE2");
// create a call with space for legal args
SmallVector<Value *, 0> Args; // XXX
- int Num = FT->getNumParams();
+ int Num = OFT->getNumParams();
for (int i = 0; i < Num; i++) {
- Type *T = FT->getParamType(i);
-dump("argg");
+ Type *T = OFT->getParamType(i);
+dumpv("argg %d illegal? %d,%d", i, isIllegal(T), isIllegal(CI->getArgOperand(i)->getType()));
if (!isIllegal(T)) {
dump(" legal");
Args.push_back(CI->getArgOperand(i));
+dumpIR(CI->getArgOperand(i));
} else {
dump(" illegal!");
Args.push_back(Zero); // will be fixed
Args.push_back(Zero);
+dumpIR(Zero);
+dumpIR(Zero);
}
}
dumpv("calling with %d args, to something hasing %d args", Args.size(), FT->getNumParams());
+dumpIR(CV);
Instruction *L = CopyDebug(CallInst::Create(CV, Args, "", I), I);
dump("CE3");
Instruction *H = NULL;