]> granicus.if.org Git - clang/commitdiff
Some small improvements to dead code elimination; helps a bit on
authorEli Friedman <eli.friedman@gmail.com>
Fri, 25 Dec 2009 05:29:40 +0000 (05:29 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Fri, 25 Dec 2009 05:29:40 +0000 (05:29 +0000)
LLVM-Code-Symbols test.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92152 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExpr.cpp
lib/CodeGen/CodeGenModule.cpp

index fbeb40cefc0fe40b4a0e0f38ccebd7f065863324..e3353149ea539b07f3aa95b59ac2a83d1747f606 100644 (file)
@@ -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");
index 761f34309bd6586c94aa595891ba49f47c1af6d6..a7e0552050886f28235a44c8c60c6f6f525aacd8 100644 (file)
@@ -546,7 +546,7 @@ bool CodeGenModule::MayDeferGeneration(const ValueDecl *Global) {
     // static, static inline, always_inline, and extern inline functions can
     // always be deferred.  Normal inline functions can be deferred in C99/C++.
     if (Linkage == GVA_Internal || Linkage == GVA_C99Inline ||
-        Linkage == GVA_CXXInline)
+        Linkage == GVA_CXXInline || Linkage == GVA_TemplateInstantiation)
       return true;
     return false;
   }