22
22
'i886' , 'i986' ])
23
23
24
24
25
- Todd = True
26
-
27
25
def _is_x86 (triple ):
28
26
arch = triple .split ('-' )[0 ]
29
27
return arch in _x86arch
@@ -218,20 +216,23 @@ def add_ir_module(self, ir_module):
218
216
self .add_llvm_module (ll_module )
219
217
220
218
def add_llvm_module (self , ll_module ):
221
- print ("CodeLibrary::add_llvm_module" , self ._name )
219
+ if config .DEBUG_ARRAY_OPT >= 1 :
220
+ print ("CodeLibrary::add_llvm_module" , self ._name )
222
221
self ._optimize_functions (ll_module )
223
222
# TODO: we shouldn't need to recreate the LLVM module object
224
223
ll_module = remove_redundant_nrt_refct (ll_module )
225
224
self ._final_module .link_in (ll_module )
226
- print ("CodeLibrary::add_llvm_module end" , self ._name )
225
+ if config .DEBUG_ARRAY_OPT >= 1 :
226
+ print ("CodeLibrary::add_llvm_module end" , self ._name )
227
227
228
228
def finalize (self ):
229
229
"""
230
230
Finalize the library. After this call, nothing can be added anymore.
231
231
Finalization involves various stages of code optimization and
232
232
linking.
233
233
"""
234
- print ("CodeLibrary::finalize" , self ._name )
234
+ if config .DEBUG_ARRAY_OPT >= 1 :
235
+ print ("CodeLibrary::finalize" , self ._name )
235
236
require_global_compiler_lock ()
236
237
237
238
# Report any LLVM-related problems to the user
@@ -242,7 +243,8 @@ def finalize(self):
242
243
if config .DUMP_FUNC_OPT :
243
244
dump ("FUNCTION OPTIMIZED DUMP %s" % self ._name , self .get_llvm_str ())
244
245
245
- print ("Before link_in" )
246
+ if config .DEBUG_ARRAY_OPT >= 1 :
247
+ print ("Before link_in" )
246
248
# Link libraries for shared code
247
249
seen = set ()
248
250
for library in self ._linking_libraries :
@@ -258,7 +260,8 @@ def finalize(self):
258
260
259
261
self ._final_module .verify ()
260
262
self ._finalize_final_module ()
261
- print ("CodeLibrary::finalize end" , self ._name )
263
+ if config .DEBUG_ARRAY_OPT >= 1 :
264
+ print ("CodeLibrary::finalize end" , self ._name )
262
265
if self ._name == 'f1' :
263
266
import pdb
264
267
#pdb.set_trace()
@@ -544,7 +547,7 @@ def scan_unresolved_symbols(self, module, engine):
544
547
prefix = self .PREFIX
545
548
546
549
for gv in module .global_variables :
547
- if Todd :
550
+ if config . DEBUG_ARRAY_OPT >= 1 :
548
551
print ("scan_unresolved_symbols" , gv )
549
552
if gv .name .startswith (prefix ):
550
553
sym = gv .name [len (prefix ):]
@@ -562,7 +565,7 @@ def scan_defined_symbols(self, module):
562
565
Scan and track all defined symbols.
563
566
"""
564
567
for fn in module .functions :
565
- if Todd :
568
+ if config . DEBUG_ARRAY_OPT >= 1 :
566
569
print ("scan_defined_symbols" , fn )
567
570
if not fn .is_declaration :
568
571
self ._defined .add (fn .name )
@@ -571,13 +574,13 @@ def resolve(self, engine):
571
574
"""
572
575
Fix unresolved symbols if they are defined.
573
576
"""
574
- if Todd :
577
+ if config . DEBUG_ARRAY_OPT >= 1 :
575
578
print ("RuntimeLinker resolve" , self ._unresolved , self ._defined )
576
579
# An iterator to get all unresolved but available symbols
577
580
pending = [name for name in self ._unresolved if name in self ._defined ]
578
581
# Resolve pending symbols
579
582
for name in pending :
580
- if Todd :
583
+ if config . DEBUG_ARRAY_OPT >= 1 :
581
584
print ("name" , name )
582
585
# Get runtime address
583
586
fnptr = engine .get_function_address (name )
@@ -623,7 +626,7 @@ def _load_defined_symbols(self, mod):
623
626
"""Extract symbols from the module
624
627
"""
625
628
for gsets in (mod .functions , mod .global_variables ):
626
- if Todd :
629
+ if config . DEBUG_ARRAY_OPT >= 1 :
627
630
print ("_load_defined_symbols" , gsets , self ._defined_symbols )
628
631
self ._defined_symbols |= {gv .name for gv in gsets
629
632
if not gv .is_declaration }
@@ -632,7 +635,7 @@ def add_module(self, module):
632
635
"""Override ExecutionEngine.add_module
633
636
to keep info about defined symbols.
634
637
"""
635
- if Todd :
638
+ if config . DEBUG_ARRAY_OPT >= 1 :
636
639
print ("add_module" , module )
637
640
self ._load_defined_symbols (module )
638
641
return self ._ee .add_module (module )
0 commit comments