зеркало из https://github.com/microsoft/clang-1.git
Use EmitBranchOnBoolExpr in VisitConditionalOperator. This
shrinks code yet again by a bit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59114 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
31a0984b5c
Коммит
035cf42943
|
@ -1129,14 +1129,23 @@ VisitConditionalOperator(const ConditionalOperator *E) {
|
|||
llvm::BasicBlock *LHSBlock = CGF.createBasicBlock("cond.?");
|
||||
llvm::BasicBlock *RHSBlock = CGF.createBasicBlock("cond.:");
|
||||
llvm::BasicBlock *ContBlock = CGF.createBasicBlock("cond.cont");
|
||||
Value *CondVal = 0;
|
||||
|
||||
// Evaluate the conditional, then convert it to bool. We do this explicitly
|
||||
// because we need the unconverted value if this is a GNU ?: expression with
|
||||
// missing middle value.
|
||||
Value *CondVal = CGF.EmitScalarExpr(E->getCond());
|
||||
Value *CondBoolVal =CGF.EmitScalarConversion(CondVal, E->getCond()->getType(),
|
||||
CGF.getContext().BoolTy);
|
||||
Builder.CreateCondBr(CondBoolVal, LHSBlock, RHSBlock);
|
||||
// If we have the GNU missing condition extension, evaluate the conditional
|
||||
// and then convert it to bool the hard way. We do this explicitly
|
||||
// because we need the unconverted value for the missing middle value of
|
||||
// the ?:.
|
||||
if (E->getLHS() == 0) {
|
||||
CondVal = CGF.EmitScalarExpr(E->getCond());
|
||||
Value *CondBoolVal =
|
||||
CGF.EmitScalarConversion(CondVal, E->getCond()->getType(),
|
||||
CGF.getContext().BoolTy);
|
||||
Builder.CreateCondBr(CondBoolVal, LHSBlock, RHSBlock);
|
||||
} else {
|
||||
// Otherwise, just use EmitBranchOnBoolExpr to get small and simple code for
|
||||
// the branch on bool.
|
||||
CGF.EmitBranchOnBoolExpr(E->getCond(), LHSBlock, RHSBlock);
|
||||
}
|
||||
|
||||
CGF.EmitBlock(LHSBlock);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче