[PATCH] D53596: [ThinLTO] Fix a crash in lazy loading of Metadata

Teresa Johnson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 23 11:46:34 PDT 2018


tejohnson created this revision.
tejohnson added reviewers: dexonsmith, Sunil_Srivastava, vsk.
Herald added subscribers: steven_wu, eraman, inglorion.
tejohnson updated this revision to Diff 170714.
tejohnson added a comment.

Added part of test case missed in first version of patch.


This is a revised version of https://reviews.llvm.org/D41474.

When the debug location is parsed in BitcodeReader::parseFunction, the
scope and inlinedAt MDNodes are obtained via MDLoader->getMDNodeFwdRefOrNull(),
which will create a forward ref if they were not yet loaded.
Specifically, if one of these MDNodes is in the module level metadata
block, and this is during ThinLTO importing, that metadata block is
lazily loaded.

Most places in that invoke getMDNodeFwdRefOrNull have a corresponding call
to resolveForwardRefsAndPlaceholders which will take care of resolving them.
E.g. places that call getMetadataFwdRefOrLoad, or at the end of parsing a
function-level metadata block, or at the end of the initial lazy load of
module level metadata in order to handle invocations of getMDNodeFwdRefOrNull
for named metadata and global object attachments. However, the calls for
the scope/inlinedAt of debug locations are not backed by any such call to
resolveForwardRefsAndPlaceholders.

To fix this, change the scope and inlinedAt parsing to instead use
getMetadataFwdRefOrLoad, which will ensure the forward refs to lazily
loaded metadata are resolved.

Fixes PR35472.


Repository:
  rL LLVM

https://reviews.llvm.org/D53596

Files:
  lib/Bitcode/Reader/BitcodeReader.cpp
  test/ThinLTO/X86/Inputs/pr35472.ll
  test/ThinLTO/X86/pr35472.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53596.170714.patch
Type: text/x-patch
Size: 7957 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181023/30f5e1a5/attachment.bin>


More information about the llvm-commits mailing list