Skip to content

Commit 72113cb

Browse files
committed
Try injecting the aliases after optimization.
Our multiversioning pass interacts badly with the llvm.compiler.used gvar.
1 parent ebcc8e4 commit 72113cb

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

src/aotcompile.cpp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -565,25 +565,28 @@ void jl_dump_native_impl(void *native_code,
565565
"jl_RTLD_DEFAULT_handle_pointer"));
566566
}
567567

568-
// We would like to emit an alias or an weakref alias to redirect these symbols
569-
// but LLVM doesn't let us emit a GlobalAlias to a declaration...
570-
// So for now we inject a definition of these functions that calls our runtime functions.
571-
injectCRTAlias(*dataM, "__gnu_h2f_ieee", "julia__gnu_h2f_ieee",
572-
FunctionType::get(Type::getFloatTy(Context), { Type::getHalfTy(Context) }, false));
573-
injectCRTAlias(*dataM, "__extendhfsf2", "julia__gnu_h2f_ieee",
574-
FunctionType::get(Type::getFloatTy(Context), { Type::getHalfTy(Context) }, false));
575-
injectCRTAlias(*dataM, "__gnu_f2h_ieee", "julia__gnu_f2h_ieee",
576-
FunctionType::get(Type::getHalfTy(Context), { Type::getFloatTy(Context) }, false));
577-
injectCRTAlias(*dataM, "__truncsfhf2", "julia__gnu_f2h_ieee",
578-
FunctionType::get(Type::getHalfTy(Context), { Type::getFloatTy(Context) }, false));
579-
injectCRTAlias(*dataM, "__truncdfhf2", "julia__truncdfhf2",
580-
FunctionType::get(Type::getHalfTy(Context), { Type::getDoubleTy(Context) }, false));
581-
582568
// do the actual work
583569
auto add_output = [&] (Module &M, StringRef unopt_bc_Name, StringRef bc_Name, StringRef obj_Name, StringRef asm_Name) {
584570
preopt.run(M);
585571
optimizer.run(M);
572+
573+
// We would like to emit an alias or an weakref alias to redirect these symbols
574+
// but LLVM doesn't let us emit a GlobalAlias to a declaration...
575+
// So for now we inject a definition of these functions that calls our runtime
576+
// functions. We do so after optimization to avoid cloning these functions.
577+
injectCRTAlias(M, "__gnu_h2f_ieee", "julia__gnu_h2f_ieee",
578+
FunctionType::get(Type::getFloatTy(Context), { Type::getHalfTy(Context) }, false));
579+
injectCRTAlias(M, "__extendhfsf2", "julia__gnu_h2f_ieee",
580+
FunctionType::get(Type::getFloatTy(Context), { Type::getHalfTy(Context) }, false));
581+
injectCRTAlias(M, "__gnu_f2h_ieee", "julia__gnu_f2h_ieee",
582+
FunctionType::get(Type::getHalfTy(Context), { Type::getFloatTy(Context) }, false));
583+
injectCRTAlias(M, "__truncsfhf2", "julia__gnu_f2h_ieee",
584+
FunctionType::get(Type::getHalfTy(Context), { Type::getFloatTy(Context) }, false));
585+
injectCRTAlias(M, "__truncdfhf2", "julia__truncdfhf2",
586+
FunctionType::get(Type::getHalfTy(Context), { Type::getDoubleTy(Context) }, false));
587+
586588
postopt.run(M);
589+
587590
if (unopt_bc_fname)
588591
emit_result(unopt_bc_Archive, unopt_bc_Buffer, unopt_bc_Name, outputs);
589592
if (bc_fname)

0 commit comments

Comments
 (0)