[OPENMP] Fix crash on reductions codegen for short circuit reduction operations.

llvm-svn: 236084
This commit is contained in:
Alexey Bataev 2015-04-29 05:21:03 +00:00
parent eb4d7c6b70
commit 19fa2c3b66
2 changed files with 8 additions and 2 deletions

View File

@ -1502,7 +1502,7 @@ void CodeGenFunction::EmitAtomicStore(RValue rvalue, LValue dest,
atomics.getAtomicType(), SourceLocation()));
// Try to write new value using cmpxchg operation
auto Pair = atomics.EmitAtomicCompareExchange(OriginalRValue, NewRValue, AO);
PHI->addIncoming(Pair.first.getScalarVal(), ContBB);
PHI->addIncoming(Pair.first.getScalarVal(), Builder.GetInsertBlock());
Builder.CreateCondBr(Pair.second, ExitBB, ContBB);
EmitBlock(ExitBB, /*IsFinished=*/true);
}
@ -1592,7 +1592,7 @@ void CodeGenFunction::EmitAtomicUpdate(
auto Pair = Atomics.EmitAtomicCompareExchange(OriginalRValue, NewRVal, AO);
OldVal = IsScalar ? Pair.first.getScalarVal()
: Atomics.convertRValueToInt(Pair.first);
PHI->addIncoming(OldVal, ContBB);
PHI->addIncoming(OldVal, Builder.GetInsertBlock());
Builder.CreateCondBr(Pair.second, ExitBB, ContBB);
EmitBlock(ExitBB, /*IsFinished=*/true);
}

View File

@ -42,6 +42,12 @@ T tmain() {
vec[i] = t_var;
s_arr[i] = var;
}
#pragma omp parallel
#pragma omp for reduction(&& : t_var)
for (int i = 0; i < 2; ++i) {
vec[i] = t_var;
s_arr[i] = var;
}
return T();
}