[PATCH] D33627: Fix Crashes when 'AttributeList::get'ing with an ArrayRef<AttributeList> where all pImpl are null

Nicholas Wilson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 28 00:44:14 PDT 2017


thewilsonator created this revision.
Herald added a subscriber: javed.absar.

As the Title says, this causes crashes if you go

  AttributeList::get(getContext(), { AttributeList(),AttributeList() });

It is sensitive to I/O, I have no idea why it is I/O sensitive but it is, at least it disappears when logging is turned on in LDC (the LLVM D Compiler) without fail. 
Sometimes the last function in the stacktrace is

  _vsnprintf + 586
  llvm::AttributeList::get(llvm::LLVMContext&, llvm::ArrayRef<llvm::AttributeList>) + 798

Anyway this appears to fix this and will speed up merges of null AttributeList.

Nicholas


Repository:
  rL LLVM

https://reviews.llvm.org/D33627

Files:
  lib/IR/Attributes.cpp


Index: lib/IR/Attributes.cpp
===================================================================
--- lib/IR/Attributes.cpp
+++ lib/IR/Attributes.cpp
@@ -1006,6 +1006,9 @@
   for (AttributeList List : Attrs)
     MaxSize = std::max(MaxSize, List.getNumAttrSets());

+  if (MaxSize == 0)
+    return AttributeList();
+
   SmallVector<AttributeSet, 8> NewAttrSets(MaxSize);
   for (unsigned I = 0; I < MaxSize; ++I) {
     AttrBuilder CurBuilder;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33627.100544.patch
Type: text/x-patch
Size: 444 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170528/5d9a9073/attachment.bin>


More information about the llvm-commits mailing list