llvm.org GIT mirror llvm / 446bc10
It's too risky to eliminate sext / zext of call results for tail call optimization even if the caller / callee attributes completely match. The callee may have been bitcast'ed (or otherwise lied about what it's doing). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95282 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 10 years ago
1 changed file(s) with 4 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
42124212 // causing miscompilation that has not been fully understood.
42134213 if (!Ret) return false;
42144214
4215 // Unless we are explicitly forcing tailcall optimization do not tailcall if
4216 // the called function is bitcast'ed. The analysis may not be entirely
4217 // accurate.
4218 if (!PerformTailCallOpt && isa(CS.getCalledValue()))
4219 return false;
4220
42214215 // If I will have a chain, make sure no other instruction that will have a
42224216 // chain interposes between I and the return.
42234217 if (I->mayHaveSideEffects() || I->mayReadFromMemory() ||
42434237 // the return. Ignore noalias because it doesn't affect the call sequence.
42444238 unsigned CallerRetAttr = F->getAttributes().getRetAttributes();
42454239 if ((CalleeRetAttr ^ CallerRetAttr) & ~Attribute::NoAlias)
4240 return false;
4241
4242 // It's not safe to eliminate thee sign / zero extension of the return value.
4243 if ((CallerRetAttr & Attribute::ZExt) || (CallerRetAttr & Attribute::SExt))
42464244 return false;
42474245
42484246 // Otherwise, make sure the unmodified return value of I is the return value.