2222 'i886' , 'i986' ])
2323
2424
25- Todd = True
26-
2725def _is_x86 (triple ):
2826 arch = triple .split ('-' )[0 ]
2927 return arch in _x86arch
@@ -218,20 +216,23 @@ def add_ir_module(self, ir_module):
218216 self .add_llvm_module (ll_module )
219217
220218 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 )
222221 self ._optimize_functions (ll_module )
223222 # TODO: we shouldn't need to recreate the LLVM module object
224223 ll_module = remove_redundant_nrt_refct (ll_module )
225224 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 )
227227
228228 def finalize (self ):
229229 """
230230 Finalize the library. After this call, nothing can be added anymore.
231231 Finalization involves various stages of code optimization and
232232 linking.
233233 """
234- print ("CodeLibrary::finalize" , self ._name )
234+ if config .DEBUG_ARRAY_OPT >= 1 :
235+ print ("CodeLibrary::finalize" , self ._name )
235236 require_global_compiler_lock ()
236237
237238 # Report any LLVM-related problems to the user
@@ -242,7 +243,8 @@ def finalize(self):
242243 if config .DUMP_FUNC_OPT :
243244 dump ("FUNCTION OPTIMIZED DUMP %s" % self ._name , self .get_llvm_str ())
244245
245- print ("Before link_in" )
246+ if config .DEBUG_ARRAY_OPT >= 1 :
247+ print ("Before link_in" )
246248 # Link libraries for shared code
247249 seen = set ()
248250 for library in self ._linking_libraries :
@@ -258,7 +260,8 @@ def finalize(self):
258260
259261 self ._final_module .verify ()
260262 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 )
262265 if self ._name == 'f1' :
263266 import pdb
264267 #pdb.set_trace()
@@ -544,7 +547,7 @@ def scan_unresolved_symbols(self, module, engine):
544547 prefix = self .PREFIX
545548
546549 for gv in module .global_variables :
547- if Todd :
550+ if config . DEBUG_ARRAY_OPT >= 1 :
548551 print ("scan_unresolved_symbols" , gv )
549552 if gv .name .startswith (prefix ):
550553 sym = gv .name [len (prefix ):]
@@ -562,7 +565,7 @@ def scan_defined_symbols(self, module):
562565 Scan and track all defined symbols.
563566 """
564567 for fn in module .functions :
565- if Todd :
568+ if config . DEBUG_ARRAY_OPT >= 1 :
566569 print ("scan_defined_symbols" , fn )
567570 if not fn .is_declaration :
568571 self ._defined .add (fn .name )
@@ -571,13 +574,13 @@ def resolve(self, engine):
571574 """
572575 Fix unresolved symbols if they are defined.
573576 """
574- if Todd :
577+ if config . DEBUG_ARRAY_OPT >= 1 :
575578 print ("RuntimeLinker resolve" , self ._unresolved , self ._defined )
576579 # An iterator to get all unresolved but available symbols
577580 pending = [name for name in self ._unresolved if name in self ._defined ]
578581 # Resolve pending symbols
579582 for name in pending :
580- if Todd :
583+ if config . DEBUG_ARRAY_OPT >= 1 :
581584 print ("name" , name )
582585 # Get runtime address
583586 fnptr = engine .get_function_address (name )
@@ -623,7 +626,7 @@ def _load_defined_symbols(self, mod):
623626 """Extract symbols from the module
624627 """
625628 for gsets in (mod .functions , mod .global_variables ):
626- if Todd :
629+ if config . DEBUG_ARRAY_OPT >= 1 :
627630 print ("_load_defined_symbols" , gsets , self ._defined_symbols )
628631 self ._defined_symbols |= {gv .name for gv in gsets
629632 if not gv .is_declaration }
@@ -632,7 +635,7 @@ def add_module(self, module):
632635 """Override ExecutionEngine.add_module
633636 to keep info about defined symbols.
634637 """
635- if Todd :
638+ if config . DEBUG_ARRAY_OPT >= 1 :
636639 print ("add_module" , module )
637640 self ._load_defined_symbols (module )
638641 return self ._ee .add_module (module )
0 commit comments