#include "llvm/IR/TypeFinder.h"
#include "llvm/IR/ValueSymbolTable.h"
#include "llvm/Support/CFG.h"
+#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Dwarf.h"
#include "llvm/Support/ErrorHandling.h"
#include <cctype>
using namespace llvm;
+static cl::opt<bool>
+OldStyleAttrSyntax("enable-old-style-attr-syntax",
+ cl::desc("Output attributes on functions rather than in attribute groups"),
+ cl::Hidden,
+ cl::init(false));
+
// Make virtual table appear in this compilation unit.
AssemblyAnnotationWriter::~AssemblyAnnotationWriter() {}
return 0;
}
-static void PrintCallingConv(unsigned cc, raw_ostream &Out)
-{
+static void PrintCallingConv(unsigned cc, raw_ostream &Out) {
switch (cc) {
- case CallingConv::Fast: Out << "fastcc"; break;
- case CallingConv::Cold: Out << "coldcc"; break;
- case CallingConv::X86_StdCall: Out << "x86_stdcallcc"; break;
- case CallingConv::X86_FastCall: Out << "x86_fastcallcc"; break;
- case CallingConv::X86_ThisCall: Out << "x86_thiscallcc"; break;
- case CallingConv::Intel_OCL_BI: Out << "intel_ocl_bicc"; break;
- case CallingConv::ARM_APCS: Out << "arm_apcscc"; break;
- case CallingConv::ARM_AAPCS: Out << "arm_aapcscc"; break;
- case CallingConv::ARM_AAPCS_VFP:Out << "arm_aapcs_vfpcc"; break;
- case CallingConv::MSP430_INTR: Out << "msp430_intrcc"; break;
- case CallingConv::PTX_Kernel: Out << "ptx_kernel"; break;
- case CallingConv::PTX_Device: Out << "ptx_device"; break;
- default: Out << "cc" << cc; break;
+ default: Out << "cc" << cc; break;
+ case CallingConv::Fast: Out << "fastcc"; break;
+ case CallingConv::Cold: Out << "coldcc"; break;
+ case CallingConv::X86_StdCall: Out << "x86_stdcallcc"; break;
+ case CallingConv::X86_FastCall: Out << "x86_fastcallcc"; break;
+ case CallingConv::X86_ThisCall: Out << "x86_thiscallcc"; break;
+ case CallingConv::Intel_OCL_BI: Out << "intel_ocl_bicc"; break;
+ case CallingConv::ARM_APCS: Out << "arm_apcscc"; break;
+ case CallingConv::ARM_AAPCS: Out << "arm_aapcscc"; break;
+ case CallingConv::ARM_AAPCS_VFP: Out << "arm_aapcs_vfpcc"; break;
+ case CallingConv::MSP430_INTR: Out << "msp430_intrcc"; break;
+ case CallingConv::PTX_Kernel: Out << "ptx_kernel"; break;
+ case CallingConv::PTX_Device: Out << "ptx_device"; break;
}
}
CreateModuleSlot(I);
// Add all the function attributes to the table.
+ // FIXME: Add attributes of other objects?
AttributeSet FnAttrs = I->getAttributes().getFnAttributes();
if (FnAttrs.hasAttributes(AttributeSet::FunctionIndex))
CreateAttributeSetSlot(FnAttrs);
if (MDNode *N = dyn_cast_or_null<MDNode>(I->getOperand(i)))
CreateMetadataSlot(N);
- // Add all the call attributes to the table. This is important for
- // inline ASM, which may have attributes but no declaration.
- if (CI->isInlineAsm()) {
- AttributeSet Attrs = CI->getAttributes().getFnAttributes();
- if (Attrs.hasAttributes(AttributeSet::FunctionIndex))
- CreateAttributeSetSlot(Attrs);
- }
+ // Add all the call attributes to the table.
+ AttributeSet Attrs = CI->getAttributes().getFnAttributes();
+ if (Attrs.hasAttributes(AttributeSet::FunctionIndex))
+ CreateAttributeSetSlot(Attrs);
+ } else if (const InvokeInst *II = dyn_cast<InvokeInst>(I)) {
+ // Add all the call attributes to the table.
+ AttributeSet Attrs = II->getAttributes().getFnAttributes();
+ if (Attrs.hasAttributes(AttributeSet::FunctionIndex))
+ CreateAttributeSetSlot(Attrs);
}
// Process metadata attached with this instruction.
printFunction(I);
// Output all attribute groups.
- if (!Machine.as_empty()) {
+ if (!OldStyleAttrSyntax && !Machine.as_empty()) {
Out << '\n';
writeAllAttributeGroups();
}
if (F->isMaterializable())
Out << "; Materializable\n";
+ const AttributeSet &Attrs = F->getAttributes();
+ if (!OldStyleAttrSyntax && Attrs.hasAttributes(AttributeSet::FunctionIndex)) {
+ AttributeSet AS = Attrs.getFnAttributes();
+ std::string AttrStr = AS.getAsString(AttributeSet::FunctionIndex, true);
+ if (!AttrStr.empty())
+ Out << "; Function Attrs: " << AttrStr << '\n';
+ }
+
if (F->isDeclaration())
Out << "declare ";
else
}
FunctionType *FT = F->getFunctionType();
- const AttributeSet &Attrs = F->getAttributes();
if (Attrs.hasAttributes(AttributeSet::ReturnIndex))
Out << Attrs.getAsString(AttributeSet::ReturnIndex) << ' ';
TypePrinter.print(F->getReturnType(), Out);
Out << ')';
if (F->hasUnnamedAddr())
Out << " unnamed_addr";
- if (Attrs.hasAttributes(AttributeSet::FunctionIndex))
- Out << ' ' << Attrs.getAsString(AttributeSet::FunctionIndex);
+ if (!OldStyleAttrSyntax) {
+ if (Attrs.hasAttributes(AttributeSet::FunctionIndex))
+ Out << " #" << Machine.getAttributeGroupSlot(Attrs.getFnAttributes());
+ } else {
+ AttributeSet AS = Attrs.getFnAttributes();
+ std::string AttrStr = AS.getAsString(AttributeSet::FunctionIndex, true);
+ if (!AttrStr.empty())
+ Out << ' ' << AttrStr;
+ }
if (F->hasSection()) {
Out << " section \"";
PrintEscapedString(F->getSection(), Out);
/// 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..
}
Out << ')';
if (PAL.hasAttributes(AttributeSet::FunctionIndex))
- Out << ' ' << PAL.getAsString(AttributeSet::FunctionIndex);
+ Out << " #" << Machine.getAttributeGroupSlot(PAL.getFnAttributes());
} else if (const InvokeInst *II = dyn_cast<InvokeInst>(&I)) {
Operand = II->getCalledValue();
PointerType *PTy = cast<PointerType>(Operand->getType());
Out << ')';
if (PAL.hasAttributes(AttributeSet::FunctionIndex))
- Out << ' ' << PAL.getAsString(AttributeSet::FunctionIndex);
+ Out << " #" << Machine.getAttributeGroupSlot(PAL.getFnAttributes());
Out << "\n to ";
writeOperand(II->getNormalDest(), true);
return;
DIDescriptor Desc(Node);
- if (Desc.getVersion() < LLVMDebugVersion11)
+ if (!Desc.Verify())
return;
unsigned Tag = Desc.getTag();
for (std::vector<std::pair<AttributeSet, unsigned> >::iterator
I = asVec.begin(), E = asVec.end(); I != E; ++I)
Out << "attributes #" << I->second << " = { "
- << I->first.getAsString(AttributeSet::FunctionIndex, true) << " }\n";
+ << I->first.getAsString(AttributeSet::FunctionIndex, false, true)
+ << " }\n";
}
//===----------------------------------------------------------------------===//