From d2cc6c2d0c2f8a6e272110416a3fd579ed5a3ac1 Mon Sep 17 00:00:00 2001 From: Serge Guelton Date: Mon, 3 Jan 2022 13:32:19 -0500 Subject: Use a sorted array instead of a map to store AttrBuilder string attributes Using and std::map for target dependent attributes is inefficient: it makes its constructor slightly heavier, and involves extra allocation for each new string attribute. Storing the attribute key/value as strings implies extra allocation/copy step. Use a sorted vector instead. Given the low number of attributes generally involved, this is cheaper, as showcased by https://llvm-compile-time-tracker.com/compare.php?from=5de322295f4ade692dc4f1823ae4450ad3c48af2&to=05bc480bf641a9e3b466619af43a2d123ee3f71d&stat=instructions Differential Revision: https://reviews.llvm.org/D116599 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp') diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 13f492859a31..9e414aa74dc7 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1349,7 +1349,7 @@ Error BitcodeReader::parseAttributeBlock() { return error("Invalid record"); for (unsigned i = 0, e = Record.size(); i != e; i += 2) { - AttrBuilder B; + AttrBuilder B(Context); decodeLLVMAttributesForBitcode(B, Record[i+1]); Attrs.push_back(AttributeList::get(Context, Record[i], B)); } @@ -1591,7 +1591,7 @@ Error BitcodeReader::parseAttributeGroupBlock() { uint64_t GrpID = Record[0]; uint64_t Idx = Record[1]; // Index of the object this attribute refers to. - AttrBuilder B; + AttrBuilder B(Context); for (unsigned i = 2, e = Record.size(); i != e; ++i) { if (Record[i] == 0) { // Enum attribute Attribute::AttrKind Kind; -- cgit v1.2.3