[PATCH] D15798: Fix for Bug 24852 (crash with -debug -instcombine)

Keno Fischer via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 7 12:01:09 PST 2016


Even better!

On Thu, Jan 7, 2016 at 8:59 PM, Mehdi Amini <mehdi.amini at apple.com> wrote:

>
> > On Jan 7, 2016, at 11:55 AM, Keno Fischer <kfischer at college.harvard.edu>
> wrote:
> >
> > loladiro added a comment.
> >
> > Would the following be a better way to address this:
> >
> >  diff --git a/lib/IR/AsmWriter.cpp b/lib/IR/AsmWriter.cpp
> >  index 185db47..949b710 100644
> >  --- a/lib/IR/AsmWriter.cpp
> >  +++ b/lib/IR/AsmWriter.cpp
> >  @@ -2052,7 +2052,8 @@ private:
> >     /// \brief Print out metadata attachments.
> >     void printMetadataAttachments(
> >         const SmallVectorImpl<std::pair<unsigned, MDNode *>> &MDs,
> >  -      StringRef Separator);
> >  +      StringRef Separator,
> >  +      LLVMContext &Context);
> >
> >     // printInfoComment - Print a little comment after the instruction
> indicating
> >     // which slot it occupies.
> >  @@ -2627,7 +2628,7 @@ void AssemblyWriter::printFunction(const Function
> *F) {
> >
> >     SmallVector<std::pair<unsigned, MDNode *>, 4> MDs;
> >     F->getAllMetadata(MDs);
> >  -  printMetadataAttachments(MDs, " ");
> >  +  printMetadataAttachments(MDs, " ", F->getContext());
> >
> >     if (F->isDeclaration()) {
> >       Out << '\n';
> >  @@ -3111,7 +3112,7 @@ void AssemblyWriter::printInstruction(const
> Instruction &I) {
> >     // Print Metadata info.
> >     SmallVector<std::pair<unsigned, MDNode *>, 4> InstMD;
> >     I.getAllMetadata(InstMD);
> >  -  printMetadataAttachments(InstMD, ", ");
> >  +  printMetadataAttachments(InstMD, ", ", I.getType()->getContext());
> >
> >     // Print a nice comment.
> >     printInfoComment(I);
> >  @@ -3119,12 +3120,13 @@ void AssemblyWriter::printInstruction(const
> Instruction &I) {
> >
> >   void AssemblyWriter::printMetadataAttachments(
> >       const SmallVectorImpl<std::pair<unsigned, MDNode *>> &MDs,
> >  -    StringRef Separator) {
> >  +    StringRef Separator,
> >  +    LLVMContext &Context) {
> >     if (MDs.empty())
> >       return;
> >
> >     if (MDNames.empty())
> >  -    TheModule->getMDKindNames(MDNames);
> >  +    Context.getMDKindNames(MDNames);
>
>
> Instead of adding a parameter, you should be able to get the context this
> way as well:
>
> MDs[0].second->getContext()
>
>> Mehdi
>
>
>
>
> >
> >     for (const auto &I : MDs) {
> >       unsigned Kind = I.first;
> >
> > That way you'd still get the names in the printout.
> >
> >
> > http://reviews.llvm.org/D15798
> >
> >
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160107/c41f4b8f/attachment.html>


More information about the llvm-commits mailing list