lib/symbioticpy/symbiotic/transform.py
def run(self):
        """
        Compile the program, optimize and slice it and
        return the name of the created bitcode
        """
        restart_counting_time()

        dbg('Running symbiotic-cc for {0}'.format(self._tool.name()))

        self._disable_some_optimizations(self._tool.llvm_version())

        #################### #################### ###################
        # COMPILATION
        #  - compile the code into LLVM bitcode
        #################### #################### ###################

        # compile all given sources
        self._compile_sources()

        # make the path absolute
        self.curfile = os.path.abspath(self.curfile)
        self._save_ll()

        self._get_stats('After compilation ')

        if hasattr(self._tool, 'passes_after_compilation'):
            self.run_opt(self._tool.passes_after_compilation())

        if hasattr(self._tool, 'actions_after_compilation'):
            self._tool.actions_after_compilation(self)

        # unroll the program if desired
        if self.options.unroll_count != 0:
            self.run_opt(['-reg2mem', '-sbt-loop-unroll',
                          '-sbt-loop-unroll-count',
                          str(self.options.unroll_count),
                          '-sbt-loop-unroll-terminate'])

        #################### #################### ###################
        # PREPROCESSING before instrumentation
        #  - prepare the code: remove calls to error functions if
        #    we do not aim for their reachability and link known
        #    functions that should be unconditionally linked to the
        #    module
        #################### #################### ###################

        # link the files that we got on the command line
        # and that we are required to link in on any circumstances
        self.link_unconditional()

        passes = []
        # NOTE: remove error calls must go first as the other passes
        # may include error calss
        if self.options.property.memsafety() or \
           self.options.property.undefinedness() or \
           self.options.property.signedoverflow() or \
           self.options.property.termination() or \
           self.options.property.memcleanup():
            # remove the original calls to __VERIFIER_error/__assert_fail
            passes.append('-remove-error-calls')

        if self.options.property.memcleanup():
            passes.append('-remove-error-calls-use-exit')

        if not self.options.property.termination():
            passes.append('-remove-infinite-loops')

        if self.options.property.undefinedness() or \
           self.options.property.signedoverflow():
            passes.append('-replace-ubsan')

        if self.options.property.signedoverflow() and \
           not self.options.overflow_with_clang:
            passes.append('-replace-ubsan-just-remove')
            passes.append('-replace-ubsan-keep-shifts')
            passes.append('-prepare-overflows')
            passes.append('-mem2reg')
            passes.append('-break-crit-edges')

        self.run_opt(passes)

        #################### #################### ###################
        # INSTRUMENTATION
        #  - now instrument the code according to the given property
        #################### #################### ###################

        self.instrument()


        #################### #################### ###################
        # POSTPROCESSING after instrumentation
        #  - link functions to the instrumented module
        #################### #################### ###################

        passes = []
        if hasattr(self._tool, 'passes_after_instrumentation'):
            passes = self._tool.passes_after_instrumentation()

        if self.options.property.memsafety():
            # replace llvm.lifetime.start/end with __VERIFIER_scope_enter/leave
            # so that optimizations will not mess the code up
            passes.append('-replace-lifetime-markers')

            # make all store/load insts that are marked by instrumentation
            # volatile, so that we can run optimizations later on them
            passes.append('-mark-volatile')

        if passes:
            self.run_opt(passes)

        #################### #################### ###################
        # SLICING
        #  - slice the code w.r.t error sites
        #################### #################### ###################

        # run optimizations if desired
        passes = get_optlist_before(self.options.optlevel)
        # Special optimizations for slicing.
        # Break the infinite loops just before slicing so that the
        # optimizations won't make them syntactically infinite again. We must
        # run reg2mem before breaking to loops, because breaking the loops can
        # not handle PHI nodes well.
        if not self.options.noslice and 'before-O3' in self.options.optlevel:
            passes += ['-reg2mem', '-break-infinite-loops',
                       '-remove-infinite-loops',
                       '-mem2reg', '-break-crit-loops', '-lowerswitch']
        self.optimize(passes, load_sbt=True)

        if hasattr(self._tool, 'actions_before_slicing'):
            self._tool.actions_before_slicing(self)

        if self.options.link_files_before_slicing:
            self.link_undefined(self.options.link_files_before_slicing)

        # remember the non-sliced llvmfile
        self.nonsliced_llvmfile = self.curfile

        if hasattr(self._tool, 'passes_before_slicing'):
            passes = self._tool.passes_before_slicing()
            if passes:
                self.run_opt(passes)

        if not self.options.noslice:
            self.perform_slicing()

        # start a new time era
        restart_counting_time()

        if hasattr(self._tool, 'actions_after_slicing'):
            self._tool.actions_after_slicing(self)

        #################### #################### ###################
        # POSTPROCESSING after slicing
        #  - prepare the code to be passed to the verification tool
        #    after all the transformations
        #################### #################### ###################
        self.postprocessing()

        if not self.options.final_output is None:
            # copy the file to final_output
            try:
                dbg("Renaming the final file from '{0}' to '{1}'"\
                    .format(self.curfile, self.options.final_output))
                if self.options.generate_ll and\
                    self.options.final_output.endswith('.ll'):
                    self._generate_ll(self.options.final_output)
                else:
                    move(self.curfile, self.options.final_output)
                    self.curfile = self.options.final_output
                    self._generate_ll()
            except OSError as e:
                msg = 'Cannot create {0}: {1}'.format(
                    self.options.final_output, str(e))
                raise SymbioticException(msg)

        return self.curfile

        Compile the program, optimize and slice it and
        return the name of the created bitcode
        
