Skip to content

Commit 9d59ecc

Browse files
authored
When accessing the data pointer for an array, first decay it to a Derived Pointer (#54335)
Fixes #54266, I've not yet minimized something to put into a test but in any case we can add the large test since it executes quite quickly. This also enables IR verification with `Strong=true` when building with assertions, this would've caught this bug much earlier.
1 parent 2d87ce3 commit 9d59ecc

File tree

4 files changed

+50
-51
lines changed

4 files changed

+50
-51
lines changed

src/cgutils.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3053,6 +3053,7 @@ static Value *emit_genericmemoryptr(jl_codectx_t &ctx, Value *mem, const jl_data
30533053
PointerType *PT = cast<PointerType>(mem->getType());
30543054
assert(PT == ctx.types().T_prjlvalue);
30553055
Value *addr = emit_bitcast(ctx, mem, ctx.types().T_jlgenericmemory->getPointerTo(PT->getAddressSpace()));
3056+
addr = decay_derived(ctx, addr);
30563057
addr = ctx.builder.CreateStructGEP(ctx.types().T_jlgenericmemory, addr, 1);
30573058
setName(ctx.emission_context, addr, ".data_ptr");
30583059
PointerType *PPT = cast<PointerType>(ctx.types().T_jlgenericmemory->getElementType(1));

src/clangsa/GCChecker.cpp

Lines changed: 43 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -795,57 +795,54 @@ static bool isMutexUnlock(StringRef name) {
795795
false;
796796
}
797797

798-
#if LLVM_VERSION_MAJOR >= 13
799-
#define endswith_lower endswith_insensitive
800-
#endif
801798

802799
bool GCChecker::isGCTrackedType(QualType QT) {
803800
return isJuliaType(
804801
[](StringRef Name) {
805-
if (Name.endswith_lower("jl_value_t") ||
806-
Name.endswith_lower("jl_svec_t") ||
807-
Name.endswith_lower("jl_sym_t") ||
808-
Name.endswith_lower("jl_expr_t") ||
809-
Name.endswith_lower("jl_code_info_t") ||
810-
Name.endswith_lower("jl_array_t") ||
811-
Name.endswith_lower("jl_genericmemory_t") ||
812-
//Name.endswith_lower("jl_genericmemoryref_t") ||
813-
Name.endswith_lower("jl_method_t") ||
814-
Name.endswith_lower("jl_method_instance_t") ||
815-
Name.endswith_lower("jl_debuginfo_t") ||
816-
Name.endswith_lower("jl_tupletype_t") ||
817-
Name.endswith_lower("jl_datatype_t") ||
818-
Name.endswith_lower("jl_typemap_entry_t") ||
819-
Name.endswith_lower("jl_typemap_level_t") ||
820-
Name.endswith_lower("jl_typename_t") ||
821-
Name.endswith_lower("jl_module_t") ||
822-
Name.endswith_lower("jl_tupletype_t") ||
823-
Name.endswith_lower("jl_gc_tracked_buffer_t") ||
824-
Name.endswith_lower("jl_binding_t") ||
825-
Name.endswith_lower("jl_ordereddict_t") ||
826-
Name.endswith_lower("jl_tvar_t") ||
827-
Name.endswith_lower("jl_typemap_t") ||
828-
Name.endswith_lower("jl_unionall_t") ||
829-
Name.endswith_lower("jl_methtable_t") ||
830-
Name.endswith_lower("jl_cgval_t") ||
831-
Name.endswith_lower("jl_codectx_t") ||
832-
Name.endswith_lower("jl_ast_context_t") ||
833-
Name.endswith_lower("jl_code_instance_t") ||
834-
Name.endswith_lower("jl_excstack_t") ||
835-
Name.endswith_lower("jl_task_t") ||
836-
Name.endswith_lower("jl_uniontype_t") ||
837-
Name.endswith_lower("jl_method_match_t") ||
838-
Name.endswith_lower("jl_vararg_t") ||
839-
Name.endswith_lower("jl_opaque_closure_t") ||
840-
Name.endswith_lower("jl_globalref_t") ||
802+
if (Name.ends_with_insensitive("jl_value_t") ||
803+
Name.ends_with_insensitive("jl_svec_t") ||
804+
Name.ends_with_insensitive("jl_sym_t") ||
805+
Name.ends_with_insensitive("jl_expr_t") ||
806+
Name.ends_with_insensitive("jl_code_info_t") ||
807+
Name.ends_with_insensitive("jl_array_t") ||
808+
Name.ends_with_insensitive("jl_genericmemory_t") ||
809+
//Name.ends_with_insensitive("jl_genericmemoryref_t") ||
810+
Name.ends_with_insensitive("jl_method_t") ||
811+
Name.ends_with_insensitive("jl_method_instance_t") ||
812+
Name.ends_with_insensitive("jl_debuginfo_t") ||
813+
Name.ends_with_insensitive("jl_tupletype_t") ||
814+
Name.ends_with_insensitive("jl_datatype_t") ||
815+
Name.ends_with_insensitive("jl_typemap_entry_t") ||
816+
Name.ends_with_insensitive("jl_typemap_level_t") ||
817+
Name.ends_with_insensitive("jl_typename_t") ||
818+
Name.ends_with_insensitive("jl_module_t") ||
819+
Name.ends_with_insensitive("jl_tupletype_t") ||
820+
Name.ends_with_insensitive("jl_gc_tracked_buffer_t") ||
821+
Name.ends_with_insensitive("jl_binding_t") ||
822+
Name.ends_with_insensitive("jl_ordereddict_t") ||
823+
Name.ends_with_insensitive("jl_tvar_t") ||
824+
Name.ends_with_insensitive("jl_typemap_t") ||
825+
Name.ends_with_insensitive("jl_unionall_t") ||
826+
Name.ends_with_insensitive("jl_methtable_t") ||
827+
Name.ends_with_insensitive("jl_cgval_t") ||
828+
Name.ends_with_insensitive("jl_codectx_t") ||
829+
Name.ends_with_insensitive("jl_ast_context_t") ||
830+
Name.ends_with_insensitive("jl_code_instance_t") ||
831+
Name.ends_with_insensitive("jl_excstack_t") ||
832+
Name.ends_with_insensitive("jl_task_t") ||
833+
Name.ends_with_insensitive("jl_uniontype_t") ||
834+
Name.ends_with_insensitive("jl_method_match_t") ||
835+
Name.ends_with_insensitive("jl_vararg_t") ||
836+
Name.ends_with_insensitive("jl_opaque_closure_t") ||
837+
Name.ends_with_insensitive("jl_globalref_t") ||
841838
// Probably not technically true for these, but let's allow it
842-
Name.endswith_lower("typemap_intersection_env") ||
843-
Name.endswith_lower("interpreter_state") ||
844-
Name.endswith_lower("jl_typeenv_t") ||
845-
Name.endswith_lower("jl_stenv_t") ||
846-
Name.endswith_lower("jl_varbinding_t") ||
847-
Name.endswith_lower("set_world") ||
848-
Name.endswith_lower("jl_codectx_t")) {
839+
Name.ends_with_insensitive("typemap_intersection_env") ||
840+
Name.ends_with_insensitive("interpreter_state") ||
841+
Name.ends_with_insensitive("jl_typeenv_t") ||
842+
Name.ends_with_insensitive("jl_stenv_t") ||
843+
Name.ends_with_insensitive("jl_varbinding_t") ||
844+
Name.ends_with_insensitive("set_world") ||
845+
Name.ends_with_insensitive("jl_codectx_t")) {
849846
return true;
850847
}
851848
return false;

src/passes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct RemoveNIPass : PassInfoMixin<RemoveNIPass> {
6464

6565
struct MultiVersioningPass : PassInfoMixin<MultiVersioningPass> {
6666
bool external_use;
67-
MultiVersioningPass(bool external_use = false) : external_use(external_use) {}
67+
MultiVersioningPass(bool external_use = false) JL_NOTSAFEPOINT : external_use(external_use) {}
6868
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM) JL_NOTSAFEPOINT;
6969
static bool isRequired() { return true; }
7070
};

src/pipeline.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,11 @@ namespace {
189189
// }
190190
}
191191

192-
#ifdef JL_DEBUG_BUILD
192+
#ifdef JL_VERIFY_PASSES
193193
static inline void addVerificationPasses(ModulePassManager &MPM, bool llvm_only) JL_NOTSAFEPOINT {
194-
if (!llvm_only)
195-
MPM.addPass(llvm::createModuleToFunctionPassAdaptor(GCInvariantVerifierPass()));
194+
if (!llvm_only){
195+
MPM.addPass(llvm::createModuleToFunctionPassAdaptor(GCInvariantVerifierPass(true)));
196+
}
196197
MPM.addPass(VerifierPass());
197198
}
198199
#endif
@@ -332,7 +333,7 @@ namespace {
332333

333334
static void buildEarlySimplificationPipeline(ModulePassManager &MPM, PassBuilder *PB, OptimizationLevel O, const OptimizationOptions &options) JL_NOTSAFEPOINT {
334335
MPM.addPass(BeforeEarlySimplificationMarkerPass());
335-
#ifdef JL_DEBUG_BUILD
336+
#ifdef JL_VERIFY_PASSES
336337
addVerificationPasses(MPM, options.llvm_only);
337338
#endif
338339
if (options.enable_early_simplifications) {

0 commit comments

Comments
 (0)