-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Add alignment to constant globals #50738
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
Changes from 1 commit
ad4091d
bef5737
3bcc901
fda2a31
c2fb4e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -1776,7 +1776,7 @@ static jl_cgval_t emit_new_struct(jl_codectx_t &ctx, jl_value_t *ty, size_t narg | |||||||
| static jl_cgval_t emit_invoke(jl_codectx_t &ctx, const jl_cgval_t &lival, const jl_cgval_t *argv, size_t nargs, jl_value_t *rt); | ||||||||
|
|
||||||||
| static Value *literal_pointer_val(jl_codectx_t &ctx, jl_value_t *p); | ||||||||
| static GlobalVariable *prepare_global_in(Module *M, GlobalVariable *G); | ||||||||
| static unsigned julia_alignment(jl_value_t *jt); | ||||||||
|
|
||||||||
| static GlobalVariable *prepare_global_in(Module *M, JuliaVariable *G) | ||||||||
| { | ||||||||
|
|
@@ -1811,7 +1811,7 @@ static inline GlobalVariable *prepare_global_in(Module *M, GlobalVariable *G) | |||||||
|
|
||||||||
| // --- convenience functions for tagging llvm values with julia types --- | ||||||||
|
|
||||||||
| static GlobalVariable *get_pointer_to_constant(jl_codegen_params_t &emission_context, Constant *val, const Twine &name, Module &M) | ||||||||
| static GlobalVariable *get_pointer_to_constant(jl_codegen_params_t &emission_context, Constant *val, Align align, const Twine &name, Module &M) | ||||||||
| { | ||||||||
| GlobalVariable *&gv = emission_context.mergedConstants[val]; | ||||||||
| auto get_gv = [&](const Twine &name) { | ||||||||
|
|
@@ -1823,6 +1823,7 @@ static GlobalVariable *get_pointer_to_constant(jl_codegen_params_t &emission_con | |||||||
| val, | ||||||||
| name); | ||||||||
| gv->setUnnamedAddr(GlobalValue::UnnamedAddr::Global); | ||||||||
| gv->setAlignment(align); | ||||||||
| return gv; | ||||||||
| }; | ||||||||
| if (gv == nullptr) { | ||||||||
|
|
@@ -1943,7 +1944,7 @@ static inline jl_cgval_t value_to_pointer(jl_codectx_t &ctx, Value *v, jl_value_ | |||||||
| { | ||||||||
| Value *loc; | ||||||||
| if (valid_as_globalinit(v)) { // llvm can't handle all the things that could be inside a ConstantExpr | ||||||||
| loc = get_pointer_to_constant(ctx.emission_context, cast<Constant>(v), "_j_const", *jl_Module); | ||||||||
| loc = get_pointer_to_constant(ctx.emission_context, cast<Constant>(v), Align(jl_is_datatype(typ) && jl_struct_try_layout((jl_datatype_t*)typ) ? julia_alignment(typ) : JL_HEAP_ALIGNMENT), "_j_const", *jl_Module); | ||||||||
|
||||||||
| loc = get_pointer_to_constant(ctx.emission_context, cast<Constant>(v), Align(jl_is_datatype(typ) && jl_struct_try_layout((jl_datatype_t*)typ) ? julia_alignment(typ) : JL_HEAP_ALIGNMENT), "_j_const", *jl_Module); | |
| assert(jl_is_concrete_type(typ)); // not legal to have an unboxed abstract type | |
| loc = get_pointer_to_constant(ctx.emission_context, cast<Constant>(v), Align(julia_alignment(typ)), "_j_const", *jl_Module); |
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.
This assertion isn't holding, is it actually valid?
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 assert is right, but the callee now is not right anymore. You need to switch to using the copy-constructor, so the type is correct (the tindex argument to value_to_pointer is no longer legal as a means of folding this together):
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 5b0bf1bc98..11fa7474ba 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -2317,7 +2317,7 @@ static jl_cgval_t convert_julia_type(jl_codectx_t &ctx, const jl_cgval_t &v, jl_
new_tindex = ConstantInt::get(getInt8Ty(ctx.builder.getContext()), new_idx);
if (v.V && !v.ispointer()) {
// TODO: remove this branch once all consumers of v.TIndex understand how to handle a non-ispointer value
- return value_to_pointer(ctx, v.V, typ, new_tindex);
+ return jl_cgval_t(value_to_pointer(ctx, v.V, v.typ), typ, new_tindex);
}
}
else if (jl_subtype(v.typ, typ)) {
(fwiw, the TODO there is about places like this needing to be fixed to use the max-align from jl_islayout_inline instead when deciding how to spill it)
Uh oh!
There was an error while loading. Please reload this page.