Hello,
I am trying to replicate the output from opt -O3 foo.bc -o foo.opt.bc by specifying the individual passes instead of the -O3 flag.
Looking at the passes from opt -O3 foo.bc -o foo.bc -debug-pass=Executions it seems there are two passes being run. When I run the flags indicated for the two passes specified in the ‘Pass Arguments:’ as two sequential opt processes or a single opt process with the concatenated flags I get a different binary result compared to the O3 run. (Note I had to remove the -targetpassconfig flag and add -spec-exec-only-if-divergent-target to the second pass to get my run to match O3’s second pass.)
Comparing the -debug-pass=Executions from my runs with the O3 run, it seems the first pass in my run has additional ‘TargetLibrary Information’, ‘Target Pass Configuration’ and the ‘Module Pass Manager’ entries compared to O3 (copied below). My output shows the ‘Pass Arguments:’ line has automatically added -targetpassconfig -verify -writebitcode, and the -targetlibinfo flag was moved to the start.
Is there a way I can address these differences to enable replicating the -O3 first and second passes using opt flags?
Thanks for considering this,
-Chad
(Opt -O3 first pass) Pass Arguments: -tti -tbaa -scoped-noalias -assumption-cache-tracker -targetlibinfo -verify -ee-instrument -simplifycfg -domtree -sroa -early-cse -lower-expect
Target Transform Information
Type-Based Alias Analysis
Scoped NoAlias Alias Analysis
Assumption Cache Tracker
Target Library Information
FunctionPass Manager
Module Verifier
Instrument function entry/exit with calls to e.g. mcount() (pre inlining)
Simplify the CFG
Dominator Tree Construction
SROA
Early CSE
Lower ‘expect’ Intrinsics
(My Run): opt in.bc -o out.bc -debug-pass=Executions -tti -tbaa -scoped-noalias -assumption-cache-tracker -targetlibinfo -verify -ee-instrument -simplifycfg -domtree -sroa -early-cse -lower-expect
Pass Arguments: -targetlibinfo -tti -targetpassconfig -tbaa -scoped-noalias -assumption-cache-tracker -verify -ee-instrument -simplifycfg -domtree -sroa -early-cse -lower-expect -verify -write-bitcode
Target Library Information
Target Transform Information
Target Pass Configuration
Type-Based Alias Analysis
Scoped NoAlias Alias Analysis
Assumption Cache Tracker
ModulePass Manager
FunctionPass Manager
Module Verifier
Instrument function entry/exit with calls to e.g. mcount() (pre inlining)
Simplify the CFG
Dominator Tree Construction
SROA
Early CSE
Lower ‘expect’ Intrinsics