diff options
author | Tom Tromey <tromey@adacore.com> | 2025-07-02 11:30:34 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-02 10:30:34 -0700 |
commit | cbfc10260cfeab7ede763bffad4c71d9ae20abd2 (patch) | |
tree | 4ef66fe155063a3b0c77d953978c68c8784880d6 /llvm/lib/Bitcode/Reader/MetadataLoader.cpp | |
parent | 50f40a5327ad9f8a4a57bb2bf7679f489f86b726 (diff) | |
download | llvm-cbfc10260cfeab7ede763bffad4c71d9ae20abd2.zip llvm-cbfc10260cfeab7ede763bffad4c71d9ae20abd2.tar.gz llvm-cbfc10260cfeab7ede763bffad4c71d9ae20abd2.tar.bz2 |
Fix lld crash caused by dynamic bit offset patch (#146701)
PR #141106 changed the debuginfo metdata to allow dynamic bit offsets
and sizes. This caused a crash in lld when using LTO.
The problem is that lazyLoadOneMetadata assumes that the metadata in
question can be cast to MDNode; but in the typical case where the offset
is a constant, this is not true.
This patch changes this spot to allow non-MDNodes through.
The included test case comes from the report in #141106.
Diffstat (limited to 'llvm/lib/Bitcode/Reader/MetadataLoader.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Reader/MetadataLoader.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp index a9467d1..d28ab7d 100644 --- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp +++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp @@ -1156,8 +1156,10 @@ void MetadataLoader::MetadataLoaderImpl::lazyLoadOneMetadata( assert(ID >= MDStringRef.size() && "Unexpected lazy-loading of MDString"); // Lookup first if the metadata hasn't already been loaded. if (auto *MD = MetadataList.lookup(ID)) { - auto *N = cast<MDNode>(MD); - if (!N->isTemporary()) + auto *N = dyn_cast<MDNode>(MD); + // If the node is not an MDNode, or if it is not temporary, then + // we're done. + if (!N || !N->isTemporary()) return; } SmallVector<uint64_t, 64> Record; |