[llvm-commits] [dragonegg] r154768 - in /dragonegg/trunk/src: Aliasing.cpp Convert.cpp
Duncan Sands
baldrick at free.fr
Sun Apr 15 11:05:34 PDT 2012
Author: baldrick
Date: Sun Apr 15 13:05:34 2012
New Revision: 154768
URL: http://llvm.org/viewvc/llvm-project?rev=154768&view=rev
Log:
Use MDBuilder to help with metadata creation.
Modified:
dragonegg/trunk/src/Aliasing.cpp
dragonegg/trunk/src/Convert.cpp
Modified: dragonegg/trunk/src/Aliasing.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Aliasing.cpp?rev=154768&r1=154767&r2=154768&view=diff
==============================================================================
--- dragonegg/trunk/src/Aliasing.cpp (original)
+++ dragonegg/trunk/src/Aliasing.cpp Sun Apr 15 13:05:34 2012
@@ -27,8 +27,7 @@
// LLVM headers
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Twine.h"
-#include "llvm/LLVMContext.h"
-#include "llvm/Metadata.h"
+#include "llvm/Support/MDBuilder.h"
// System headers
#include <gmp.h>
@@ -61,17 +60,9 @@
// Create the root node. This must be unique to the compilation unit since
// the names of the nodes we hang off it have no intrinsic meaning: nodes
// from different compilation units must not be merged even if they have the
- // same name. To ensure uniqueness the root node is made self-referential.
- MDNode *Dummy = MDNode::getTemporary(Context, ArrayRef<Value*>());
- Root = MDNode::get(Context, Dummy);
- // At this point we have
- // !0 = metadata !{} <- dummy
- // !1 = metadata !{metadata !0} <- root
- // Replace the dummy operand with the root node itself and delete the dummy.
- Root->replaceOperandWith(0, Root);
- MDNode::deleteTemporary(Dummy);
- // We now have
- // !1 = metadata !{metadata !1} <- self-referential root
+ // same name.
+ MDBuilder MDHelper(Context);
+ Root = MDHelper.CreateAnonymousTBAARoot();
}
return Root;
}
@@ -148,8 +139,9 @@
tree type = TYPE_CANONICAL(TYPE_MAIN_VARIANT(TYPE_P(t) ? t : TREE_TYPE(t)));
std::string TreeName = ("alias set " + Twine(alias_set) + ": " +
getDescriptiveName(type)).str();
- Value *Ops[2] = { MDString::get(Context, TreeName), getTBAARoot() };
- MDNode *AliasTag = MDNode::get(Context, Ops);
+ MDBuilder MDHelper(Context);
+
+ MDNode *AliasTag = MDHelper.CreateTBAANode(TreeName, getTBAARoot());
NodeTags[alias_set] = AliasTag;
LeafNodes.push_back(alias_set);
return AliasTag;
Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=154768&r1=154767&r2=154768&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Sun Apr 15 13:05:34 2012
@@ -31,6 +31,7 @@
#include "llvm/Module.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/MDBuilder.h"
#include "llvm/Target/TargetLowering.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
@@ -319,14 +320,8 @@
// Unlike GCC's, LLVM ranges do not include the upper end point.
++Hi;
- // If the range is everything then it is useless.
- if (Hi == Lo)
- return 0;
-
- // Return the range [Lo, Hi).
- Type *Ty = IntegerType::get(Context, BitWidth);
- Value *Range[2] = { ConstantInt::get(Ty, Lo), ConstantInt::get(Ty, Hi) };
- return MDNode::get(Context, Range);
+ MDBuilder MDHelper(Context);
+ return MDHelper.CreateRange(Lo, Hi);
}
/// isDirectMemoryAccessSafe - Whether directly storing/loading a value of the
More information about the llvm-commits
mailing list