|
7 | 7 | //===----------------------------------------------------------------------===//
|
8 | 8 |
|
9 | 9 | #include "llvm/IR/Metadata.h"
|
| 10 | +#include "../lib/IR/LLVMContextImpl.h" |
10 | 11 | #include "llvm/ADT/DenseMap.h"
|
11 | 12 | #include "llvm/ADT/STLExtras.h"
|
12 | 13 | #include "llvm/IR/Constants.h"
|
@@ -1591,6 +1592,44 @@ TEST_F(DILocationTest, discriminatorSpecialCases) {
|
1591 | 1592 | EXPECT_EQ(std::nullopt, L4->cloneByMultiplyingDuplicationFactor(0x1000));
|
1592 | 1593 | }
|
1593 | 1594 |
|
| 1595 | +TEST_F(DILocationTest, KeyInstructions) { |
| 1596 | + Context.pImpl->NextAtomGroup = 1; |
| 1597 | + |
| 1598 | + EXPECT_EQ(Context.pImpl->NextAtomGroup, 1u); |
| 1599 | + DILocation *A1 = |
| 1600 | + DILocation::get(Context, 1, 0, getSubprogram(), nullptr, false, 1, 2); |
| 1601 | + // The group is only applied to the DILocation if we've built LLVM with |
| 1602 | + // EXPERIMENTAL_KEY_INSTRUCTIONS. |
| 1603 | +#ifdef EXPERIMENTAL_KEY_INSTRUCTIONS |
| 1604 | + EXPECT_EQ(A1->getAtomGroup(), 1u); |
| 1605 | + EXPECT_EQ(A1->getAtomRank(), 2u); |
| 1606 | +#else |
| 1607 | + EXPECT_EQ(A1->getAtomGroup(), 0u); |
| 1608 | + EXPECT_EQ(A1->getAtomRank(), 0u); |
| 1609 | +#endif |
| 1610 | + |
| 1611 | + // Group number 1 has been "used" so next available is 2. |
| 1612 | + EXPECT_EQ(Context.pImpl->NextAtomGroup, 2u); |
| 1613 | + |
| 1614 | + // Set a group number higher than current + 1, then check the waterline. |
| 1615 | + DILocation::get(Context, 2, 0, getSubprogram(), nullptr, false, 5, 1); |
| 1616 | + EXPECT_EQ(Context.pImpl->NextAtomGroup, 6u); |
| 1617 | + |
| 1618 | + // The waterline should be unchanged (group <= next). |
| 1619 | + DILocation::get(Context, 3, 0, getSubprogram(), nullptr, false, 4, 1); |
| 1620 | + EXPECT_EQ(Context.pImpl->NextAtomGroup, 6u); |
| 1621 | + DILocation::get(Context, 3, 0, getSubprogram(), nullptr, false, 5, 1); |
| 1622 | + EXPECT_EQ(Context.pImpl->NextAtomGroup, 6u); |
| 1623 | + |
| 1624 | + // Check the waterline gets incremented by 1. |
| 1625 | + EXPECT_EQ(Context.incNextDILocationAtomGroup(), 6u); |
| 1626 | + EXPECT_EQ(Context.pImpl->NextAtomGroup, 7u); |
| 1627 | + |
| 1628 | + Context.updateDILocationAtomGroupWaterline(8); |
| 1629 | + EXPECT_EQ(Context.pImpl->NextAtomGroup, 8u); |
| 1630 | + Context.updateDILocationAtomGroupWaterline(7); |
| 1631 | + EXPECT_EQ(Context.pImpl->NextAtomGroup, 8u); |
| 1632 | +} |
1594 | 1633 |
|
1595 | 1634 | typedef MetadataTest GenericDINodeTest;
|
1596 | 1635 |
|
|
0 commit comments