diff options
Diffstat (limited to 'lib/CodeGen/CGExprComplex.cpp')
| -rw-r--r-- | lib/CodeGen/CGExprComplex.cpp | 29 | 
1 files changed, 17 insertions, 12 deletions
| diff --git a/lib/CodeGen/CGExprComplex.cpp b/lib/CodeGen/CGExprComplex.cpp index 1580bbe6a294..27d1c689966b 100644 --- a/lib/CodeGen/CGExprComplex.cpp +++ b/lib/CodeGen/CGExprComplex.cpp @@ -95,6 +95,7 @@ public:    //===--------------------------------------------------------------------===//    ComplexPairTy Visit(Expr *E) { +    ApplyDebugLocation DL(CGF, E);      return StmtVisitor<ComplexExprEmitter, ComplexPairTy>::Visit(E);    } @@ -316,14 +317,14 @@ ComplexPairTy ComplexExprEmitter::EmitLoadOfLValue(LValue lvalue,    llvm::Value *Real=nullptr, *Imag=nullptr;    if (!IgnoreReal || isVolatile) { -    llvm::Value *RealP = Builder.CreateStructGEP(SrcPtr, 0, +    llvm::Value *RealP = Builder.CreateStructGEP(nullptr, SrcPtr, 0,                                                   SrcPtr->getName() + ".realp");      Real = Builder.CreateAlignedLoad(RealP, AlignR, isVolatile,                                       SrcPtr->getName() + ".real");    }    if (!IgnoreImag || isVolatile) { -    llvm::Value *ImagP = Builder.CreateStructGEP(SrcPtr, 1, +    llvm::Value *ImagP = Builder.CreateStructGEP(nullptr, SrcPtr, 1,                                                   SrcPtr->getName() + ".imagp");      Imag = Builder.CreateAlignedLoad(ImagP, AlignI, isVolatile,                                       SrcPtr->getName() + ".imag"); @@ -335,12 +336,13 @@ ComplexPairTy ComplexExprEmitter::EmitLoadOfLValue(LValue lvalue,  /// specified value pointer.  void ComplexExprEmitter::EmitStoreOfComplex(ComplexPairTy Val, LValue lvalue,                                              bool isInit) { -  if (lvalue.getType()->isAtomicType()) +  if (lvalue.getType()->isAtomicType() || +      (!isInit && CGF.LValueIsSuitableForInlineAtomic(lvalue)))      return CGF.EmitAtomicStore(RValue::getComplex(Val), lvalue, isInit);    llvm::Value *Ptr = lvalue.getAddress(); -  llvm::Value *RealPtr = Builder.CreateStructGEP(Ptr, 0, "real"); -  llvm::Value *ImagPtr = Builder.CreateStructGEP(Ptr, 1, "imag"); +  llvm::Value *RealPtr = Builder.CreateStructGEP(nullptr, Ptr, 0, "real"); +  llvm::Value *ImagPtr = Builder.CreateStructGEP(nullptr, Ptr, 1, "imag");    unsigned AlignR = lvalue.getAlignment().getQuantity();    ASTContext &C = CGF.getContext();    QualType ComplexTy = lvalue.getType(); @@ -375,7 +377,7 @@ VisitImaginaryLiteral(const ImaginaryLiteral *IL) {  ComplexPairTy ComplexExprEmitter::VisitCallExpr(const CallExpr *E) { -  if (E->getCallReturnType()->isReferenceType()) +  if (E->getCallReturnType(CGF.getContext())->isReferenceType())      return EmitLoadOfLValue(E);    return CGF.EmitCallExpr(E).getComplexVal(); @@ -818,6 +820,8 @@ EmitCompoundAssignLValue(const CompoundAssignOperator *E,    TestAndClearIgnoreReal();    TestAndClearIgnoreImag();    QualType LHSTy = E->getLHS()->getType(); +  if (const AtomicType *AT = LHSTy->getAs<AtomicType>()) +    LHSTy = AT->getValueType();    BinOpInfo OpInfo; @@ -945,13 +949,14 @@ VisitAbstractConditionalOperator(const AbstractConditionalOperator *E) {    // Bind the common expression if necessary.    CodeGenFunction::OpaqueValueMapping binding(CGF, E); -  RegionCounter Cnt = CGF.getPGORegionCounter(E); +    CodeGenFunction::ConditionalEvaluation eval(CGF); -  CGF.EmitBranchOnBoolExpr(E->getCond(), LHSBlock, RHSBlock, Cnt.getCount()); +  CGF.EmitBranchOnBoolExpr(E->getCond(), LHSBlock, RHSBlock, +                           CGF.getProfileCount(E));    eval.begin(CGF);    CGF.EmitBlock(LHSBlock); -  Cnt.beginRegion(Builder); +  CGF.incrementProfileCounter(E);    ComplexPairTy LHS = Visit(E->getTrueExpr());    LHSBlock = Builder.GetInsertBlock();    CGF.EmitBranch(ContBlock); @@ -1033,7 +1038,7 @@ ComplexPairTy CodeGenFunction::EmitComplexExpr(const Expr *E, bool IgnoreReal,           "Invalid complex expression to emit");    return ComplexExprEmitter(*this, IgnoreReal, IgnoreImag) -    .Visit(const_cast<Expr*>(E)); +      .Visit(const_cast<Expr *>(E));  }  void CodeGenFunction::EmitComplexExprIntoLValue(const Expr *E, LValue dest, @@ -1085,8 +1090,8 @@ EmitComplexCompoundAssignmentLValue(const CompoundAssignOperator *E) {  }  LValue CodeGenFunction:: -EmitScalarCompooundAssignWithComplex(const CompoundAssignOperator *E, -                                     llvm::Value *&Result) { +EmitScalarCompoundAssignWithComplex(const CompoundAssignOperator *E, +                                    llvm::Value *&Result) {    CompoundFunc Op = getComplexOp(E->getOpcode());    RValue Val;    LValue Ret = ComplexExprEmitter(*this).EmitCompoundAssignLValue(E, Op, Val); | 
