summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/AsmWriter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/IR/AsmWriter.cpp')
-rw-r--r--llvm/lib/IR/AsmWriter.cpp44
1 files changed, 19 insertions, 25 deletions
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index e995a586b7c..50774a395b5 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -21,7 +21,6 @@
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/IR/AssemblyAnnotationWriter.h"
-#include "llvm/IR/AttributeSetNode.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/CallingConv.h"
@@ -606,7 +605,7 @@ private:
unsigned mdnNext;
/// asMap - The slot map for attribute sets.
- DenseMap<AttributeSetNode *, unsigned> asMap;
+ DenseMap<AttributeSet, unsigned> asMap;
unsigned asNext;
public:
/// Construct from a module.
@@ -629,7 +628,7 @@ public:
int getLocalSlot(const Value *V);
int getGlobalSlot(const GlobalValue *V);
int getMetadataSlot(const MDNode *N);
- int getAttributeGroupSlot(AttributeSetNode *AS);
+ int getAttributeGroupSlot(AttributeSet AS);
/// If you'd like to deal with a function instead of just a module, use
/// this method to get its data into the SlotTracker.
@@ -652,8 +651,8 @@ public:
unsigned mdn_size() const { return mdnMap.size(); }
bool mdn_empty() const { return mdnMap.empty(); }
- /// AttributeSetNode map iterators.
- typedef DenseMap<AttributeSetNode *, unsigned>::iterator as_iterator;
+ /// AttributeSet map iterators.
+ typedef DenseMap<AttributeSet, unsigned>::iterator as_iterator;
as_iterator as_begin() { return asMap.begin(); }
as_iterator as_end() { return asMap.end(); }
unsigned as_size() const { return asMap.size(); }
@@ -673,8 +672,8 @@ private:
/// CreateFunctionSlot - Insert the specified Value* into the slot table.
void CreateFunctionSlot(const Value *V);
- /// \brief Insert the specified AttributeSetNode into the slot table.
- void CreateAttributeSetSlot(AttributeSetNode *AS);
+ /// \brief Insert the specified AttributeSet into the slot table.
+ void CreateAttributeSetSlot(AttributeSet AS);
/// Add all of the module level global variables (and their initializers)
/// and function declarations, but not the contents of those functions.
@@ -833,8 +832,8 @@ void SlotTracker::processModule() {
// Add all the function attributes to the table.
// FIXME: Add attributes of other objects?
- AttributeSetNode *FnAttrs = F.getAttributes().getFnAttributes();
- if (FnAttrs)
+ AttributeSet FnAttrs = F.getAttributes().getFnAttributes();
+ if (FnAttrs.hasAttributes())
CreateAttributeSetSlot(FnAttrs);
}
@@ -869,15 +868,10 @@ void SlotTracker::processFunction() {
// We allow direct calls to any llvm.foo function here, because the
// target may not be linked into the optimizer.
- if (const CallInst *CI = dyn_cast<CallInst>(&I)) {
+ if (auto CS = ImmutableCallSite(&I)) {
// Add all the call attributes to the table.
- AttributeSetNode *Attrs = CI->getAttributes().getFnAttributes();
- if (Attrs)
- CreateAttributeSetSlot(Attrs);
- } else if (const InvokeInst *II = dyn_cast<InvokeInst>(&I)) {
- // Add all the call attributes to the table.
- AttributeSetNode *Attrs = II->getAttributes().getFnAttributes();
- if (Attrs)
+ AttributeSet Attrs = CS.getAttributes().getFnAttributes();
+ if (Attrs.hasAttributes())
CreateAttributeSetSlot(Attrs);
}
}
@@ -963,11 +957,11 @@ int SlotTracker::getLocalSlot(const Value *V) {
return FI == fMap.end() ? -1 : (int)FI->second;
}
-int SlotTracker::getAttributeGroupSlot(AttributeSetNode *AS) {
+int SlotTracker::getAttributeGroupSlot(AttributeSet AS) {
// Check for uninitialized state and do lazy initialization.
initialize();
- // Find the AttributeSetNode in the module map.
+ // Find the AttributeSet in the module map.
as_iterator AI = asMap.find(AS);
return AI == asMap.end() ? -1 : (int)AI->second;
}
@@ -1017,8 +1011,8 @@ void SlotTracker::CreateMetadataSlot(const MDNode *N) {
CreateMetadataSlot(Op);
}
-void SlotTracker::CreateAttributeSetSlot(AttributeSetNode *AS) {
- assert(AS && "Doesn't need a slot!");
+void SlotTracker::CreateAttributeSetSlot(AttributeSet AS) {
+ assert(AS.hasAttributes() && "Doesn't need a slot!");
as_iterator I = asMap.find(AS);
if (I != asMap.end())
@@ -2607,10 +2601,10 @@ void AssemblyWriter::printFunction(const Function *F) {
const AttributeList &Attrs = F->getAttributes();
if (Attrs.hasAttributes(AttributeList::FunctionIndex)) {
- AttributeSetNode *AS = Attrs.getFnAttributes();
+ AttributeSet AS = Attrs.getFnAttributes();
std::string AttrStr;
- for (const Attribute &Attr : *AS) {
+ for (const Attribute &Attr : AS) {
if (!Attr.isStringAttribute()) {
if (!AttrStr.empty()) AttrStr += ' ';
AttrStr += Attr.getAsString();
@@ -3250,7 +3244,7 @@ void AssemblyWriter::printMDNodeBody(const MDNode *Node) {
}
void AssemblyWriter::writeAllAttributeGroups() {
- std::vector<std::pair<AttributeSetNode *, unsigned>> asVec;
+ std::vector<std::pair<AttributeSet, unsigned>> asVec;
asVec.resize(Machine.as_size());
for (SlotTracker::as_iterator I = Machine.as_begin(), E = Machine.as_end();
@@ -3259,7 +3253,7 @@ void AssemblyWriter::writeAllAttributeGroups() {
for (const auto &I : asVec)
Out << "attributes #" << I.second << " = { "
- << I.first->getAsString(true) << " }\n";
+ << I.first.getAsString(true) << " }\n";
}
void AssemblyWriter::printUseListOrder(const UseListOrder &Order) {
OpenPOWER on IntegriCloud