Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1075)

Unified Diff: lib/Target/X86/X86FastISel.cpp

Issue 7539010: Emit immediate call arguments locally to save stack size when compiling with -O0 (Closed) Base URL: http://llvm.org/svn/llvm-project/llvm/trunk/
Patch Set: fix several typos Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/CodeGen/X86/fast-isel-x86-64.ll » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/Target/X86/X86FastISel.cpp
===================================================================
--- lib/Target/X86/X86FastISel.cpp (revision 136701)
+++ lib/Target/X86/X86FastISel.cpp (working copy)
@@ -1568,10 +1568,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())
@@ -1579,20 +1581,24 @@
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);
// 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,
@@ -1604,7 +1610,6 @@
if (ArgReg == 0) return false;
Type *ArgTy = ArgVal->getType();
- MVT ArgVT;
if (!isTypeLegal(ArgTy, ArgVT))
return false;
if (ArgVT == MVT::x86mmx)
« no previous file with comments | « no previous file | test/CodeGen/X86/fast-isel-x86-64.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698