Skip to content

Commit

Permalink
Don't rewrite global aliases during multiversioning.
Browse files Browse the repository at this point in the history
Fixes #34064
  • Loading branch information
maleadt committed Sep 11, 2020
1 parent 39a278d commit c2db424
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/llvm-multiversioning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,12 +702,16 @@ void CloneCtx::fix_gv_uses()
auto single_pass = [&] (Function *orig_f) {
bool changed = false;
for (auto uses = ConstantUses<GlobalValue>(orig_f, M); !uses.done(); uses.next()) {
changed = true;
auto &stack = uses.get_stack();
auto info = uses.get_info();
// We only support absolute pointer relocation.
assert(info.samebits);
// And only for non-constant global variable initializers
if (isa<GlobalAlias>(info.val)) {
// ... but don't crash on global aliases, since we'll retain the original f
// (these are emitted for C-callable functions)
continue;
}
auto val = cast<GlobalVariable>(info.val);
assert(info.use->getOperandNo() == 0);
assert(!val->isConstant());
Expand All @@ -717,6 +721,7 @@ void CloneCtx::fix_gv_uses()
addr = ConstantExpr::getAdd(addr, ConstantInt::get(T_size, info.offset));
gv_relocs.emplace_back(addr, fid);
val->setInitializer(rewrite_gv_init(stack));
changed = true;
}
return changed;
};
Expand Down

0 comments on commit c2db424

Please sign in to comment.