Fix wrong combination of MemoryBehavior.

Instead of taking the maximum we need to handle the special case MayRead + MayWrite = MayReadWrite
This commit is contained in:
Erik Eckstein
2015-12-23 13:47:52 -08:00
parent b05363bab5
commit f8c82889b8
4 changed files with 48 additions and 4 deletions

View File

@@ -253,12 +253,13 @@ MemBehavior MemoryBehaviorVisitor::visitApplyInst(ApplyInst *AI) {
Idx < End && Behavior < MemBehavior::MayHaveSideEffects; ++Idx) {
auto &ArgEffect = ApplyEffects.getParameterEffects()[Idx];
auto ArgBehavior = ArgEffect.getMemBehavior(InspectionMode);
if (ArgBehavior > Behavior) {
auto NewBehavior = combineMemoryBehavior(Behavior, ArgBehavior);
if (NewBehavior != Behavior) {
SILValue Arg = AI->getArgument(Idx);
// We only consider the argument effects if the argument aliases V.
if (!Arg.getType().isAddress() ||
!AA->isNoAlias(Arg, V, computeTBAAType(Arg), getValueTBAAType())) {
Behavior = ArgBehavior;
Behavior = NewBehavior;
}
}
}