Skip to content

Commit 24f2816

Browse files
committed
Special-case relocation slots from global aliases.
1 parent 2898b93 commit 24f2816

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/llvm-multiversioning.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,8 @@ struct CloneCtx {
295295
std::vector<std::pair<Constant*,uint32_t>> gv_relocs{};
296296
// Mapping from function id (i.e. 0-based index in `fvars`) to GVs to be initialized.
297297
std::map<uint32_t,GlobalVariable*> const_relocs;
298+
// Functions that were referred to by a global alias, and might not have other uses.
299+
std::set<uint32_t> alias_relocs;
298300
bool has_veccall{false};
299301
bool has_cloneall{false};
300302
};
@@ -717,6 +719,7 @@ void CloneCtx::rewrite_alias(GlobalAlias *alias, Function *F)
717719
tgt.relocs.insert(id);
718720
}
719721
}
722+
alias_relocs.insert(id);
720723

721724
auto BB = BasicBlock::Create(ctx, "top", trampoline);
722725
IRBuilder<> irbuilder(BB);
@@ -1007,6 +1010,9 @@ void CloneCtx::emit_metadata()
10071010
values.push_back(id_v);
10081011
values.push_back(get_ptrdiff32(it->second, gbase));
10091012
}
1013+
if (alias_relocs.find(id) != alias_relocs.end()) {
1014+
shared_relocs.insert(id);
1015+
}
10101016
}
10111017
values[0] = ConstantInt::get(T_int32, values.size() / 2);
10121018
ArrayType *vars_type = ArrayType::get(T_int32, values.size());

0 commit comments

Comments
 (0)