Compile the program, optimize and slice it and
return the name of the created bitcode
Compile the program optimize and slice it and return the name of the created bitcode
def run(self):
        restart_counting_time()
        dbg('Running symbiotic-cc for {0}'.format(self._tool.name()))
        self._disable_some_optimizations(self._tool.llvm_version())
        self._compile_sources()
        self.curfile = os.path.abspath(self.curfile)
        self._save_ll()
        self._get_stats('After compilation ')
        if hasattr(self._tool, 'passes_after_compilation'):
            self.run_opt(self._tool.passes_after_compilation())
        if hasattr(self._tool, 'actions_after_compilation'):
            self._tool.actions_after_compilation(self)
        if self.options.unroll_count != 0:
            self.run_opt(['-reg2mem', '-sbt-loop-unroll',
                          '-sbt-loop-unroll-count',
                          str(self.options.unroll_count),
                          '-sbt-loop-unroll-terminate'])
        self.link_unconditional()
        passes = []
        if self.options.property.memsafety() or \
           self.options.property.undefinedness() or \
           self.options.property.signedoverflow() or \
           self.options.property.termination() or \
           self.options.property.memcleanup():
            passes.append('-remove-error-calls')
        if self.options.property.memcleanup():
            passes.append('-remove-error-calls-use-exit')
        if not self.options.property.termination():
            passes.append('-remove-infinite-loops')
        if self.options.property.undefinedness() or \
           self.options.property.signedoverflow():
            passes.append('-replace-ubsan')
        if self.options.property.signedoverflow() and \
           not self.options.overflow_with_clang:
            passes.append('-replace-ubsan-just-remove')
            passes.append('-replace-ubsan-keep-shifts')
            passes.append('-prepare-overflows')
            passes.append('-mem2reg')
            passes.append('-break-crit-edges')
        self.run_opt(passes)
        self.instrument()
        passes = []
        if hasattr(self._tool, 'passes_after_instrumentation'):
            passes = self._tool.passes_after_instrumentation()
        if self.options.property.memsafety():
            passes.append('-replace-lifetime-markers')
            passes.append('-mark-volatile')
        if passes:
            self.run_opt(passes)
        passes = get_optlist_before(self.options.optlevel)
        if not self.options.noslice and 'before-O3' in self.options.optlevel:
            passes += ['-reg2mem', '-break-infinite-loops',
                       '-remove-infinite-loops',
                       '-mem2reg', '-break-crit-loops', '-lowerswitch']
        self.optimize(passes, load_sbt=True)
        if hasattr(self._tool, 'actions_before_slicing'):
            self._tool.actions_before_slicing(self)
        if self.options.link_files_before_slicing:
            self.link_undefined(self.options.link_files_before_slicing)
        self.nonsliced_llvmfile = self.curfile
        if hasattr(self._tool, 'passes_before_slicing'):
            passes = self._tool.passes_before_slicing()
            if passes:
                self.run_opt(passes)
        if not self.options.noslice:
            self.perform_slicing()
        restart_counting_time()
        if hasattr(self._tool, 'actions_after_slicing'):
            self._tool.actions_after_slicing(self)
        self.postprocessing()
        if not self.options.final_output is None:
            try:
                dbg("Renaming the final file from '{0}' to '{1}'"\
                    .format(self.curfile, self.options.final_output))
                if self.options.generate_ll and\
                    self.options.final_output.endswith('.ll'):
                    self._generate_ll(self.options.final_output)
                else:
                    move(self.curfile, self.options.final_output)
                    self.curfile = self.options.final_output
                    self._generate_ll()
            except OSError as e:
                msg = 'Cannot create {0}: {1}'.format(
                    self.options.final_output, str(e))
                raise SymbioticException(msg)
        return self.curfile
