From c2db4248a9f03ae2e23ef38290efe606a82ce484 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Fri, 11 Sep 2020 17:08:52 +0200 Subject: [PATCH] Don't rewrite global aliases during multiversioning. Fixes JuliaLang/julia#34064 --- src/llvm-multiversioning.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/llvm-multiversioning.cpp b/src/llvm-multiversioning.cpp index 68081eb53d3a5b..8a68d753685835 100644 --- a/src/llvm-multiversioning.cpp +++ b/src/llvm-multiversioning.cpp @@ -702,12 +702,16 @@ void CloneCtx::fix_gv_uses() auto single_pass = [&] (Function *orig_f) { bool changed = false; for (auto uses = ConstantUses(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(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(info.val); assert(info.use->getOperandNo() == 0); assert(!val->isConstant()); @@ -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; };