Some small improvements to dead code elimination; helps a bit on

LLVM-Code-Symbols test.

llvm-svn: 92152
This commit is contained in:
Eli Friedman 2009-12-25 05:29:40 +00:00
parent fddc26cc64
commit 2e06e8bbcc
2 changed files with 10 additions and 1 deletions

View 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");

View 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;
}