@@ -77,32 +77,6 @@ def display(self, filename=None, view=False):
77
77
def __repr__ (self ):
78
78
return self .dot
79
79
80
- def test_link ():
81
- ll .initialize ()
82
- ll .initialize_all_targets ()
83
- ll .initialize_native_asmprinter ()
84
-
85
- target = ll .Target .from_triple (ll .get_process_triple ())
86
- tm = target .create_target_machine ()
87
-
88
-
89
- llvm_module = ll .parse_assembly ("""
90
- declare i32 @PyArg_UnpackTuple(i8*, i8*, i64, i64, ...)
91
- declare double @sin(double)
92
- define i64 @foo() {
93
- ret i64 ptrtoint (i32 (i8*, i8*, i64, i64, ...)* @PyArg_UnpackTuple to i64)
94
- }
95
- """ )
96
-
97
- engine = ll .create_mcjit_compiler (llvm_module , tm )
98
- addr = engine .get_function_address ('PyArg_UnpackTuple' )
99
- print ('PyArg_UnpackTuple' , addr ) # printing 0x0
100
-
101
-
102
- addr = engine .get_function_address ('foo' )
103
- foo = ctypes .CFUNCTYPE (ctypes .c_int64 )(addr )
104
- print ('foo' , addr )
105
- print ("PyArg_UnpackTuple" , foo ()) # print non zero
106
80
107
81
class CodeLibrary (object ):
108
82
"""
@@ -235,23 +209,17 @@ def add_ir_module(self, ir_module):
235
209
self .add_llvm_module (ll_module )
236
210
237
211
def add_llvm_module (self , ll_module ):
238
- if config .DEBUG_ARRAY_OPT >= 1 :
239
- print ("CodeLibrary::add_llvm_module" , self ._name )
240
212
self ._optimize_functions (ll_module )
241
213
# TODO: we shouldn't need to recreate the LLVM module object
242
214
ll_module = remove_redundant_nrt_refct (ll_module )
243
215
self ._final_module .link_in (ll_module )
244
- if config .DEBUG_ARRAY_OPT >= 1 :
245
- print ("CodeLibrary::add_llvm_module end" , self ._name )
246
216
247
217
def finalize (self ):
248
218
"""
249
219
Finalize the library. After this call, nothing can be added anymore.
250
220
Finalization involves various stages of code optimization and
251
221
linking.
252
222
"""
253
- if config .DEBUG_ARRAY_OPT >= 1 :
254
- print ("CodeLibrary::finalize" , self ._name )
255
223
#require_global_compiler_lock()
256
224
257
225
# Report any LLVM-related problems to the user
@@ -263,8 +231,6 @@ def finalize(self):
263
231
dump ("FUNCTION OPTIMIZED DUMP %s" % self ._name ,
264
232
self .get_llvm_str (), 'llvm' )
265
233
266
- if config .DEBUG_ARRAY_OPT >= 1 :
267
- print ("Before link_in" )
268
234
# Link libraries for shared code
269
235
seen = set ()
270
236
for library in self ._linking_libraries :
@@ -280,10 +246,8 @@ def finalize(self):
280
246
281
247
self ._final_module .verify ()
282
248
self ._finalize_final_module ()
283
- if config .DEBUG_ARRAY_OPT >= 1 :
284
- print ("CodeLibrary::finalize end" , self ._name )
285
249
286
- def _finalize_dynamic_globals (self ):
250
+ def _finalize_dyanmic_globals (self ):
287
251
# Scan for dynamic globals
288
252
for gv in self ._final_module .global_variables :
289
253
if gv .name .startswith ('numba.dynamic.globals' ):
@@ -301,7 +265,7 @@ def _finalize_final_module(self):
301
265
"""
302
266
Make the underlying LLVM module ready to use.
303
267
"""
304
- self ._finalize_dynamic_globals ()
268
+ self ._finalize_dyanmic_globals ()
305
269
self ._verify_declare_only_symbols ()
306
270
307
271
# Remember this on the module, for the object cache hooks
@@ -321,7 +285,6 @@ def _finalize_final_module(self):
321
285
dump ("OPTIMIZED DUMP %s" % self ._name , self .get_llvm_str (), 'llvm' )
322
286
323
287
if config .DUMP_ASSEMBLY :
324
- test_link ()
325
288
# CUDA backend cannot return assembly this early, so don't
326
289
# attempt to dump assembly if nothing is produced.
327
290
asm = self .get_asm_str ()
@@ -571,8 +534,6 @@ def scan_unresolved_symbols(self, module, engine):
571
534
prefix = self .PREFIX
572
535
573
536
for gv in module .global_variables :
574
- if config .DEBUG_ARRAY_OPT >= 1 :
575
- print ("scan_unresolved_symbols" , gv )
576
537
if gv .name .startswith (prefix ):
577
538
sym = gv .name [len (prefix ):]
578
539
# Avoid remapping to existing GV
@@ -589,23 +550,17 @@ def scan_defined_symbols(self, module):
589
550
Scan and track all defined symbols.
590
551
"""
591
552
for fn in module .functions :
592
- if config .DEBUG_ARRAY_OPT >= 1 :
593
- print ("scan_defined_symbols" , fn )
594
553
if not fn .is_declaration :
595
554
self ._defined .add (fn .name )
596
555
597
556
def resolve (self , engine ):
598
557
"""
599
558
Fix unresolved symbols if they are defined.
600
559
"""
601
- if config .DEBUG_ARRAY_OPT >= 1 :
602
- print ("RuntimeLinker resolve" , self ._unresolved , self ._defined )
603
560
# An iterator to get all unresolved but available symbols
604
561
pending = [name for name in self ._unresolved if name in self ._defined ]
605
562
# Resolve pending symbols
606
563
for name in pending :
607
- if config .DEBUG_ARRAY_OPT >= 1 :
608
- print ("name" , name )
609
564
# Get runtime address
610
565
fnptr = engine .get_function_address (name )
611
566
# Fix all usage
@@ -650,17 +605,13 @@ def _load_defined_symbols(self, mod):
650
605
"""Extract symbols from the module
651
606
"""
652
607
for gsets in (mod .functions , mod .global_variables ):
653
- if config .DEBUG_ARRAY_OPT >= 1 :
654
- print ("_load_defined_symbols" , gsets , self ._defined_symbols )
655
608
self ._defined_symbols |= {gv .name for gv in gsets
656
609
if not gv .is_declaration }
657
610
658
611
def add_module (self , module ):
659
612
"""Override ExecutionEngine.add_module
660
613
to keep info about defined symbols.
661
614
"""
662
- if config .DEBUG_ARRAY_OPT >= 1 :
663
- print ("add_module" , module )
664
615
self ._load_defined_symbols (module )
665
616
return self ._ee .add_module (module )
666
617
@@ -923,7 +874,6 @@ def initialize_llvm():
923
874
ll .initialize ()
924
875
ll .initialize_native_target ()
925
876
ll .initialize_native_asmprinter ()
926
- ll .initialize_all_targets ()
927
877
928
878
929
879
def get_host_cpu_features ():
0 commit comments