Reland "[IR] Make AttributeSetNode public, avoid temporary AttributeList copies"
authorReid Kleckner <rnk@google.com>
Mon, 10 Apr 2017 23:31:05 +0000 (23:31 +0000)
committerReid Kleckner <rnk@google.com>
Mon, 10 Apr 2017 23:31:05 +0000 (23:31 +0000)
commiteb9dd5b87f43cbd9641fba0555b775589e49af33
tree3aed507a5bb8b601a92c13399bf2a54d54fed432
parent75696ffa2533abb4e4db406d4e2de42e86197413
Reland "[IR] Make AttributeSetNode public, avoid temporary AttributeList copies"

This re-lands r299875.

I introduced a bug in Clang code responsible for replacing K&R, no
prototype declarations with a real function definition with a prototype.
The bug was here:

       // Collect any return attributes from the call.
  -    if (oldAttrs.hasAttributes(llvm::AttributeList::ReturnIndex))
  -      newAttrs.push_back(llvm::AttributeList::get(newFn->getContext(),
  -                                                  oldAttrs.getRetAttributes()));
  +    newAttrs.push_back(oldAttrs.getRetAttributes());

Previously getRetAttributes() carried AttributeList::ReturnIndex in its
AttributeList. Now that we return the AttributeSetNode* directly, it no
longer carries that index, and we call this overload with a single node:
  AttributeList::get(LLVMContext&, ArrayRef<AttributeSetNode*>)

That aborted with an assertion on x86_32 targets. I added an explicit
triple to the test and added CHECKs to help find issues like this in the
future sooner.

llvm-svn: 299899
17 files changed:
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/2006-05-19-SingleEltReturn.c
llvm/include/llvm/IR/AttributeSetNode.h [moved from llvm/lib/IR/AttributeSetNode.h with 93% similarity]
llvm/include/llvm/IR/Attributes.h
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/AsmParser/LLParser.h
llvm/lib/IR/AsmWriter.cpp
llvm/lib/IR/AttributeImpl.h
llvm/lib/IR/Attributes.cpp
llvm/lib/IR/Core.cpp
llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
llvm/lib/Transforms/IPO/MergeFunctions.cpp
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
llvm/lib/Transforms/Utils/CloneFunction.cpp
llvm/lib/Transforms/Utils/CodeExtractor.cpp