Chromium Code Reviews| Index: lib/Target/X86/X86FastISel.cpp |
| =================================================================== |
| --- lib/Target/X86/X86FastISel.cpp (revision 136475) |
| +++ lib/Target/X86/X86FastISel.cpp (working copy) |
| @@ -1565,10 +1565,12 @@ |
| if (CS.paramHasAttr(AttrInd, Attribute::Nest)) |
| Flags.setNest(); |
| - // If this is an i1/i8/i16 argument, promote to i32 to avoid an extra |
| - // instruction. This is safe because it is common to all fastisel supported |
| - // calling conventions on x86. |
| + unsigned ArgReg; |
| + MVT ArgVT; |
| if (ConstantInt *CI = dyn_cast<ConstantInt>(ArgVal)) { |
| + // If this is an i1/i8/i16 argument, promote to i32 to avoid an extra |
| + // instruction. This is safe because it is common to all fastisel |
| + // supported calling conventions on x86. |
| if (CI->getBitWidth() == 1 || CI->getBitWidth() == 8 || |
| CI->getBitWidth() == 16) { |
| if (Flags.isSExt()) |
| @@ -1576,20 +1578,25 @@ |
| else |
| ArgVal = ConstantExpr::getZExt(CI,Type::getInt32Ty(CI->getContext())); |
| } |
| - } |
| - unsigned ArgReg; |
| - |
| + // Emit immediate arguments for the call locally to avoid spilling. |
| + if (!isTypeLegal(ArgVal->getType(), ArgVT)) return false; |
| + uint64_t val; |
| + if (Flags.isSExt()) |
| + val = CI->getSExtValue(); |
| + else |
| + val = CI->getZExtValue(); |
| + ArgReg = FastEmit_i(ArgVT, ArgVT, ISD::Constant, val); |
| + // ArgReg = getRegForValue(ArgVal); |
|
nlewycky
2011/08/01 20:49:28
Don't send out a patch with a commented-out line.
krasin
2011/08/01 20:55:37
Shame on me!
Done.
|
| // Passing bools around ends up doing a trunc to i1 and passing it. |
| // Codegen this as an argument + "and 1". |
| - if (ArgVal->getType()->isIntegerTy(1) && isa<TruncInst>(ArgVal) && |
| + } else if (ArgVal->getType()->isIntegerTy(1) && isa<TruncInst>(ArgVal) && |
| cast<TruncInst>(ArgVal)->getParent() == I->getParent() && |
| ArgVal->hasOneUse()) { |
| ArgVal = cast<TruncInst>(ArgVal)->getOperand(0); |
| ArgReg = getRegForValue(ArgVal); |
| if (ArgReg == 0) return false; |
| - MVT ArgVT; |
| if (!isTypeLegal(ArgVal->getType(), ArgVT)) return false; |
| ArgReg = FastEmit_ri(ArgVT, ArgVT, ISD::AND, ArgReg, |
| @@ -1601,7 +1608,6 @@ |
| if (ArgReg == 0) return false; |
| Type *ArgTy = ArgVal->getType(); |
| - MVT ArgVT; |
| if (!isTypeLegal(ArgTy, ArgVT)) |
| return false; |
| if (ArgVT == MVT::x86mmx) |