X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;ds=sidebyside;f=utils%2Ffindmisopt;h=f2a872c6dc3e70f85f3fa4f4e26fa25d529756f8;hb=adf01b3f18442ae8db6b8948e70d82d9df415119;hp=f8099a98dbcbc6a45b042adf607ad4dbf143decf;hpb=ba07a6922289d65690ce5f39301cd7e75c97d89e;p=oota-llvm.git diff --git a/utils/findmisopt b/utils/findmisopt index f8099a98dbc..f2a872c6dc3 100755 --- a/utils/findmisopt +++ b/utils/findmisopt @@ -7,7 +7,7 @@ # it from finding a problem unless the set of failing optimizations are # known and given to it on the command line. # -# Given a bytecode file that produces correct output (or return code), +# Given a bitcode file that produces correct output (or return code), # this script will run through all the optimizations passes that gccas # uses (in the same order) and will narrow down which optimizations # cause the program either generate different output or return a @@ -21,11 +21,13 @@ # # Where: # bcfile -# is the bytecode file input (the unoptimized working case) +# is the bitcode file input (the unoptimized working case) # outdir # is a directory into which intermediate results are placed # progargs # is a single argument containing all the arguments the program needs +# proginput +# is a file name from which stdin should be directed # match # if specified to any value causes the result code of the program to # be used to determine success/fail. If not specified success/fail is @@ -50,7 +52,11 @@ fi bcfile="$1" outdir="$2" args="$3" -match="$4" +input="$4" +if [ ! -f "$input" ] ; then + input="/dev/null" +fi +match="$5" name=`basename $bcfile .bc` ll="$outdir/${name}.ll" s="$outdir/${name}.s" @@ -61,11 +67,19 @@ optll="$outdir/${name}.opt.ll" opts="$outdir/${name}.opt.s" optprog="$outdir/${name}.opt" optout="$outdir/${name}.opt.out" +ldflags="-lstdc++ -lm -ldl -lc" echo "Test Name: $name" echo "Unoptimized program: $prog" echo " Optimized program: $optprog" +# Define the list of optimizations to run. This comprises the same set of +# optimizations that opt -std-compile-opts and gccld run, in the same order. +opt_switches=`llvm-as < /dev/null -o - | opt -std-compile-opts -disable-output -debug-pass=Arguments 2>&1 | sed 's/Pass Arguments: //'` +ld_switches=`llvm-as < /dev/null -o - | llvm-ld - -debug-pass=Arguments 2>&1 | sed 's/Pass Arguments: //'` +all_switches="$opt_switches $ld_switches" +echo "Passes : $all_switches" + # Create output directory if it doesn't exist if [ -f "$outdir" ] ; then echo "$outdir is not a directory" @@ -79,16 +93,11 @@ fi # Generate the disassembly llvm-dis "$bcfile" -o "$ll" -f || exit 1 -# Generate the non-optimized program +# Generate the non-optimized program and its output llc "$bcfile" -o "$s" -f || exit 1 -gcc "$s" -o "$prog" -lstdc++ -lc -lm || exit 1 - -# Define the list of optimizations to run. This comprises the same set of -# optimizations that gccas and gccld run, in the same order. -all_switches="-verify -lowersetjmp -funcresolve -raiseallocs -simplifycfg -mem2reg -globalopt -globaldce -ipconstprop -deadargelim -instcombine -simplifycfg -prune-eh -inline -simplify-libcalls -argpromotion -raise -tailduplicate -simplifycfg -scalarrepl -instcombine -predsimplify -condprop -tailcallelim -simplifycfg -reassociate -licm -loop-unswitch -instcombine -indvars -loop-unroll -instcombine -load-vn -gcse -sccp -instcombine -condprop -dse -dce -simplifycfg -deadtypeelim -constmerge -funcresolve -internalize -ipsccp -globalopt -constmerge -deadargelim -inline -prune-eh -globalopt -globaldce -argpromotion -instcombine -predsimplify -scalarrepl -globalsmodref-aa -licm -load-vn -gcse -dse -instcombine -simplifycfg -verify" -# Here's an alternative list of optimizations comprising just the ones that -# gccld uses. To use, just comment out the line above, and uncomment this one -#all_switches="-funcresolve -internalize -ipsccp -globalopt -constmerge -deadargelim -inline -prune-eh -globalopt -globaldce -argpromotion -instcombine -predsimplify -scalarrepl -globalsmodref-aa -licm -load-vn -gcse -dse -instcombine -simplifycfg -verify" +gcc "$s" -o "$prog" $ldflags || exit 1 +"$prog" $args > "$out" 2>&1 <$input +ex1=$? # Current set of switches is empty function tryit { @@ -96,10 +105,8 @@ function tryit { opt $switches_to_use "$bcfile" -o "$optbc" -f || exit llvm-dis "$optbc" -o "$optll" -f || exit llc "$optbc" -o "$opts" -f || exit - gcc "$opts" -o "$optprog" -lstdc++ -lc -lm || exit - "$prog" $args > "$out" 2>&1 - ex1=$? - "$optprog" $args > "$optout" 2>&1 + gcc "$opts" -o "$optprog" $ldflags || exit + "$optprog" $args > "$optout" 2>&1 <"$input" ex2=$? if [ -n "$match" ] ; then