attributes #0 = { noinline norecurse nounwind optnone ssp uwtable "darwin-stkchk-strong-link" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "probe-stack"="___chkstk_darwin" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+cx8,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "tune-cpu"="generic" "unsafe-fp-math"="false" "use-soft-float"="false" }
This means you can't then run it through opt and watch it pass by pass get optimized with opt --print-after-all -O3 xyz.ll -S -o abc.ll. Clang doesn't take the --print-after-all flag.What is the purpose of the optnone attribute? Why is Clang preventing later optimization?
Edit: if I had to wager a guess, it’s because someone generated an IR module at some point with -O0 and then re-ran opt to perform a specific non-destructive analysis, at which point LLVM happily ran all of its default passes. So someone decided that initially building with -O0 is equivalent to saying “my code should never be optimized, even in subsequent invocations of the compiler.”
The usual trick I do is clang -S -emit-llvm -O2 -Xclang --disable-llvm-passes.
> Clang doesn't take the --print-after-all flag.
You have to prefix it with -mllvm, e.g., clang -mllvm -print-after-all -O2 foo.cpp.
As for the dominator case: it’s possible that it does need them then. But for a really trivial VLA (like at the level of the function’s frame) it shouldn’t.