[LLVMdev] Disabling certain optimizations at -O1?
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Tue Nov 26 03:57:46 PST 2013
Hi,
there are optimizations, mostly dealing with hoisting/merging common
code including function calls, that breaks stack trace symbolization
in a very bad way.
int f(int x) {
if (x == 1)
report("a");
else if (x == 2)
report("b");
return 0;
}
For example, in the above function (at -O1) both calls to report() are
done from the same PC. As a result, stack trace (from inside report())
will point to the same source line no matter what branch was actually
taken. In practice, these two (or more) lines may be very far from
each other. This makes stack traces misleading and very hard to reason
about.
Mostly, we are running in this issue with sanitizers, where we care
about performance (and therefore don't use -O0), but want stacktraces
to be mostly sane anyway.
http://llvm-reviews.chandlerc.com/D2214
http://llvm-reviews.chandlerc.com/D2215
I've prepared two patches that deal with these issues by disabling
this and similar optimizations when building with sanitizers.
Would it be reasonable to disable these optimizations at -O1 instead?
More information about the llvm-dev
mailing list