[PATCH] D15798: Fix for Bug 24852 (crash with -debug -instcombine)
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 7 11:59:32 PST 2016
> 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
>
>
>
More information about the llvm-commits
mailing list