r236084 - [OPENMP] Fix crash on reductions codegen for short circuit reduction operations.
Alexey Bataev
a.bataev at hotmail.com
Tue Apr 28 22:21:03 PDT 2015
Author: abataev
Date: Wed Apr 29 00:21:03 2015
New Revision: 236084
URL: http://llvm.org/viewvc/llvm-project?rev=236084&view=rev
Log:
[OPENMP] Fix crash on reductions codegen for short circuit reduction operations.
Modified:
cfe/trunk/lib/CodeGen/CGAtomic.cpp
cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=236084&r1=236083&r2=236084&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Wed Apr 29 00:21:03 2015
@@ -1502,7 +1502,7 @@ void CodeGenFunction::EmitAtomicStore(RV
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);
}
Modified: cfe/trunk/test/OpenMP/for_reduction_codegen.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_reduction_codegen.cpp?rev=236084&r1=236083&r2=236084&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/for_reduction_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/for_reduction_codegen.cpp Wed Apr 29 00:21:03 2015
@@ -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();
}
More information about the cfe-commits
mailing list