-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
fix: get llvm type of global val #128820
fix: get llvm type of global val #128820
Conversation
This comment has been minimized.
This comment has been minimized.
cc @rust-lang/wg-llvm |
Could you add a test to show your change? |
I don't know how to make a test to show this change. this bug does not cause any compilation issues and they produce correct llvm ir . |
@@ -390,7 +390,7 @@ impl<'ll> CodegenCx<'ll, '_> { | |||
let val_llty = self.val_ty(v); | |||
|
|||
let g = self.get_static_inner(def_id, val_llty); | |||
let llty = self.val_ty(g); | |||
let llty = llvm::LLVMGlobalGetValueType(g); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please also adjust the self.val_ty(g) != self.type_ptr()
check above? That one is also supposed to read LLVMGlobalGetValueType(g) != llty
I believe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm... i found the initializer type is always a packed struct
(val_llty) at now. which can never be equal to the llty
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we use cx.const_struct(&llvals, true)
to create a packed const struct at const_alloc_to_llvm
. can we create a normal struct for static initializer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm... i found the initializer type is always a
packed struct
(val_ty) at now. which can never be equal to thellty
.
But isn't this also the type we pass as llty? It's the type of the initializer v
above, which should also be a packed struct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the llty
is the type of old global var, which is set at predefine_static
. and the val_llty
is the type of initializer v
.
the llty won't be a packed struct
r? nikic |
@bors r+ rollup |
fix: get llvm type of global val using `LLVMTypeOf` on a global var always return ptr. so create a new function to access the value type of a global
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#128820 (fix: get llvm type of global val) - rust-lang#129028 (`impl_trait_overcaptures`: Don't worry about uncaptured contravariant lifetimes if they outlive a captured lifetime) - rust-lang#129471 ([rustdoc] Sort impl associated items by kinds and then by appearance) - rust-lang#129706 (Rename dump of coroutine by-move-body to be more consistent, fix ICE in dump_mir) - rust-lang#129720 (Simplify DestProp memory management) - rust-lang#129796 (Unify scraped examples with other code examples) - rust-lang#129938 (Elaborate on deriving vs implementing `Copy`) - rust-lang#129973 (run_make_support: rename `Command::stdin` to `stdin_buf` and add `std{in,out,err}` config helpers) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#128820 (fix: get llvm type of global val) - rust-lang#129028 (`impl_trait_overcaptures`: Don't worry about uncaptured contravariant lifetimes if they outlive a captured lifetime) - rust-lang#129471 ([rustdoc] Sort impl associated items by kinds and then by appearance) - rust-lang#129706 (Rename dump of coroutine by-move-body to be more consistent, fix ICE in dump_mir) - rust-lang#129720 (Simplify DestProp memory management) - rust-lang#129796 (Unify scraped examples with other code examples) - rust-lang#129938 (Elaborate on deriving vs implementing `Copy`) - rust-lang#129973 (run_make_support: rename `Command::stdin` to `stdin_buf` and add `std{in,out,err}` config helpers) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#128820 - LYF1999:yf/dev, r=nikic fix: get llvm type of global val using `LLVMTypeOf` on a global var always return ptr. so create a new function to access the value type of a global
using
LLVMTypeOf
on a global var always return ptr. so create a new function to access the value type of a global