Comments (2)
We have tests/codegen/debug-vtable.rs
making sure that the type is artificial, and I also see that your example has DIFlagArtificial
in the LLVM IR:
!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
!1 = distinct !DIGlobalVariable(name: "<std::rt::lang_start::{closure_env#0}<()> as core::ops::function::Fn<()>>::{vtable}", scope: null, file: !2, type: !3, isLocal: true, isDefinition: true)
!2 = !DIFile(filename: "<unknown>", directory: "")
!3 = !DICompositeType(tag: DW_TAG_structure_type, name: "<std::rt::lang_start::{closure_env#0}<()> as core::ops::function::Fn<()>>::{vtable_type}", file: !2, size: 384, align: 64, flags: DIFlagArtificial, elements: !4, vtableHolder: !14, templateParams: !23, identifier: "83627f9f9db11820e9b7128180480645")
But there's no sign of that in the output DWARF, neither on the variable nor its type:
<1><2a>: Abbrev Number: 2 (DW_TAG_variable)
<2b> DW_AT_name : (indirect string, offset: 0x7f): <std::rt::lang_start::{closure_env#0}<()> as core::ops::function::Fn<()>>::{vtable}
<2f> DW_AT_type : <0x3d>
<33> DW_AT_location : 9 byte block: 3 0 0 0 0 0 0 0 0 (DW_OP_addr: 0)
<1><3d>: Abbrev Number: 3 (DW_TAG_structure_type)
<3e> DW_AT_containing_type: <0xb5>
<42> DW_AT_name : (indirect string, offset: 0x14d): <std::rt::lang_start::{closure_env#0}<()> as core::ops::function::Fn<()>>::{vtable_type}
<46> DW_AT_byte_size : 48
<47> DW_AT_alignment : 8
from rust.
For regular variables, the flag is applied here, because that Var.isArtificial()
checks both the variable and the type. I don't see anything like that for global varables, so I tried adding this:
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -200,6 +200,9 @@ DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE(
else
addGlobalName(GV->getName(), *VariableDIE, DeclContext);
+ if (GTy && GTy->isArtificial())
+ addFlag(*VariableDIE, dwarf::DW_AT_artificial);
+
addAnnotation(*VariableDIE, GV->getAnnotations());
if (uint32_t AlignInBytes = GV->getAlignInBytes())
And now I do see it in DWARF:
<1><2a>: Abbrev Number: 2 (DW_TAG_variable)
<2b> DW_AT_name : (indirect string, offset: 0x63): <std::rt::lang_start::{closure_env#0}<()> as core::ops::function::Fn<()>>::{vtable}
<2f> DW_AT_type : <0x3d>
<33> DW_AT_artificial : 1
<33> DW_AT_location : 9 byte block: 3 0 0 0 0 0 0 0 0 (DW_OP_addr: 0)
I'll try an LLVM PR with this change soon.
from rust.
Related Issues (20)
- mimatched type when using a `let` binding with the same name as a struct HOT 2
- Tracking Issue for externally implementable items
- error: internal compiler error: ...: opaque types got hidden types registered from within subtype predicate
- `print-type-size` somtimes prints incorrect output HOT 1
- Compiling this code caused the compiler to block
- Segmentation fault installing rust on clean Ubuntu 24.04 amd64 HOT 4
- Poor interaction between NLL-borrowck, async, and c_variadic's `...` desugaring (`VaListImpl<'_>`)
- ICE : called `Option::unwrap()` on a `None` value in compiler/rustc_hir_typeck/src/method/confirm.rs HOT 2
- `&T -> *const T` or `&mut T -> *mut T` should be considered a use of inner fields HOT 2
- Remark `TMP`, `TEMP` and `USERPROFILE` env vars can influence `env::temp_dir` on Windows HOT 1
- Add SIMD operations that use f16 and f128 HOT 4
- Warn for `cfg!(target_* = "whatever")` usage in build scripts HOT 1
- UTF_16BE encode decode result does not match HOT 2
- Error when `fn` keyword is missing could be more explicit HOT 3
- How to enable rust-lld on stable? HOT 3
- Failure to recognize `&String` as equivalent to `&str` HOT 2
- need to show help for `adding an explicit lifetime bound`.
- ICE: `this path really should be doomed`
- Tracking issue for migrating from Glacier to compiletest ICE/crash tracking HOT 3
- `check_type_length_limit` is broken HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust.