Index: llvm/trunk/lib/IR/Attributes.cpp =================================================================== --- llvm/trunk/lib/IR/Attributes.cpp +++ llvm/trunk/lib/IR/Attributes.cpp @@ -1006,6 +1006,10 @@ for (AttributeList List : Attrs) MaxSize = std::max(MaxSize, List.getNumAttrSets()); + // If every list was empty, there is no point in merging the lists. + if (MaxSize == 0) + return AttributeList(); + SmallVector NewAttrSets(MaxSize); for (unsigned I = 0; I < MaxSize; ++I) { AttrBuilder CurBuilder; Index: llvm/trunk/unittests/IR/AttributesTest.cpp =================================================================== --- llvm/trunk/unittests/IR/AttributesTest.cpp +++ llvm/trunk/unittests/IR/AttributesTest.cpp @@ -82,4 +82,11 @@ EXPECT_TRUE(AL.hasParamAttribute(0, Attribute::NonNull)); } +TEST(Attributes, EmptyGet) { + LLVMContext C; + AttributeList EmptyLists[] = {AttributeList(), AttributeList()}; + AttributeList AL = AttributeList::get(C, EmptyLists); + EXPECT_TRUE(AL.isEmpty()); +} + } // end anonymous namespace