@@ -4564,6 +4564,12 @@ Value *ScalarExprEmitter::VisitBinLAnd(const BinaryOperator *E) {
4564
4564
if (LHSCondVal) { // If we have 1 && X, just emit X.
4565
4565
CGF.incrementProfileCounter (E);
4566
4566
4567
+ // If the top of the logical operator nest, reset the MCDC temp to 0.
4568
+ if (CGF.MCDCLogOpStack .empty ())
4569
+ CGF.maybeResetMCDCCondBitmap (E);
4570
+
4571
+ CGF.MCDCLogOpStack .push_back (E);
4572
+
4567
4573
Value *RHSCond = CGF.EvaluateExprAsBool (E->getRHS ());
4568
4574
4569
4575
// If we're generating for profiling or coverage, generate a branch to a
@@ -4572,6 +4578,7 @@ Value *ScalarExprEmitter::VisitBinLAnd(const BinaryOperator *E) {
4572
4578
// "FalseBlock" after the increment is done.
4573
4579
if (InstrumentRegions &&
4574
4580
CodeGenFunction::isInstrumentedCondition (E->getRHS ())) {
4581
+ CGF.maybeUpdateMCDCCondBitmap (E->getRHS (), RHSCond);
4575
4582
llvm::BasicBlock *FBlock = CGF.createBasicBlock (" land.end" );
4576
4583
llvm::BasicBlock *RHSBlockCnt = CGF.createBasicBlock (" land.rhscnt" );
4577
4584
Builder.CreateCondBr (RHSCond, RHSBlockCnt, FBlock);
@@ -4581,6 +4588,11 @@ Value *ScalarExprEmitter::VisitBinLAnd(const BinaryOperator *E) {
4581
4588
CGF.EmitBlock (FBlock);
4582
4589
}
4583
4590
4591
+ CGF.MCDCLogOpStack .pop_back ();
4592
+ // If the top of the logical operator nest, update the MCDC bitmap.
4593
+ if (CGF.MCDCLogOpStack .empty ())
4594
+ CGF.maybeUpdateMCDCTestVectorBitmap (E);
4595
+
4584
4596
// ZExt result to int or bool.
4585
4597
return Builder.CreateZExtOrBitCast (RHSCond, ResTy, " land.ext" );
4586
4598
}
@@ -4590,6 +4602,12 @@ Value *ScalarExprEmitter::VisitBinLAnd(const BinaryOperator *E) {
4590
4602
return llvm::Constant::getNullValue (ResTy);
4591
4603
}
4592
4604
4605
+ // If the top of the logical operator nest, reset the MCDC temp to 0.
4606
+ if (CGF.MCDCLogOpStack .empty ())
4607
+ CGF.maybeResetMCDCCondBitmap (E);
4608
+
4609
+ CGF.MCDCLogOpStack .push_back (E);
4610
+
4593
4611
llvm::BasicBlock *ContBlock = CGF.createBasicBlock (" land.end" );
4594
4612
llvm::BasicBlock *RHSBlock = CGF.createBasicBlock (" land.rhs" );
4595
4613
@@ -4622,6 +4640,7 @@ Value *ScalarExprEmitter::VisitBinLAnd(const BinaryOperator *E) {
4622
4640
// condition coverage.
4623
4641
if (InstrumentRegions &&
4624
4642
CodeGenFunction::isInstrumentedCondition (E->getRHS ())) {
4643
+ CGF.maybeUpdateMCDCCondBitmap (E->getRHS (), RHSCond);
4625
4644
llvm::BasicBlock *RHSBlockCnt = CGF.createBasicBlock (" land.rhscnt" );
4626
4645
Builder.CreateCondBr (RHSCond, RHSBlockCnt, ContBlock);
4627
4646
CGF.EmitBlock (RHSBlockCnt);
@@ -4639,6 +4658,11 @@ Value *ScalarExprEmitter::VisitBinLAnd(const BinaryOperator *E) {
4639
4658
// Insert an entry into the phi node for the edge with the value of RHSCond.
4640
4659
PN->addIncoming (RHSCond, RHSBlock);
4641
4660
4661
+ CGF.MCDCLogOpStack .pop_back ();
4662
+ // If the top of the logical operator nest, update the MCDC bitmap.
4663
+ if (CGF.MCDCLogOpStack .empty ())
4664
+ CGF.maybeUpdateMCDCTestVectorBitmap (E);
4665
+
4642
4666
// Artificial location to preserve the scope information
4643
4667
{
4644
4668
auto NL = ApplyDebugLocation::CreateArtificial (CGF);
@@ -4680,6 +4704,12 @@ Value *ScalarExprEmitter::VisitBinLOr(const BinaryOperator *E) {
4680
4704
if (!LHSCondVal) { // If we have 0 || X, just emit X.
4681
4705
CGF.incrementProfileCounter (E);
4682
4706
4707
+ // If the top of the logical operator nest, reset the MCDC temp to 0.
4708
+ if (CGF.MCDCLogOpStack .empty ())
4709
+ CGF.maybeResetMCDCCondBitmap (E);
4710
+
4711
+ CGF.MCDCLogOpStack .push_back (E);
4712
+
4683
4713
Value *RHSCond = CGF.EvaluateExprAsBool (E->getRHS ());
4684
4714
4685
4715
// If we're generating for profiling or coverage, generate a branch to a
@@ -4688,6 +4718,7 @@ Value *ScalarExprEmitter::VisitBinLOr(const BinaryOperator *E) {
4688
4718
// "FalseBlock" after the increment is done.
4689
4719
if (InstrumentRegions &&
4690
4720
CodeGenFunction::isInstrumentedCondition (E->getRHS ())) {
4721
+ CGF.maybeUpdateMCDCCondBitmap (E->getRHS (), RHSCond);
4691
4722
llvm::BasicBlock *FBlock = CGF.createBasicBlock (" lor.end" );
4692
4723
llvm::BasicBlock *RHSBlockCnt = CGF.createBasicBlock (" lor.rhscnt" );
4693
4724
Builder.CreateCondBr (RHSCond, FBlock, RHSBlockCnt);
@@ -4697,6 +4728,11 @@ Value *ScalarExprEmitter::VisitBinLOr(const BinaryOperator *E) {
4697
4728
CGF.EmitBlock (FBlock);
4698
4729
}
4699
4730
4731
+ CGF.MCDCLogOpStack .pop_back ();
4732
+ // If the top of the logical operator nest, update the MCDC bitmap.
4733
+ if (CGF.MCDCLogOpStack .empty ())
4734
+ CGF.maybeUpdateMCDCTestVectorBitmap (E);
4735
+
4700
4736
// ZExt result to int or bool.
4701
4737
return Builder.CreateZExtOrBitCast (RHSCond, ResTy, " lor.ext" );
4702
4738
}
@@ -4706,6 +4742,12 @@ Value *ScalarExprEmitter::VisitBinLOr(const BinaryOperator *E) {
4706
4742
return llvm::ConstantInt::get (ResTy, 1 );
4707
4743
}
4708
4744
4745
+ // If the top of the logical operator nest, reset the MCDC temp to 0.
4746
+ if (CGF.MCDCLogOpStack .empty ())
4747
+ CGF.maybeResetMCDCCondBitmap (E);
4748
+
4749
+ CGF.MCDCLogOpStack .push_back (E);
4750
+
4709
4751
llvm::BasicBlock *ContBlock = CGF.createBasicBlock (" lor.end" );
4710
4752
llvm::BasicBlock *RHSBlock = CGF.createBasicBlock (" lor.rhs" );
4711
4753
@@ -4742,6 +4784,7 @@ Value *ScalarExprEmitter::VisitBinLOr(const BinaryOperator *E) {
4742
4784
// condition coverage.
4743
4785
if (InstrumentRegions &&
4744
4786
CodeGenFunction::isInstrumentedCondition (E->getRHS ())) {
4787
+ CGF.maybeUpdateMCDCCondBitmap (E->getRHS (), RHSCond);
4745
4788
llvm::BasicBlock *RHSBlockCnt = CGF.createBasicBlock (" lor.rhscnt" );
4746
4789
Builder.CreateCondBr (RHSCond, ContBlock, RHSBlockCnt);
4747
4790
CGF.EmitBlock (RHSBlockCnt);
@@ -4755,6 +4798,11 @@ Value *ScalarExprEmitter::VisitBinLOr(const BinaryOperator *E) {
4755
4798
CGF.EmitBlock (ContBlock);
4756
4799
PN->addIncoming (RHSCond, RHSBlock);
4757
4800
4801
+ CGF.MCDCLogOpStack .pop_back ();
4802
+ // If the top of the logical operator nest, update the MCDC bitmap.
4803
+ if (CGF.MCDCLogOpStack .empty ())
4804
+ CGF.maybeUpdateMCDCTestVectorBitmap (E);
4805
+
4758
4806
// ZExt result to int.
4759
4807
return Builder.CreateZExtOrBitCast (PN, ResTy, " lor.ext" );
4760
4808
}
@@ -4899,6 +4947,10 @@ VisitAbstractConditionalOperator(const AbstractConditionalOperator *E) {
4899
4947
return Builder.CreateSelect (CondV, LHS, RHS, " cond" );
4900
4948
}
4901
4949
4950
+ // If the top of the logical operator nest, reset the MCDC temp to 0.
4951
+ if (CGF.MCDCLogOpStack .empty ())
4952
+ CGF.maybeResetMCDCCondBitmap (condExpr);
4953
+
4902
4954
llvm::BasicBlock *LHSBlock = CGF.createBasicBlock (" cond.true" );
4903
4955
llvm::BasicBlock *RHSBlock = CGF.createBasicBlock (" cond.false" );
4904
4956
llvm::BasicBlock *ContBlock = CGF.createBasicBlock (" cond.end" );
@@ -4934,6 +4986,11 @@ VisitAbstractConditionalOperator(const AbstractConditionalOperator *E) {
4934
4986
llvm::PHINode *PN = Builder.CreatePHI (LHS->getType (), 2 , " cond" );
4935
4987
PN->addIncoming (LHS, LHSBlock);
4936
4988
PN->addIncoming (RHS, RHSBlock);
4989
+
4990
+ // If the top of the logical operator nest, update the MCDC bitmap.
4991
+ if (CGF.MCDCLogOpStack .empty ())
4992
+ CGF.maybeUpdateMCDCTestVectorBitmap (condExpr);
4993
+
4937
4994
return PN;
4938
4995
}
4939
4996
0 commit comments