diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2009-12-25 05:29:40 +0000 |
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2009-12-25 05:29:40 +0000 |
| commit | ab189950908fc08dd2533692f0e8253e807c73ac (patch) | |
| tree | 6c19a1251ded30dc4081267179464da5a5713c94 /lib/CodeGen/CGExpr.cpp | |
| parent | cb48f8a60ad26b56d299cca9a57f8ea683d8a909 (diff) | |
Some small improvements to dead code elimination; helps a bit on
LLVM-Code-Symbols test.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92152 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
| -rw-r--r-- | lib/CodeGen/CGExpr.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index fbeb40cefc..e3353149ea 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -1378,6 +1378,15 @@ LValue CodeGenFunction::EmitCompoundLiteralLValue(const CompoundLiteralExpr* E){ LValue CodeGenFunction::EmitConditionalOperatorLValue(const ConditionalOperator* E) { if (E->isLvalue(getContext()) == Expr::LV_Valid) { + if (int Cond = ConstantFoldsToSimpleInteger(E->getCond())) { + Expr *Live = Cond == 1 ? E->getLHS() : E->getRHS(); + if (Live) + return EmitLValue(Live); + } + + if (!E->getLHS()) + return EmitUnsupportedLValue(E, "conditional operator with missing LHS"); + llvm::BasicBlock *LHSBlock = createBasicBlock("cond.true"); llvm::BasicBlock *RHSBlock = createBasicBlock("cond.false"); llvm::BasicBlock *ContBlock = createBasicBlock("cond.end"); |
