diff options
author | Juneyoung Lee <aqjune@gmail.com> | 2021-01-01 04:46:10 +0900 |
---|---|---|
committer | Juneyoung Lee <aqjune@gmail.com> | 2021-01-01 04:46:10 +0900 |
commit | 5cdf6ed744896a23ebc3f723ee2abcfc88137da0 (patch) | |
tree | b860da2c75e19fd1506d0cd11c310a571f48bc71 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | 509fa8e02e25a610574c0fc2cceea1d350c35a66 (diff) | |
download | llvm-5cdf6ed744896a23ebc3f723ee2abcfc88137da0.zip llvm-5cdf6ed744896a23ebc3f723ee2abcfc88137da0.tar.gz llvm-5cdf6ed744896a23ebc3f723ee2abcfc88137da0.tar.bz2 |
[CodeGen] recognize select form of and/ors when splitting branch conditions
Recently a few patches are made to move towards using select i1 instead of and/or i1 to represent "a && b"/"a || b" in C/C++.
"a && b" in C/C++ does not evaluate b if a is false whereas 'and a, b' in IR evaluates b and uses its result regardless of the result of a.
This is problematic because it can cause miscompilation if b was an erroneous operation (https://llvm.org/pr48353).
In C/C++, the result is simply false because b is not evaluated, but in IR the result is poison.
The discussion at D93065 has more context about this.
This patch makes two branch-splitting optimizations (one in SelectionDAGBuilder, one in CodeGenPrepare) recognize
select form of and/or as well using m_LogicalAnd/Or.
Since it is CodeGen, I think this is semantically ok (at least as safe as what codegen already did).
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D93853
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
0 files changed, 0 insertions, 0 deletions