Skip to content

Commit

Permalink
fixup! use separate names for internal and exported functions
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Sep 14, 2021
1 parent ef201df commit ed397cd
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ $(BUILDDIR)/llvm-alloc-opt.o $(BUILDDIR)/llvm-alloc-opt.dbg.obj: $(SRCDIR)/codeg
$(BUILDDIR)/llvm-final-gc-lowering.o $(BUILDDIR)/llvm-final-gc-lowering.dbg.obj: $(SRCDIR)/llvm-pass-helpers.h
$(BUILDDIR)/llvm-gc-invariant-verifier.o $(BUILDDIR)/llvm-gc-invariant-verifier.dbg.obj: $(SRCDIR)/codegen_shared.h
$(BUILDDIR)/llvm-late-gc-lowering.o $(BUILDDIR)/llvm-late-gc-lowering.dbg.obj: $(SRCDIR)/llvm-pass-helpers.h
$(BUILDDIR)/llvm-lower-handlers.o $(BUILDDIR)/llvm-lower-handlers.dbg.obj: $(SRCDIR)/codegen_shared.h
$(BUILDDIR)/llvm-multiversioning.o $(BUILDDIR)/llvm-multiversioning.dbg.obj: $(SRCDIR)/codegen_shared.h
$(BUILDDIR)/llvm-pass-helpers.o $(BUILDDIR)/llvm-pass-helpers.dbg.obj: $(SRCDIR)/llvm-pass-helpers.h $(SRCDIR)/codegen_shared.h
$(BUILDDIR)/llvm-ptls.o $(BUILDDIR)/llvm-ptls.dbg.obj: $(SRCDIR)/codegen_shared.h
Expand Down
7 changes: 4 additions & 3 deletions src/ccall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1264,12 +1264,13 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
return args[6 + i];
};

