@@ -370,9 +370,16 @@ class MCDCRecordProcessor : NextIDsBuilder, mcdc::TVIdxBuilder {
370
370
// / Mapping of calculated MC/DC Independence Pairs for each condition.
371
371
MCDCRecord::TVPairMap IndependencePairs;
372
372
373
+ // / Storage for ExecVectors
374
+ // / ExecVectors is the alias of its 0th element.
375
+ std::array<MCDCRecord::TestVectors, 2 > ExecVectorsByCond;
376
+
373
377
// / Actual executed Test Vectors for the boolean expression, based on
374
378
// / ExecutedTestVectorBitmap.
375
- MCDCRecord::TestVectors ExecVectors;
379
+ MCDCRecord::TestVectors &ExecVectors;
380
+
381
+ // / Number of False items in ExecVectors
382
+ unsigned NumExecVectorsF;
376
383
377
384
#ifndef NDEBUG
378
385
DenseSet<unsigned > TVIdxs;
@@ -385,7 +392,8 @@ class MCDCRecordProcessor : NextIDsBuilder, mcdc::TVIdxBuilder {
385
392
: NextIDsBuilder(Branches), TVIdxBuilder(this ->NextIDs), Bitmap(Bitmap),
386
393
Region (Region), DecisionParams(Region.getDecisionParams()),
387
394
Branches(Branches), NumConditions(DecisionParams.NumConditions),
388
- Folded(NumConditions, false ), IndependencePairs(NumConditions) {}
395
+ Folded(NumConditions, false ), IndependencePairs(NumConditions),
396
+ ExecVectors(ExecVectorsByCond[false ]) {}
389
397
390
398
private:
391
399
// Walk the binary decision diagram and try assigning both false and true to
@@ -415,11 +423,9 @@ class MCDCRecordProcessor : NextIDsBuilder, mcdc::TVIdxBuilder {
415
423
continue ;
416
424
417
425
// Copy the completed test vector to the vector of testvectors.
418
- ExecVectors.push_back (TV);
419
-
420
426
// The final value (T,F) is equal to the last non-dontcare state on the
421
427
// path (in a short-circuiting system).
422
- ExecVectors. back (). push_back (MCDCCond);
428
+ ExecVectorsByCond[MCDCCond]. push_back ({TV, MCDCCond} );
423
429
}
424
430
425
431
// Reset back to DontCare.
@@ -437,6 +443,14 @@ class MCDCRecordProcessor : NextIDsBuilder, mcdc::TVIdxBuilder {
437
443
buildTestVector (TV, 0 , 0 , 0 );
438
444
assert (TVIdxs.size () == unsigned (NumTestVectors) &&
439
445
" TVIdxs wasn't fulfilled" );
446
+
447
+ // Fill ExecVectors order by False items and True items.
448
+ // ExecVectors is the alias of ExecVectorsByCond[false], so
449
+ // Append ExecVectorsByCond[true] on it.
450
+ NumExecVectorsF = ExecVectors.size ();
451
+ auto &ExecVectorsT = ExecVectorsByCond[true ];
452
+ ExecVectors.append (std::make_move_iterator (ExecVectorsT.begin ()),
453
+ std::make_move_iterator (ExecVectorsT.end ()));
440
454
}
441
455
442
456
// Find an independence pair for each condition:
@@ -445,13 +459,12 @@ class MCDCRecordProcessor : NextIDsBuilder, mcdc::TVIdxBuilder {
445
459
// - All other conditions' values must be equal or marked as "don't care".
446
460
void findIndependencePairs () {
447
461
unsigned NumTVs = ExecVectors.size ();
448
- for (unsigned I = 1 ; I < NumTVs; ++I) {
449
- const MCDCRecord::TestVector &A = ExecVectors[I];
450
- for (unsigned J = 0 ; J < I; ++J) {
451
- const MCDCRecord::TestVector &B = ExecVectors[J];
452
- // Enumerate two execution vectors whose outcomes are different.
453
- if (A[NumConditions] == B[NumConditions])
454
- continue ;
462
+ for (unsigned I = NumExecVectorsF; I < NumTVs; ++I) {
463
+ const auto &[A, ACond] = ExecVectors[I];
464
+ assert (ACond == MCDCRecord::MCDC_True);
465
+ for (unsigned J = 0 ; J < NumExecVectorsF; ++J) {
466
+ const auto &[B, BCond] = ExecVectors[J];
467
+ assert (BCond == MCDCRecord::MCDC_False);
455
468
unsigned Flip = NumConditions, Idx;
456
469
for (Idx = 0 ; Idx < NumConditions; ++Idx) {
457
470
MCDCRecord::CondState ACond = A[Idx], BCond = B[Idx];
0 commit comments