summaryrefslogtreecommitdiff
path: root/lib/IR
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2013-04-16 20:55:47 +0000
committerBill Wendling <isanbard@gmail.com>2013-04-16 20:55:47 +0000
commit634054947c87502e29c0610eb9b378515b768814 (patch)
treefc857a0f578b20c7236194886caf144f18718ce3 /lib/IR
parent13a16284a5a988a85b55f11ca593452e15d373df (diff)
downloadllvm-634054947c87502e29c0610eb9b378515b768814.tar.gz
llvm-634054947c87502e29c0610eb9b378515b768814.tar.bz2
llvm-634054947c87502e29c0610eb9b378515b768814.tar.xz
Print out the target-independent attributes in a comment before the function definition.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179622 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR')
-rw-r--r--lib/IR/AsmWriter.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/lib/IR/AsmWriter.cpp b/lib/IR/AsmWriter.cpp
index fb591a891d..7761127d55 100644
--- a/lib/IR/AsmWriter.cpp
+++ b/lib/IR/AsmWriter.cpp
@@ -1605,6 +1605,29 @@ void AssemblyWriter::printFunction(const Function *F) {
if (F->isMaterializable())
Out << "; Materializable\n";
+ const AttributeSet &Attrs = F->getAttributes();
+ if (Attrs.hasAttributes(AttributeSet::FunctionIndex)) {
+ AttributeSet AS = Attrs.getFnAttributes();
+ std::string AttrStr;
+
+ unsigned Idx = 0;
+ for (unsigned E = AS.getNumSlots(); Idx != E; ++Idx)
+ if (AS.getSlotIndex(Idx) == AttributeSet::FunctionIndex)
+ break;
+
+ for (AttributeSet::iterator I = AS.begin(Idx), E = AS.end(Idx);
+ I != E; ++I) {
+ Attribute Attr = *I;
+ if (!Attr.isStringAttribute()) {
+ if (!AttrStr.empty()) AttrStr += ' ';
+ AttrStr += Attr.getAsString();
+ }
+ }
+
+ if (!AttrStr.empty())
+ Out << "; Function Attrs: " << AttrStr << '\n';
+ }
+
if (F->isDeclaration())
Out << "declare ";
else
@@ -1620,7 +1643,6 @@ void AssemblyWriter::printFunction(const Function *F) {
}
FunctionType *FT = F->getFunctionType();
- const AttributeSet &Attrs = F->getAttributes();
if (Attrs.hasAttributes(AttributeSet::ReturnIndex))
Out << Attrs.getAsString(AttributeSet::ReturnIndex) << ' ';
TypePrinter.print(F->getReturnType(), Out);
@@ -1761,10 +1783,8 @@ void AssemblyWriter::printBasicBlock(const BasicBlock *BB) {
/// which slot it occupies.
///
void AssemblyWriter::printInfoComment(const Value &V) {
- if (AnnotationWriter) {
+ if (AnnotationWriter)
AnnotationWriter->printInfoComment(V, Out);
- return;
- }
}
// This member is called for each Instruction in a function..