Skip to content

Commit

Permalink
Special-case relocation slots from global aliases.
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt committed Sep 21, 2020
1 parent 2898b93 commit 24f2816
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/llvm-multiversioning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ struct CloneCtx {
std::vector<std::pair<Constant*,uint32_t>> gv_relocs{};
// Mapping from function id (i.e. 0-based index in `fvars`) to GVs to be initialized.
std::map<uint32_t,GlobalVariable*> const_relocs;
// Functions that were referred to by a global alias, and might not have other uses.
std::set<uint32_t> alias_relocs;
bool has_veccall{false};
bool has_cloneall{false};
};
Expand Down Expand Up @@ -717,6 +719,7 @@ void CloneCtx::rewrite_alias(GlobalAlias *alias, Function *F)
tgt.relocs.insert(id);
}
}
alias_relocs.insert(id);

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

0 comments on commit 24f2816

Please sign in to comment.