Skip to content

[llvm][MetadataLoader] Make sure we correctly load DW_APPLE_ENUM_KIND from bitcode #132374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 22, 2025

Conversation

Michael137
Copy link
Member

@Michael137 Michael137 commented Mar 21, 2025

This was pointed out in #124752 (comment)

There was no test that roundtrips this attribute through LLVM bitcode, so this was never caught.

… from bitcode

This was pointed out in
llvm#124752 (comment)

There was not test that roundtrips this attribute through LLVM bitcode, so this was never caught.
@llvmbot
Copy link
Member

llvmbot commented Mar 21, 2025

@llvm/pr-subscribers-debuginfo

Author: Michael Buch (Michael137)

Changes

This was pointed out in
#124752 (comment)

There was not test that roundtrips this attribute through LLVM bitcode, so this was never caught.


Full diff: https://github.com/llvm/llvm-project/pull/132374.diff

2 Files Affected:

  • (modified) llvm/lib/Bitcode/Reader/MetadataLoader.cpp (+2-2)
  • (modified) llvm/test/DebugInfo/AArch64/DW_AT_APPLE_enum_kind.ll (+3-2)
diff --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
index 1baf0a9214e00..12794d3346e3f 100644
--- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
+++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
@@ -1704,8 +1704,8 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
       }
     }
 
-    if (Record.size() > 25 && Record[25] != dwarf::DW_APPLE_ENUM_KIND_invalid)
-      EnumKind = Record[25];
+    if (Record.size() > 24 && Record[24] != dwarf::DW_APPLE_ENUM_KIND_invalid)
+      EnumKind = Record[24];
 
     DICompositeType *CT = nullptr;
     if (Identifier)
