Skip to content

Commit

Permalink
Print out the target-independent attributes in a comment before the f…
Browse files Browse the repository at this point in the history
…unction definition.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179622 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
isanbard committed Apr 16, 2013
1 parent 13a1628 commit 6340549
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions lib/IR/AsmWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -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..
Expand Down

0 comments on commit 6340549

Please sign in to comment.