diff --git a/src/llvm-multiversioning.cpp b/src/llvm-multiversioning.cpp index 099596358b571..ab90670c6d929 100644 --- a/src/llvm-multiversioning.cpp +++ b/src/llvm-multiversioning.cpp @@ -295,6 +295,8 @@ struct CloneCtx { std::vector> gv_relocs{}; // Mapping from function id (i.e. 0-based index in `fvars`) to GVs to be initialized. std::map const_relocs; + // Functions that were referred to by a global alias, and might not have other uses. + std::set alias_relocs; bool has_veccall{false}; bool has_cloneall{false}; }; @@ -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); @@ -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());