[llvm-branch-commits] [cfe-branch] r286965 - Merging r286129:

Alexey Bataev via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Nov 15 06:15:57 PST 2016


Author: abataev
Date: Tue Nov 15 08:15:56 2016
New Revision: 286965

URL: http://llvm.org/viewvc/llvm-project?rev=286965&view=rev
Log:
Merging r286129:
------------------------------------------------------------------------
r286129 | abataev | 2016-11-07 18:15:02 +0000 (Mon, 07 Nov 2016) | 8 lines

[OPENMP] Fixed codegen for __real/__imag expressions in atomic
constructs.

For __real/__imag unary expressions clang emits lvalue with the
associated type from the original complex expression, but not the
underlying builtin integer or float type. This causes crash in codegen
for atomic constructs, if __real/__imag expression are used in atomic
  constructs.
------------------------------------------------------------------------

Modified:
    cfe/branches/release_39/   (props changed)
    cfe/branches/release_39/lib/CodeGen/CGExpr.cpp
    cfe/branches/release_39/test/OpenMP/atomic_write_codegen.c

Propchange: cfe/branches/release_39/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Nov 15 08:15:56 2016
@@ -1,4 +1,4 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:275880,275967,276102,276350,276361,276473,276653,276716,276887,276891,276900,276979,276983,277095,277138,277141,277221,277307,277522,277743,277783,277796-277797,277852,277866,277889,277900,278139,278156,278234-278235,278393,278395,278763,278786,278988,284110,286103,286106
+/cfe/trunk:275880,275967,276102,276350,276361,276473,276653,276716,276887,276891,276900,276979,276983,277095,277138,277141,277221,277307,277522,277743,277783,277796-277797,277852,277866,277889,277900,278139,278156,278234-278235,278393,278395,278763,278786,278988,284110,286103,286106,286129
 /cfe/trunk/test:170344
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_39/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/lib/CodeGen/CGExpr.cpp?rev=286965&r1=286964&r2=286965&view=diff
==============================================================================
--- cfe/branches/release_39/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/branches/release_39/lib/CodeGen/CGExpr.cpp Tue Nov 15 08:15:56 2016
@@ -2248,13 +2248,15 @@ LValue CodeGenFunction::EmitUnaryOpLValu
       return LV;
     }
 
-    assert(E->getSubExpr()->getType()->isAnyComplexType());
+    QualType T = ExprTy->castAs<ComplexType>()->getElementType();
 
     Address Component =
       (E->getOpcode() == UO_Real
          ? emitAddrOfRealComponent(LV.getAddress(), LV.getType())
          : emitAddrOfImagComponent(LV.getAddress(), LV.getType()));
-    return MakeAddrLValue(Component, ExprTy, LV.getAlignmentSource());
+    LValue ElemLV = MakeAddrLValue(Component, T, LV.getAlignmentSource());
+    ElemLV.getQuals().addQualifiers(LV.getQuals());
+    return ElemLV;
   }
   case UO_PreInc:
   case UO_PreDec: {

Modified: cfe/branches/release_39/test/OpenMP/atomic_write_codegen.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/test/OpenMP/atomic_write_codegen.c?rev=286965&r1=286964&r2=286965&view=diff
==============================================================================
--- cfe/branches/release_39/test/OpenMP/atomic_write_codegen.c (original)
+++ cfe/branches/release_39/test/OpenMP/atomic_write_codegen.c Tue Nov 15 08:15:56 2016
@@ -78,6 +78,9 @@ float2 float2x;
 register int rix __asm__("esp");
 
 int main() {
+// CHECK: store atomic i32 1, i32* getelementptr inbounds ({ i32, i32 }, { i32, i32 }* @civ, i32 0, i32 1) monotonic,
+#pragma omp atomic write
+ __imag(civ) = 1;
 // CHECK: load i8, i8*
 // CHECK: store atomic i8
 #pragma omp atomic write




More information about the llvm-branch-commits mailing list