summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/AsmWriter.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2016-05-31 23:01:54 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2016-05-31 23:01:54 +0000
commitcceae7feda8e33194d1a6c5963bd4114bb8d2b36 (patch)
treed7f155b4ea8004651b1aadf412465b0d3950f9e6 /llvm/lib/IR/AsmWriter.cpp
parent81fbadb63f4d28f62950e2e2c4967f1429b3ca55 (diff)
downloadbcm5719-llvm-cceae7feda8e33194d1a6c5963bd4114bb8d2b36.tar.gz
bcm5719-llvm-cceae7feda8e33194d1a6c5963bd4114bb8d2b36.zip
Add support for metadata attachments for global variables.
This patch adds an IR, assembly and bitcode representation for metadata attachments for globals. Future patches will port existing features to use these new attachments. Differential Revision: http://reviews.llvm.org/D20074 llvm-svn: 271348
Diffstat (limited to 'llvm/lib/IR/AsmWriter.cpp')
-rw-r--r--llvm/lib/IR/AsmWriter.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index ec975c77c96..c5002dc8c2f 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -681,6 +681,9 @@ private:
/// Add all of the functions arguments, basic blocks, and instructions.
void processFunction();
+ /// Add the metadata directly attached to a GlobalObject.
+ void processGlobalObjectMetadata(const GlobalObject &GO);
+
/// Add all of the metadata from a function.
void processFunctionMetadata(const Function &F);
@@ -799,6 +802,7 @@ void SlotTracker::processModule() {
for (const GlobalVariable &Var : TheModule->globals()) {
if (!Var.hasName())
CreateModuleSlot(&Var);
+ processGlobalObjectMetadata(Var);
}
for (const GlobalAlias &A : TheModule->aliases()) {
@@ -882,12 +886,15 @@ void SlotTracker::processFunction() {
ST_DEBUG("end processFunction!\n");
}
-void SlotTracker::processFunctionMetadata(const Function &F) {
+void SlotTracker::processGlobalObjectMetadata(const GlobalObject &GO) {
SmallVector<std::pair<unsigned, MDNode *>, 4> MDs;
- F.getAllMetadata(MDs);
+ GO.getAllMetadata(MDs);
for (auto &MD : MDs)
CreateMetadataSlot(MD.second);
+}
+void SlotTracker::processFunctionMetadata(const Function &F) {
+ processGlobalObjectMetadata(F);
for (auto &BB : F) {
for (auto &I : BB)
processInstructionMetadata(I);
@@ -2473,6 +2480,10 @@ void AssemblyWriter::printGlobal(const GlobalVariable *GV) {
if (GV->getAlignment())
Out << ", align " << GV->getAlignment();
+ SmallVector<std::pair<unsigned, MDNode *>, 4> MDs;
+ GV->getAllMetadata(MDs);
+ printMetadataAttachments(MDs, ", ");
+
printInfoComment(*GV);
}
OpenPOWER on IntegriCloud