[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-02-24 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rL296213: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193) (authored by vedantk). Changed prior to commit: https://reviews.llvm.org/D29369?vs=89733=89752#toc Repository: rL

[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-02-24 Thread Will Dietz via Phabricator via cfe-commits
dtzWill accepted this revision. dtzWill added a comment. This revision is now accepted and ready to land. Sorry for the delay! LGTM, thanks! https://reviews.llvm.org/D29369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-02-24 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 89733. vsk added a comment. - Make the suggested readability improvements, and fix a comment in the test case. https://reviews.llvm.org/D29369 Files: lib/CodeGen/CGExprScalar.cpp test/CodeGen/compound-assign-overflow.c

[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-02-22 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment. Ping, is the argument in favor of making the change in my last comment satisfactory? https://reviews.llvm.org/D29369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-02-14 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment. In https://reviews.llvm.org/D29369#676521, @dtzWill wrote: > In https://reviews.llvm.org/D29369#673064, @vsk wrote: > > > In https://reviews.llvm.org/D29369#672166, @dtzWill wrote: > > > > > After some thought, can we discuss why this is a good idea? > > > > > > The goal is

[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-02-14 Thread Will Dietz via Phabricator via cfe-commits
dtzWill added a comment. In https://reviews.llvm.org/D29369#673064, @vsk wrote: > In https://reviews.llvm.org/D29369#672166, @dtzWill wrote: > > > After some thought, can we discuss why this is a good idea? > > > The goal is to lower ubsan's compile-time + instrumentation overhead at -O0, >

[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-02-09 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment. In https://reviews.llvm.org/D29369#672166, @dtzWill wrote: > After some thought, can we discuss why this is a good idea? The goal is to lower ubsan's compile-time + instrumentation overhead at -O0, since this reduces the friction of debugging a ubsan-instrumented project.

[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-02-09 Thread Will Dietz via Phabricator via cfe-commits
dtzWill requested changes to this revision. dtzWill added a comment. This revision now requires changes to proceed. After some thought, can we discuss why this is a good idea? This increases the cyclomatic complexity of code that already is difficult to reason about, and seems like it's both

[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-02-09 Thread Will Dietz via Phabricator via cfe-commits
dtzWill accepted this revision. dtzWill added a comment. I've been bitten when attempting to use existence/nature of casts in the AST to reason about the original code, but this looks like it does the right thing in all the situations I can think of. Missing overflows because of a bugged

[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-02-09 Thread John Regehr via Phabricator via cfe-commits
regehr added a comment. Paging @dtzWill https://reviews.llvm.org/D29369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-02-09 Thread Filipe Cabecinhas via Phabricator via cfe-commits
filcab added a comment. Minor nits, now. LGTM, but having someone more familiar with clang chime in would be great. Comment at: lib/CodeGen/CGExprScalar.cpp:1700 case LangOptions::SOB_Trapping: +if (getUnwidenedIntegerType(CGF.getContext(), E->getSubExpr()).hasValue())

[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-02-03 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 87030. vsk edited the summary of this revision. vsk added a comment. - Use switches per Filipe's comment, and fix a comment in the test case. https://reviews.llvm.org/D29369 Files: lib/CodeGen/CGExprScalar.cpp test/CodeGen/compound-assign-overflow.c

[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-02-03 Thread Vedant Kumar via Phabricator via cfe-commits
vsk marked an inline comment as done. vsk added a comment. In https://reviews.llvm.org/D29369#666308, @vsk wrote: > In https://reviews.llvm.org/D29369#665878, @filcab wrote: > > > Why the switch to `if` instead of a fully-covered switch/case? > > > It lets me avoid repeating two function calls:

[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-02-03 Thread Filipe Cabecinhas via Phabricator via cfe-commits
filcab added a comment. Why the switch to `if` instead of a fully-covered switch/case? In https://reviews.llvm.org/D29369#664426, @vsk wrote: > In https://reviews.llvm.org/D29369#664366, @regehr wrote: > > > Out of curiosity, how many of these superfluous checks are not subsequently > >

[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-02-01 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment. In https://reviews.llvm.org/D29369#664366, @regehr wrote: > Out of curiosity, how many of these superfluous checks are not subsequently > eliminated by InstCombine? I don't have numbers from a benchmark prepped. Here's what we get with the 'ubsan-promoted-arith.cpp' test

[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-02-01 Thread John Regehr via Phabricator via cfe-commits
regehr added a comment. Out of curiosity, how many of these superfluous checks are not subsequently eliminated by InstCombine? https://reviews.llvm.org/D29369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-02-01 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 86746. vsk edited the summary of this revision. vsk added a comment. - Remove a stale test case in unsigned-promotion.c. https://reviews.llvm.org/D29369 Files: lib/CodeGen/CGExprScalar.cpp test/CodeGen/compound-assign-overflow.c

[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-02-01 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 86739. vsk marked an inline comment as done. vsk added a comment. - Per Eli's comment: check that integers are actually widened, instead of incorrectly assuming they are always widened. I added some test cases for this. - Address the 'fixme' regarding

[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-02-01 Thread Vedant Kumar via Phabricator via cfe-commits
vsk marked an inline comment as done. vsk added inline comments. Comment at: lib/CodeGen/CGExprScalar.cpp:72 + if (const auto *UO = dyn_cast(Op.E)) +return IsPromotedInteger(UO->getSubExpr()); + efriedma wrote: > Checking isPromotableIntegerType doesn't

[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-02-01 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments. Comment at: lib/CodeGen/CGExprScalar.cpp:72 + if (const auto *UO = dyn_cast(Op.E)) +return IsPromotedInteger(UO->getSubExpr()); + Checking isPromotableIntegerType doesn't work the way you want it to; types can be "promoted"

[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

2017-01-31 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision. C requires the operands of arithmetic expressions to be promoted if their types are smaller than an int. Ubsan emits overflow checks when this sort of type promotion occurs, even if there is no way to actually get an overflow with the promoted type. This patch teaches