Skip to content

Commit 76fc067

Browse files
authored
Make sure all the relocations are filled in for partially cloned target (#44262)
We collect the relocations (i.e. the GOT slots that is used in the code) for each target in `tgt.relocs`. Needing a relocation, however, does not imply that the function is cloned for this target within the group (It does mean that at least one target in the group has it cloned). The previous version would miss the relocation in this case. This was triggerred with the following cloning situation caller: clone_1 callee: clone_1, clone_1.clone_3 Since caller.clone_1 may call either callee.clone_1 or callee.clone_1.clone_3 a relocation for callee will be used and is required to be initialized. In addition to target 1, target 2 (and in fact target 3) within group 1 will also use caller.clone_1. However, since callee isn't cloned for target 2 the previous version wouldn't have saved this slot in the relocation array.
1 parent c9cb015 commit 76fc067

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/llvm-multiversioning.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,15 +1037,15 @@ void CloneCtx::emit_metadata()
10371037
idxs.push_back(baseidx);
10381038
for (uint32_t j = 0; j < nfvars; j++) {
10391039
auto base_f = grp->base_func(fvars[j]);
1040-
if (shared_relocs.count(j)) {
1040+
if (shared_relocs.count(j) || tgt->relocs.count(j)) {
10411041
count++;
10421042
idxs.push_back(jl_sysimg_tag_mask | j);
10431043
auto f = map_get(*tgt->vmap, base_f, base_f);
10441044
offsets.push_back(get_ptrdiff32(cast<Function>(f), fbase));
10451045
}
10461046
else if (auto f = map_get(*tgt->vmap, base_f)) {
10471047
count++;
1048-
idxs.push_back(tgt->relocs.count(j) ? (jl_sysimg_tag_mask | j) : j);
1048+
idxs.push_back(j);
10491049
offsets.push_back(get_ptrdiff32(cast<Function>(f), fbase));
10501050
}
10511051
}

0 commit comments

Comments
 (0)