[llvm] Add debuginfo C support for a SetType, Subrangetype, dynamic array type and replace arrays (PR #135607)
David Spickett via llvm-commits
llvm-commits at lists.llvm.org
Wed May 7 01:58:46 PDT 2025
DavidSpickett wrote:
I can reproduce the failure locally with cmake config:
```
cmake -G Ninja ../llvm/llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=True '-DLLVM_ENABLE_PROJECTS=llvm;clang-tools-extra;clang'
```
```
$ ./bin/llvm-lit ../llvm-project/llvm/test/Bindings/llvm-c/debug_info_new_format.ll -a
-- Testing: 1 tests, 1 workers --
FAIL: LLVM :: Bindings/llvm-c/debug_info_new_format.ll (1 of 1)
******************** TEST 'LLVM :: Bindings/llvm-c/debug_info_new_format.ll' FAILED ********************
Exit Code: 2
Command Output (stderr):
--
/home/david.spickett/build-llvm-aarch64/bin/llvm-c-test --test-dibuilder | /home/david.spickett/build-llvm-aarch64/bin/FileCheck /home/david.spickett/llvm-project/llvm/test/Bindings/llvm-c/debug_info_new_format.ll # RUN: at line 1
+ /home/david.spickett/build-llvm-aarch64/bin/llvm-c-test --test-dibuilder
+ /home/david.spickett/build-llvm-aarch64/bin/FileCheck /home/david.spickett/llvm-project/llvm/test/Bindings/llvm-c/debug_info_new_format.ll
llvm-c-test: /home/david.spickett/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From *) [To = llvm::DIExpression, From = llvm::Metadata]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
FileCheck error: '<stdin>' is empty.
FileCheck command line: /home/david.spickett/build-llvm-aarch64/bin/FileCheck /home/david.spickett/llvm-project/llvm/test/Bindings/llvm-c/debug_info_new_format.ll
--
********************
********************
Failed Tests (1):
LLVM :: Bindings/llvm-c/debug_info_new_format.ll
```
If you use a debug build (`-DCMAKE_BUILD_TYPE=Release`) you can get more information about what it attempted to do:
```
$ gdb -args /home/david.spickett/build-llvm-aarch64/bin/llvm-c-test --test-dibuilder
```
This is the backtrace:
```
(gdb) bt
#0 __pthread_kill_implementation (threadid=281474842230816, signo=signo at entry=6, no_tid=no_tid at entry=0) at ./nptl/pthread_kill.c:44
#1 0x0000fffff7b5f244 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78
#2 0x0000fffff7b1a67c in __GI_raise (sig=sig at entry=6) at ../sysdeps/posix/raise.c:26
#3 0x0000fffff7b07130 in __GI_abort () at ./stdlib/abort.c:79
#4 0x0000fffff7b13fd4 in __assert_fail_base (fmt=0xfffff7c2c550 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",
assertion=assertion at entry=0xaaaaab7292dd "isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"",
file=file at entry=0xaaaaab8b84b7 "/home/david.spickett/llvm-project/llvm/include/llvm/Support/Casting.h", line=line at entry=578,
function=function at entry=0xaaaaabc61c28 "decltype(auto) llvm::cast(From *) [To = llvm::DIExpression, From = llvm::Metadata]") at ./assert/assert.c:94
#5 0x0000fffff7b1404c in __GI___assert_fail (assertion=0xaaaaab7292dd "isa<To>(Val) && \"cast<Ty>() argument of incompatible type!\"",
file=0xaaaaab8b84b7 "/home/david.spickett/llvm-project/llvm/include/llvm/Support/Casting.h", line=578,
function=0xaaaaabc61c28 "decltype(auto) llvm::cast(From *) [To = llvm::DIExpression, From = llvm::Metadata]") at ./assert/assert.c:103
#6 0x0000aaaab08f9684 in llvm::cast<llvm::DIExpression, llvm::Metadata> (Val=0xaaaab6a154a0) at /home/david.spickett/llvm-project/llvm/include/llvm/Support/Casting.h:578
#7 0x0000aaaab2c4e9c4 in llvm::unwrap<llvm::DIExpression> (P=0xaaaab6a154a0) at /home/david.spickett/llvm-project/llvm/include/llvm/IR/Metadata.h:148
#8 0x0000aaaab2c442c0 in LLVMDIBuilderCreateSubrangeType (Builder=0xaaaab69d3860, Scope=0xaaaab6a10660, Name=0xaaaaab308484 "foo", NameLen=3, LineNo=42, File=0xaaaab6a10660, SizeInBits=64, AlignInBits=0,
Flags=LLVMDIFlagZero, BaseTy=0xaaaab6a12928, LowerBound=0xaaaab6a154a0, UpperBound=0xaaaab6a19510, Stride=0x0, Bias=0x0) at /home/david.spickett/llvm-project/llvm/lib/IR/DebugInfo.cpp:1342
#9 0x0000aaaab01c16b4 in llvm_test_dibuilder () at /home/david.spickett/llvm-project/llvm/tools/llvm-c-test/debuginfo.c:240
#10 0x0000aaaab01cd0e0 in main (argc=2, argv=0xfffffffff238) at /home/david.spickett/llvm-project/llvm/tools/llvm-c-test/main.c:113
```
The To and From types:
```
(gdb) p Val
$5 = (llvm::Metadata *) 0xaaaab6a154a0
(gdb) ptype From
type = class llvm::Metadata {
<...>
(gdb) ptype To
type = class llvm::DIExpression : public llvm::MDNode {
private:
std::vector<unsigned long> Elements;
<...>
```
The cast is actually requested by this wrapper macro:
```
│ 147 // Create wrappers for C Binding types (see CBindingWrapping.h).
│ > 148 DEFINE_ISA_CONVERSION_FUNCTIONS(Metadata, LLVMMetadataRef)
```
And I have no idea what that's doing or why, but there are some ways you can investigate at least.
Before merging you will least one approval before this can be merged. Perhaps @OCHyams has the time to review, but if not, someone from @llvm/pr-subscribers-debug-info will do so.
https://github.com/llvm/llvm-project/pull/135607
More information about the llvm-commits
mailing list