def run ( self ) : restart_counting_time ( ) dbg ( 'Running symbiotic-cc for {0}' . format ( self . _tool . name ( ) ) ) self . _disable_some_optimizations ( self . _tool . llvm_version ( ) ) self . _compile_sources ( ) self . curfile = os . path . abspath ( self . curfile ) self . _save_ll ( ) self . _get_stats ( 'After compilation ' ) if hasattr ( self . _tool , 'passes_after_compilation' ) : self . run_opt ( self . _tool . passes_after_compilation ( ) ) if hasattr ( self . _tool , 'actions_after_compilation' ) : self . _tool . actions_after_compilation ( self ) if self . options . unroll_count != 0 : self . run_opt ( [ '-reg2mem' , '-sbt-loop-unroll' , '-sbt-loop-unroll-count' , str ( self . options . unroll_count ) , '-sbt-loop-unroll-terminate' ] ) self . link_unconditional ( ) passes = [ ] if self . options . property . memsafety ( ) or self . options . property . undefinedness ( ) or self . options . property . signedoverflow ( ) or self . options . property . termination ( ) or self . options . property . memcleanup ( ) : passes . append ( '-remove-error-calls' ) if self . options . property . memcleanup ( ) : passes . append ( '-remove-error-calls-use-exit' ) if not self . options . property . termination ( ) : passes . append ( '-remove-infinite-loops' ) if self . options . property . undefinedness ( ) or self . options . property . signedoverflow ( ) : passes . append ( '-replace-ubsan' ) if self . options . property . signedoverflow ( ) and not self . options . overflow_with_clang : passes . append ( '-replace-ubsan-just-remove' ) passes . append ( '-replace-ubsan-keep-shifts' ) passes . append ( '-prepare-overflows' ) passes . append ( '-mem2reg' ) passes . append ( '-break-crit-edges' ) self . run_opt ( passes ) self . instrument ( ) passes = [ ] if hasattr ( self . _tool , 'passes_after_instrumentation' ) : passes = self . _tool . passes_after_instrumentation ( ) if self . options . property . memsafety ( ) : passes . append ( '-replace-lifetime-markers' ) passes . append ( '-mark-volatile' ) if passes : self . run_opt ( passes ) passes = get_optlist_before ( self . options . optlevel ) if not self . options . noslice and 'before-O3' in self . options . optlevel : passes += [ '-reg2mem' , '-break-infinite-loops' , '-remove-infinite-loops' , '-mem2reg' , '-break-crit-loops' , '-lowerswitch' ] self . optimize ( passes , load_sbt = True ) if hasattr ( self . _tool , 'actions_before_slicing' ) : self . _tool . actions_before_slicing ( self ) if self . options . link_files_before_slicing : self . link_undefined ( self . options . link_files_before_slicing ) self . nonsliced_llvmfile = self . curfile if hasattr ( self . _tool , 'passes_before_slicing' ) : passes = self . _tool . passes_before_slicing ( ) if passes : self . run_opt ( passes ) if not self . options . noslice : self . perform_slicing ( ) restart_counting_time ( ) if hasattr ( self . _tool , 'actions_after_slicing' ) : self . _tool . actions_after_slicing ( self ) self . postprocessing ( ) if not self . options . final_output is None : try : dbg ( "Renaming the final file from '{0}' to '{1}'" . format ( self . curfile , self . options . final_output ) ) if self . options . generate_ll and self . options . final_output . endswith ( '.ll' ) : self . _generate_ll ( self . options . final_output ) else : move ( self . curfile , self . options . final_output ) self . curfile = self . options . final_output self . _generate_ll ( ) except OSError as e : msg = 'Cannot create {0}: {1}' . format ( self . options . final_output , str ( e ) ) raise SymbioticException ( msg ) return self . curfile
Compile the program, optimize and slice it and
return the name of the created bitcode
Compile the program optimize and slice it and return the name of the created bitcode
"""
        Compile the program, optimize and slice it and
        return the name of the created bitcode
        """ #################### #################### ################### # COMPILATION #  - compile the code into LLVM bitcode #################### #################### ################### # compile all given sources # make the path absolute # unroll the program if desired #################### #################### ################### # PREPROCESSING before instrumentation #  - prepare the code: remove calls to error functions if #    we do not aim for their reachability and link known #    functions that should be unconditionally linked to the #    module #################### #################### ################### # link the files that we got on the command line # and that we are required to link in on any circumstances # NOTE: remove error calls must go first as the other passes # may include error calss # remove the original calls to __VERIFIER_error/__assert_fail #################### #################### ################### # INSTRUMENTATION #  - now instrument the code according to the given property #################### #################### ################### #################### #################### ################### # POSTPROCESSING after instrumentation #  - link functions to the instrumented module #################### #################### ################### # replace llvm.lifetime.start/end with __VERIFIER_scope_enter/leave # so that optimizations will not mess the code up # make all store/load insts that are marked by instrumentation # volatile, so that we can run optimizations later on them #################### #################### ################### # SLICING #  - slice the code w.r.t error sites #################### #################### ################### # run optimizations if desired # Special optimizations for slicing. # Break the infinite loops just before slicing so that the # optimizations won't make them syntactically infinite again. We must # run reg2mem before breaking to loops, because breaking the loops can # not handle PHI nodes well. # remember the non-sliced llvmfile # start a new time era #################### #################### ################### # POSTPROCESSING after slicing #  - prepare the code to be passed to the verification tool #    after all the transformations #################### #################### ################### # copy the file to final_output
self