Merge pull request #4818 from swiftix/assorted-fixes-3

This commit is contained in:
swift-ci
2016-09-19 15:12:30 -07:00
committed by GitHub
11 changed files with 375 additions and 30 deletions

View File

@@ -66,16 +66,22 @@ bool FunctionEffects::mergeFrom(const FunctionEffects &RHS) {
bool FunctionEffects::mergeFromApply(
const FunctionEffects &ApplyEffects, FullApplySite FAS) {
return mergeFromApply(ApplyEffects, FAS.getInstruction());
}
bool FunctionEffects::mergeFromApply(
const FunctionEffects &ApplyEffects, SILInstruction *AS) {
bool Changed = mergeFlags(ApplyEffects);
Changed |= GlobalEffects.mergeFrom(ApplyEffects.GlobalEffects);
unsigned numCallerArgs = FAS.getNumArguments();
auto FAS = FullApplySite::isa(AS);
unsigned numCallerArgs = FAS ? FAS.getNumArguments() : 1;
unsigned numCalleeArgs = ApplyEffects.ParamEffects.size();
assert(numCalleeArgs >= numCallerArgs);
for (unsigned Idx = 0; Idx < numCalleeArgs; Idx++) {
// Map the callee argument effects to parameters of this function.
// If there are more callee parameters than arguments it means that the
// callee is the result of a partial_apply.
Effects *E = (Idx < numCallerArgs ? getEffectsOn(FAS.getArgument(Idx)) :
Effects *E = (Idx < numCallerArgs ? getEffectsOn(FAS ? FAS.getArgument(Idx) : AS->getOperand(Idx)) :
&GlobalEffects);
Changed |= E->mergeFrom(ApplyEffects.ParamEffects[Idx]);
}