diff --git a/llvm/test/DebugInfo/AArch64/DW_AT_APPLE_enum_kind.ll b/llvm/test/DebugInfo/AArch64/DW_AT_APPLE_enum_kind.ll
index 399d80c778072..4f219a7e7b12e 100644
--- a/llvm/test/DebugInfo/AArch64/DW_AT_APPLE_enum_kind.ll
+++ b/llvm/test/DebugInfo/AArch64/DW_AT_APPLE_enum_kind.ll
@@ -1,5 +1,6 @@
-; RUN: llc < %s -filetype=obj -o %t
-; RUN: llvm-dwarfdump -v %t | FileCheck %s
+; RUN: clang++ %s -c -g -emit-llvm -o %t.bc
+; RUN: llc %t.bc -filetype=obj -o %t.o
+; RUN: llvm-dwarfdump -v %t.o | FileCheck %s
 
 ; C++ source to regenerate:
 ; enum __attribute__((enum_extensibility(open))) OpenEnum {

@Michael137
Copy link
Member Author

@MaskRay are these failures related to your recent refactorings? If so, could you revert?

FAILED: lib/Target/RISCV/AsmParser/CMakeFiles/LLVMRISCVAsmParser.dir/RISCVAsmParser.cpp.o
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/clang++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-5b8n6-1/llvm-project/github-pull-requests/build/lib/Target/RISCV/AsmParser -I/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-5b8n6-1/llvm-project/github-pull-requests/llvm/lib/Target/RISCV/AsmParser -I/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-5b8n6-1/llvm-project/github-pull-requests/llvm/lib/Target/RISCV -I/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-5b8n6-1/llvm-project/github-pull-requests/build/lib/Target/RISCV -I/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-5b8n6-1/llvm-project/github-pull-requests/build/include -I/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-5b8n6-1/llvm-project/github-pull-requests/llvm/include -gmlt -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -fvisibility=hidden  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++17 -MD -MT lib/Target/RISCV/AsmParser/CMakeFiles/LLVMRISCVAsmParser.dir/RISCVAsmParser.cpp.o -MF lib/Target/RISCV/AsmParser/CMakeFiles/LLVMRISCVAsmParser.dir/RISCVAsmParser.cpp.o.d -o lib/Target/RISCV/AsmParser/CMakeFiles/LLVMRISCVAsmParser.dir/RISCVAsmParser.cpp.o -c /var/lib/buildkite-agent/builds/linux-56-59b8f5d88-5b8n6-1/llvm-project/github-pull-requests/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-5b8n6-1/llvm-project/github-pull-requests/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:826:48: error: no member named 'VK_RISCV_None' in 'llvm::RISCVMCExpr'
    RISCVMCExpr::VariantKind VK = RISCVMCExpr::VK_RISCV_None;
                                  ~~~~~~~~~~~~~^
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-5b8n6-1/llvm-project/github-pull-requests/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:831:31: error: no member named 'VK_RISCV_None' in 'llvm::RISCVMCExpr'
           VK == RISCVMCExpr::VK_RISCV_None;
                 ~~~~~~~~~~~~~^

@tromey
Copy link
Contributor

tromey commented Mar 21, 2025

FWIW this patch looks good to me.

@@ -1,5 +1,6 @@
; RUN: llc < %s -filetype=obj -o %t
; RUN: llvm-dwarfdump -v %t | FileCheck %s
; RUN: clang++ %s -c -g -emit-llvm -o %t.bc
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an LLVM test can't/shouldn't depend on clang. Can you check in the bitcode file instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good
Instead of checking in bitcode i roundtrip this file through llvm-dis/llvm-as instead. Which tests the same codepath

@@ -1,5 +1,7 @@
; RUN: llc < %s -filetype=obj -o %t
; RUN: llvm-dwarfdump -v %t | FileCheck %s
;
; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s --check-prefix=CHECK-METADATA
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you hoist the round-trip part into tests/IR or BitCode?

@Michael137 Michael137 merged commit a27da0a into llvm:main Mar 22, 2025
11 checks passed
@Michael137 Michael137 deleted the llvm/enum-kind-bitcode branch March 22, 2025 08:09
@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 22, 2025

LLVM Buildbot has detected a new failure on builder lldb-aarch64-ubuntu running on linaro-lldb-aarch64-ubuntu while building llvm at step 6 "test".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/59/builds/14740

Here is the relevant piece of the build log for the reference
Step 6 (test) failure: build (failure)
...
UNSUPPORTED: lldb-api :: functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSURL.py (349 of 2109)
UNSUPPORTED: lldb-api :: functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCPlain.py (350 of 2109)
UNSUPPORTED: lldb-api :: functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjNSException.py (351 of 2109)
UNSUPPORTED: lldb-api :: functionalities/data-formatter/data-formatter-objc/cmtime/TestDataFormatterCMTime.py (352 of 2109)
UNSUPPORTED: lldb-api :: functionalities/data-formatter/data-formatter-objc/nsindexpath/TestDataFormatterNSIndexPath.py (353 of 2109)
UNSUPPORTED: lldb-api :: functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py (354 of 2109)
UNSUPPORTED: lldb-api :: functionalities/data-formatter/data-formatter-proper-plurals/TestFormattersOneIsSingular.py (355 of 2109)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-ptr-to-array/TestPtrToArrayFormatting.py (356 of 2109)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-script/TestDataFormatterScript.py (357 of 2109)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-smart-array/TestDataFormatterSmartArray.py (358 of 2109)
FAIL: lldb-api :: functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py (359 of 2109)
******************** TEST 'lldb-api :: functionalities/data-formatter/data-formatter-skip-summary/TestDataFormatterSkipSummary.py' FAILED ********************
Script:
--
/usr/bin/python3.10 /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --env LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include --env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --arch aarch64 --build-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex --lldb-module-cache-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/lldb --compiler /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/clang --dsymutil /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/dsymutil --make /usr/bin/gmake --llvm-tools-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --lldb-obj-root /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb --lldb-libs-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-skip-summary -p TestDataFormatterSkipSummary.py
--
Exit Code: -11

Command Output (stdout):
--
lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision a27da0a20cbfb9f0c600d53bf2520f068b222f59)
  clang revision a27da0a20cbfb9f0c600d53bf2520f068b222f59
  llvm revision a27da0a20cbfb9f0c600d53bf2520f068b222f59
Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 'debugserver', 'objc']

--
Command Output (stderr):
--
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_with_run_command_dsym (TestDataFormatterSkipSummary.SkipSummaryDataFormatterTestCase) (test case does not fall in any category of interest for this run) 
PASS: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_with_run_command_dwarf (TestDataFormatterSkipSummary.SkipSummaryDataFormatterTestCase)
PASS: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_with_run_command_dwo (TestDataFormatterSkipSummary.SkipSummaryDataFormatterTestCase)
----------------------------------------------------------------------
Ran 3 tests in 0.987s

OK (skipped=1)

--

********************
PASS: lldb-api :: functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py (360 of 2109)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-stl/generic/coroutine_handle/TestCoroutineHandle.py (361 of 2109)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-stl/generic/list/loop/TestDataFormatterGenericListLoop.py (362 of 2109)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py (363 of 2109)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-stl/generic/deque/TestDataFormatterGenericDeque.py (364 of 2109)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-stl/generic/list/TestDataFormatterGenericList.py (365 of 2109)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-stl/generic/multimap/TestDataFormatterGenericMultiMap.py (366 of 2109)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-stl/generic/optional/TestDataFormatterGenericOptional.py (367 of 2109)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py (368 of 2109)
PASS: lldb-api :: functionalities/data-formatter/data-formatter-stl/libcxx-simulators/optional/TestDataFormatterLibcxxOptionalSimulator.py (369 of 2109)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants