Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions llvm/lib/CAS/OnDiskCAS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ class OnDiskCAS : public BuiltinCAS {
static constexpr StringLiteral DataPoolFile = "data";
static constexpr StringLiteral ActionCacheFile = "actions";

static constexpr StringLiteral FilePrefix = "v3.";
static constexpr StringLiteral FilePrefix = "v4.";
static constexpr StringLiteral FileSuffixData = ".data";
static constexpr StringLiteral FileSuffixLeaf = ".leaf";
static constexpr StringLiteral FileSuffixLeaf0 = ".leaf+0";
Expand Down Expand Up @@ -1903,7 +1903,7 @@ Expected<NodeHandle> OnDiskCAS::storeNodeImpl(ArrayRef<uint8_t> ComputedHash,
}

// Big leaf nodes.
if (Data.size() > TrieRecord::MaxEmbeddedSize)
if (Refs.empty() && Data.size() > TrieRecord::MaxEmbeddedSize)
return createStandaloneLeaf(I, Data);

// TODO: Check whether it's worth checking the index for an already existing
Expand Down
10 changes: 8 additions & 2 deletions llvm/unittests/CAS/CASDBTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,15 +400,21 @@ TEST_P(CASDBTest, NodesBig) {
if (Storage.size() < SizeE)
Storage.resize(SizeE, '\01');

SmallVector<CASID, 4> CreatedNodes;
// Avoid checking every size because this is an expensive test. Just check
// for data that is 8B-word-aligned, and one less.
// for data that is 8B-word-aligned, and one less. Also appending the created
// nodes as the references in the next block to check references are created
// correctly.
for (size_t Size = SizeB; Size < SizeE; Size += WordSize) {
for (bool IsAligned : {false, true}) {
StringRef Data(Storage.data(), Size - (IsAligned ? 0 : 1));
Optional<NodeProxy> Node;
ASSERT_THAT_ERROR(CAS->createNode(None, Data).moveInto(Node), Succeeded());
ASSERT_THAT_ERROR(CAS->createNode(CreatedNodes, Data).moveInto(Node),
Succeeded());
ASSERT_EQ(Data, Node->getData());
ASSERT_EQ(0, Node->getData().end()[0]);
ASSERT_EQ(Node->getNumReferences(), CreatedNodes.size());
CreatedNodes.emplace_back(Node->getID());
}
}
}
Expand Down