@@ -54,7 +54,6 @@ namespace llvm {
54
54
#include < llvm/IR/DataLayout.h>
55
55
#include < llvm/Support/DynamicLibrary.h>
56
56
57
-
58
57
#include < llvm/Support/raw_ostream.h>
59
58
#include < llvm/Support/FormattedStream.h>
60
59
#include < llvm/ADT/StringMap.h>
@@ -70,6 +69,7 @@ using namespace llvm;
70
69
#include " julia_assert.h"
71
70
72
71
RTDyldMemoryManager* createRTDyldMemoryManager (void );
72
+ using namespace llvm ::object;
73
73
74
74
static IntegerType *T_uint32;
75
75
static IntegerType *T_uint64;
@@ -284,72 +284,6 @@ void jl_add_optimization_passes(LLVMPassManagerRef PM, int opt_level) {
284
284
addOptimizationPasses (unwrap (PM), opt_level);
285
285
}
286
286
287
- // ------------------------ TEMPORARILY COPIED FROM LLVM -----------------
288
- // This must be kept in sync with gdb/gdb/jit.h .
289
- extern " C" {
290
-
291
- typedef enum {
292
- JIT_NOACTION = 0 ,
293
- JIT_REGISTER_FN,
294
- JIT_UNREGISTER_FN
295
- } jit_actions_t ;
296
-
297
- struct jit_code_entry {
298
- struct jit_code_entry *next_entry;
299
- struct jit_code_entry *prev_entry;
300
- const char *symfile_addr;
301
- uint64_t symfile_size;
302
- };
303
-
304
- struct jit_descriptor {
305
- uint32_t version;
306
- // This should be jit_actions_t, but we want to be specific about the
307
- // bit-width.
308
- uint32_t action_flag;
309
- struct jit_code_entry *relevant_entry;
310
- struct jit_code_entry *first_entry;
311
- };
312
-
313
- // We put information about the JITed function in this global, which the
314
- // debugger reads. Make sure to specify the version statically, because the
315
- // debugger checks the version before we can set it during runtime.
316
- extern struct jit_descriptor __jit_debug_descriptor;
317
-
318
- LLVM_ATTRIBUTE_NOINLINE extern void __jit_debug_register_code ();
319
- }
320
-
321
- namespace {
322
-
323
- // Use a local variable to hold the addresses to avoid generating a PLT
324
- // on the function call.
325
- // It messes up the GDB lookup logic with dynamically linked LLVM.
326
- // (Ref https://sourceware.org/bugzilla/show_bug.cgi?id=20633)
327
- // Use `volatile` to make sure the call always loads this slot.
328
- void (*volatile jit_debug_register_code)() = __jit_debug_register_code;
329
-
330
- using namespace llvm ;
331
- using namespace llvm ::object;
332
- using namespace llvm ::orc;
333
-
334
- // / Do the registration.
335
- void NotifyDebugger (jit_code_entry *JITCodeEntry)
336
- {
337
- __jit_debug_descriptor.action_flag = JIT_REGISTER_FN;
338
-
339
- // Insert this entry at the head of the list.
340
- JITCodeEntry->prev_entry = nullptr ;
341
- jit_code_entry *NextEntry = __jit_debug_descriptor.first_entry ;
342
- JITCodeEntry->next_entry = NextEntry;
343
- if (NextEntry) {
344
- NextEntry->prev_entry = JITCodeEntry;
345
- }
346
- __jit_debug_descriptor.first_entry = JITCodeEntry;
347
- __jit_debug_descriptor.relevant_entry = JITCodeEntry;
348
- jit_debug_register_code ();
349
- }
350
- }
351
- // ------------------------ END OF TEMPORARY COPY FROM LLVM -----------------
352
-
353
287
#if defined(_OS_LINUX_) || defined(_OS_WINDOWS_) || defined(_OS_FREEBSD_)
354
288
// Resolve non-lock free atomic functions in the libatomic1 library.
355
289
// This is the library that provides support for c11/c++11 atomic operations.
@@ -402,10 +336,9 @@ void JuliaOJIT::DebugObjectRegistrar::registerObject(RTDyldObjHandleT H, const O
402
336
std::move (NewBuffer));
403
337
}
404
338
else {
405
- NotifyGDB ( SavedObject);
339
+ JIT. NotifyFinalizer (*( SavedObject. getBinary ()), *LO );
406
340
}
407
341
408
- JIT.NotifyFinalizer (*Object, *LO);
409
342
SavedObjects.push_back (std::move (SavedObject));
410
343
411
344
ORCNotifyObjectEmitted (JuliaListener.get (), *Object,
@@ -436,7 +369,6 @@ void JuliaOJIT::DebugObjectRegistrar::registerObject(RTDyldObjHandleT H, const O
436
369
}
437
370
}
438
371
439
- // TODO: hook up RegisterJITEventListener, instead of hard-coding the GDB and JuliaListener targets
440
372
template <typename ObjSetT, typename LoadResult>
441
373
void JuliaOJIT::DebugObjectRegistrar::operator ()(RTDyldObjHandleT H,
442
374
const ObjSetT &Objects, const LoadResult &LOS)
@@ -456,24 +388,6 @@ void JuliaOJIT::DebugObjectRegistrar::operator()(RTDyldObjHandleT H,
456
388
#endif
457
389
}
458
390
459
- void JuliaOJIT::DebugObjectRegistrar::NotifyGDB (OwningBinary<object::ObjectFile> &DebugObj)
460
- {
461
- const char *Buffer = DebugObj.getBinary ()->getMemoryBufferRef ().getBufferStart ();
462
- size_t Size = DebugObj.getBinary ()->getMemoryBufferRef ().getBufferSize ();
463
-
464
- assert (Buffer && " Attempt to register a null object with a debugger." );
465
- jit_code_entry *JITCodeEntry = new jit_code_entry ();
466
-
467
- if (!JITCodeEntry) {
468
- jl_printf (JL_STDERR, " WARNING: Allocation failed when registering a JIT entry!\n " );
469
- }
470
- else {
471
- JITCodeEntry->symfile_addr = Buffer;
472
- JITCodeEntry->symfile_size = Size ;
473
-
474
- NotifyDebugger (JITCodeEntry);
475
- }
476
- }
477
391
478
392
object::OwningBinary<object::ObjectFile> JuliaOJIT::CompilerT::operator ()(Module &M)
479
393
{
0 commit comments