auto _is_libjulia_func = [&] (uintptr_t ptr, const char *name) {
auto _is_libjulia_func = [&] (uintptr_t ptr, StringRef name) {
if ((uintptr_t)fptr == ptr)
return true;
if (f_lib) {
#ifdef _OS_WINDOWS_
if ((f_lib == JL_EXE_LIBNAME) || // preventing invalid pointer access
(f_lib == JL_LIBJULIA_DL_LIBNAME) ||
(f_lib == JL_LIBJULIA_INTERNAL_DL_LIBNAME) ||
(!strcmp(f_lib, jl_crtdll_basename))) {
// libjulia-like
Expand All @@ -1280,9 +1281,9 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
return false;
#endif
}
return f_name && !strcmp(f_name, name);
return f_name && (f_name == name || (name[0] == 'i' && f_name == name.drop_front()));
};
#define is_libjulia_func(name) _is_libjulia_func((uintptr_t)&(name), #name)
#define is_libjulia_func(name) _is_libjulia_func((uintptr_t)&(name), StringRef(XSTR(#name)))

// emit arguments
jl_cgval_t *argv = (jl_cgval_t*)alloca(sizeof(jl_cgval_t) * nccallargs);
Expand Down
3 changes: 0 additions & 3 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ typedef Instruction TerminatorInst;
#include "processor.h"
#include "julia_assert.h"

#define STR(csym) #csym
#define XSTR(csym) STR(csym)

JL_STREAM *dump_emitted_mi_name_stream = NULL;
extern "C" JL_DLLEXPORT
void jl_dump_emitted_mi_name(void *s)
Expand Down
3 changes: 3 additions & 0 deletions src/codegen_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#include <llvm/IR/DebugLoc.h>
#include <llvm/IR/IRBuilder.h>

#define STR(csym) #csym
#define XSTR(csym) STR(csym)

enum AddressSpace {
Generic = 0,
Tracked = 10,
Expand Down
2 changes: 1 addition & 1 deletion src/intrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ FunctionType *get_intr_args4(LLVMContext &C) { return FunctionType::get(T_prjlva
FunctionType *get_intr_args5(LLVMContext &C) { return FunctionType::get(T_prjlvalue, {T_prjlvalue, T_prjlvalue, T_prjlvalue, T_prjlvalue, T_prjlvalue}, false); }

static JuliaFunction *runtime_func[num_intrinsics] = {
#define ADD_I(name, nargs) new JuliaFunction{"jl_"#name, get_intr_args##nargs, nullptr},
#define ADD_I(name, nargs) new JuliaFunction{XSTR(jl_##name), get_intr_args##nargs, nullptr},
#define ADD_HIDDEN ADD_I
#define ALIAS(alias, base) nullptr,
INTRINSICS
Expand Down
4 changes: 2 additions & 2 deletions src/llvm-late-gc-lowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1551,8 +1551,8 @@ State LateLowerGCFrame::LocalScan(Function &F) {
// Known functions emitted in codegen that are not safepoints
if (callee == pointer_from_objref_func || callee == gc_preserve_begin_func ||
callee == gc_preserve_end_func || callee == typeof_func ||
callee == pgcstack_getter || callee->getName() == "jl_egal__unboxed" ||
callee->getName() == "jl_lock_value" || callee->getName() == "jl_unlock_value" ||
callee == pgcstack_getter || callee->getName() == XSTR(jl_egal__unboxed) ||
callee->getName() == XSTR(jl_lock_value) || callee->getName() == XSTR(jl_unlock_value) ||
callee == write_barrier_func || callee->getName() == "memcmp") {
continue;
}
Expand Down
9 changes: 5 additions & 4 deletions src/llvm-lower-handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "julia.h"
#include "julia_assert.h"
#include "codegen_shared.h"

#define DEBUG_TYPE "lower_handlers"
#undef DEBUG
Expand Down Expand Up @@ -95,11 +96,11 @@ static void ensure_enter_function(Module &M)
auto T_pint8 = PointerType::get(T_int8, 0);
auto T_void = Type::getVoidTy(M.getContext());
auto T_int32 = Type::getInt32Ty(M.getContext());
if (!M.getNamedValue("jl_enter_handler")) {
if (!M.getNamedValue(XSTR(jl_enter_handler))) {
std::vector<Type*> ehargs(0);
ehargs.push_back(T_pint8);
Function::Create(FunctionType::get(T_void, ehargs, false),
Function::ExternalLinkage, "jl_enter_handler", &M);
Function::ExternalLinkage, XSTR(jl_enter_handler), &M);
}
if (!M.getNamedValue(jl_setjmp_name)) {
std::vector<Type*> args2(0);
Expand All @@ -118,8 +119,8 @@ bool LowerExcHandlers::doInitialization(Module &M) {
if (!except_enter_func)
return false;
ensure_enter_function(M);
leave_func = M.getFunction("jl_pop_handler");
jlenter_func = M.getFunction("jl_enter_handler");
leave_func = M.getFunction(XSTR(jl_pop_handler));
jlenter_func = M.getFunction(XSTR(jl_enter_handler));
setjmp_func = M.getFunction(jl_setjmp_name);

auto T_pint8 = Type::getInt8PtrTy(M.getContext(), 0);
Expand Down
7 changes: 4 additions & 3 deletions src/llvm-pass-helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "codegen_shared.h"
#include "julia_assert.h"
#include "llvm-pass-helpers.h"
#include "jl_internal_funcs.inc"

using namespace llvm;

Expand Down Expand Up @@ -209,9 +210,9 @@ namespace jl_intrinsics {
}

namespace jl_well_known {
static const char *GC_BIG_ALLOC_NAME = "jl_gc_big_alloc";
static const char *GC_POOL_ALLOC_NAME = "jl_gc_pool_alloc";
static const char *GC_QUEUE_ROOT_NAME = "jl_gc_queue_root";
static const char *GC_BIG_ALLOC_NAME = XSTR(jl_gc_big_alloc);
static const char *GC_POOL_ALLOC_NAME = XSTR(jl_gc_pool_alloc);
static const char *GC_QUEUE_ROOT_NAME = XSTR(jl_gc_queue_root);

using jl_intrinsics::addGCAllocAttributes;

Expand Down

0 comments on commit ed397cd

Please sign in to comment.