[llvm-commits] Fix looking up MD names to not need a module.
Nick Lewycky
nlewycky at google.com
Mon Mar 1 20:00:40 PST 2010
On 28 February 2010 15:28, Erick Tryzelaar
<idadesub at users.sourceforge.net>wrote:
> Nicolas Lewycky asked me to send this in. It changes the AsmWriter to grab
> the
> mdkind names from the instruction's context instead of from the module,
> which
> may or may not exist. It look good?
>
This looks great. Please commit!
Nick
>
> -e
>
> ---
> lib/VMCore/AsmWriter.cpp | 22 ++++++++++++----------
> 1 files changed, 12 insertions(+), 10 deletions(-)
>
> diff --git lib/VMCore/AsmWriter.cpp lib/VMCore/AsmWriter.cpp
> index 361c58e..fd74241 100644
> --- lib/VMCore/AsmWriter.cpp
> +++ lib/VMCore/AsmWriter.cpp
> @@ -17,6 +17,7 @@
> #include "llvm/Assembly/Writer.h"
> #include "llvm/Assembly/PrintModulePass.h"
> #include "llvm/Assembly/AsmAnnotationWriter.h"
> +#include "llvm/LLVMContext.h"
> #include "llvm/CallingConv.h"
> #include "llvm/Constants.h"
> #include "llvm/DerivedTypes.h"
> @@ -1236,7 +1237,6 @@ class AssemblyWriter {
> TypePrinting TypePrinter;
> AssemblyAnnotationWriter *AnnotationWriter;
> std::vector<const Type*> NumberedTypes;
> - SmallVector<StringRef, 8> MDNames;
>
> public:
> inline AssemblyWriter(formatted_raw_ostream &o, SlotTracker &Mac,
> @@ -1244,8 +1244,6 @@ public:
> AssemblyAnnotationWriter *AAW)
> : Out(o), Machine(Mac), TheModule(M), AnnotationWriter(AAW) {
> AddModuleTypesToPrinter(TypePrinter, NumberedTypes, M);
> - if (M)
> - M->getMDKindNames(MDNames);
> }
>
> void printMDNodeBody(const MDNode *MD);
> @@ -1990,14 +1988,18 @@ void AssemblyWriter::printInstruction(const
> Instruction &I) {
> // Print Metadata info.
> SmallVector<std::pair<unsigned, MDNode*>, 4> InstMD;
> I.getAllMetadata(InstMD);
> - for (unsigned i = 0, e = InstMD.size(); i != e; ++i) {
> - unsigned Kind = InstMD[i].first;
> - if (Kind < MDNames.size()) {
> - Out << ", !" << MDNames[Kind];
> - } else {
> - Out << ", !<unknown kind #" << Kind << ">";
> + if (!InstMD.empty()) {
> + SmallVector<StringRef, 8> MDNames;
> + I.getType()->getContext().getMDKindNames(MDNames);
> + for (unsigned i = 0, e = InstMD.size(); i != e; ++i) {
> + unsigned Kind = InstMD[i].first;
> + if (Kind < MDNames.size()) {
> + Out << ", !" << MDNames[Kind];
> + } else {
> + Out << ", !<unknown kind #" << Kind << ">";
> + }
> + Out << " !" << Machine.getMetadataSlot(InstMD[i].second);
> }
> - Out << " !" << Machine.getMetadataSlot(InstMD[i].second);
> }
> printInfoComment(I);
> }
> --
> 1.7.0
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20100301/5aa36b4d/attachment.html>
More information about the llvm-commits
mailing list