Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/CodeGen/CGStmt.cpp
Show First 20 Lines • Show All 798 Lines • ▼ Show 20 Lines | if (C->isOne()) { | ||||
if (CWithProgress()) | if (CWithProgress()) | ||||
FnIsMustProgress = false; | FnIsMustProgress = false; | ||||
else if (CPlusPlusWithProgress()) | else if (CPlusPlusWithProgress()) | ||||
LoopMustProgress = true; | LoopMustProgress = true; | ||||
} | } | ||||
} else if (LanguageRequiresProgress()) | } else if (LanguageRequiresProgress()) | ||||
LoopMustProgress = true; | LoopMustProgress = true; | ||||
if (CGM.getCodeGenOpts().FiniteLoops == | |||||
CodeGenOptions::FiniteLoopsKind::Enforce) { | |||||
FnIsMustProgress = true; | |||||
LoopMustProgress = true; | |||||
} else if (CGM.getCodeGenOpts().FiniteLoops == | |||||
CodeGenOptions::FiniteLoopsKind::NeverEnforce) { | |||||
FnIsMustProgress = false; | |||||
LoopMustProgress = false; | |||||
} | |||||
const SourceRange &R = S.getSourceRange(); | const SourceRange &R = S.getSourceRange(); | ||||
LoopStack.push(LoopHeader.getBlock(), CGM.getContext(), CGM.getCodeGenOpts(), | LoopStack.push(LoopHeader.getBlock(), CGM.getContext(), CGM.getCodeGenOpts(), | ||||
WhileAttrs, SourceLocToDebugLoc(R.getBegin()), | WhileAttrs, SourceLocToDebugLoc(R.getBegin()), | ||||
SourceLocToDebugLoc(R.getEnd()), LoopMustProgress); | SourceLocToDebugLoc(R.getEnd()), LoopMustProgress); | ||||
// As long as the condition is true, go to the loop body. | // As long as the condition is true, go to the loop body. | ||||
llvm::BasicBlock *LoopBody = createBasicBlock("while.body"); | llvm::BasicBlock *LoopBody = createBasicBlock("while.body"); | ||||
if (EmitBoolCondBranch) { | if (EmitBoolCondBranch) { | ||||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | if (C->isZero()) | ||||
EmitBoolCondBranch = false; | EmitBoolCondBranch = false; | ||||
else if (C->isOne() && CWithProgress()) | else if (C->isOne() && CWithProgress()) | ||||
FnIsMustProgress = false; | FnIsMustProgress = false; | ||||
else if (CPlusPlusWithProgress()) | else if (CPlusPlusWithProgress()) | ||||
LoopMustProgress = true; | LoopMustProgress = true; | ||||
} else if (LanguageRequiresProgress()) | } else if (LanguageRequiresProgress()) | ||||
LoopMustProgress = true; | LoopMustProgress = true; | ||||
if (CGM.getCodeGenOpts().FiniteLoops == | |||||
CodeGenOptions::FiniteLoopsKind::Enforce) { | |||||
FnIsMustProgress = true; | |||||
LoopMustProgress = true; | |||||
} else if (CGM.getCodeGenOpts().FiniteLoops == | |||||
CodeGenOptions::FiniteLoopsKind::NeverEnforce) { | |||||
FnIsMustProgress = false; | |||||
LoopMustProgress = false; | |||||
} | |||||
const SourceRange &R = S.getSourceRange(); | const SourceRange &R = S.getSourceRange(); | ||||
LoopStack.push(LoopBody, CGM.getContext(), CGM.getCodeGenOpts(), DoAttrs, | LoopStack.push(LoopBody, CGM.getContext(), CGM.getCodeGenOpts(), DoAttrs, | ||||
SourceLocToDebugLoc(R.getBegin()), | SourceLocToDebugLoc(R.getBegin()), | ||||
SourceLocToDebugLoc(R.getEnd()), LoopMustProgress); | SourceLocToDebugLoc(R.getEnd()), LoopMustProgress); | ||||
// As long as the condition is true, iterate the loop. | // As long as the condition is true, iterate the loop. | ||||
if (EmitBoolCondBranch) { | if (EmitBoolCondBranch) { | ||||
uint64_t BackedgeCount = getProfileCount(S.getBody()) - ParentCount; | uint64_t BackedgeCount = getProfileCount(S.getBody()) - ParentCount; | ||||
Show All 36 Lines | void CodeGenFunction::EmitForStmt(const ForStmt &S, | ||||
if (LanguageRequiresProgress()) { | if (LanguageRequiresProgress()) { | ||||
if (!S.getCond() && CWithProgress()) | if (!S.getCond() && CWithProgress()) | ||||
FnIsMustProgress = false; | FnIsMustProgress = false; | ||||
else if (CPlusPlusWithProgress() || | else if (CPlusPlusWithProgress() || | ||||
!S.getCond()->EvaluateAsInt(Result, getContext())) | !S.getCond()->EvaluateAsInt(Result, getContext())) | ||||
LoopMustProgress = true; | LoopMustProgress = true; | ||||
} | } | ||||
if (CGM.getCodeGenOpts().FiniteLoops == | |||||
CodeGenOptions::FiniteLoopsKind::Enforce) { | |||||
LoopMustProgress = true; | |||||
} else if (CGM.getCodeGenOpts().FiniteLoops == | |||||
CodeGenOptions::FiniteLoopsKind::NeverEnforce) { | |||||
LoopMustProgress = false; | |||||
} | |||||
const SourceRange &R = S.getSourceRange(); | const SourceRange &R = S.getSourceRange(); | ||||
LoopStack.push(CondBlock, CGM.getContext(), CGM.getCodeGenOpts(), ForAttrs, | LoopStack.push(CondBlock, CGM.getContext(), CGM.getCodeGenOpts(), ForAttrs, | ||||
SourceLocToDebugLoc(R.getBegin()), | SourceLocToDebugLoc(R.getBegin()), | ||||
SourceLocToDebugLoc(R.getEnd()), LoopMustProgress); | SourceLocToDebugLoc(R.getEnd()), LoopMustProgress); | ||||
// If the for loop doesn't have an increment we can just use the | // If the for loop doesn't have an increment we can just use the | ||||
// condition as the continue block. Otherwise we'll need to create | // condition as the continue block. Otherwise we'll need to create | ||||
// a block for it (in the current scope, i.e. in the scope of the | // a block for it (in the current scope, i.e. in the scope of the | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | if (S.getCond()) { | ||||
EmitBlock(ForBody); | EmitBlock(ForBody); | ||||
} else { | } else { | ||||
// Treat it as a non-zero constant. Don't even create a new block for the | // Treat it as a non-zero constant. Don't even create a new block for the | ||||
// body, just fall into it. | // body, just fall into it. | ||||
} | } | ||||
incrementProfileCounter(&S); | incrementProfileCounter(&S); | ||||
if (CGM.getCodeGenOpts().FiniteLoops == | |||||
CodeGenOptions::FiniteLoopsKind::Enforce) { | |||||
FnIsMustProgress = true; | |||||
} else if (CGM.getCodeGenOpts().FiniteLoops == | |||||
CodeGenOptions::FiniteLoopsKind::NeverEnforce) { | |||||
FnIsMustProgress = false; | |||||
} | |||||
{ | { | ||||
// Create a separate cleanup scope for the body, in case it is not | // Create a separate cleanup scope for the body, in case it is not | ||||
// a compound statement. | // a compound statement. | ||||
RunCleanupsScope BodyScope(*this); | RunCleanupsScope BodyScope(*this); | ||||
EmitStmt(S.getBody()); | EmitStmt(S.getBody()); | ||||
} | } | ||||
// If there is an increment, emit it next. | // If there is an increment, emit it next. | ||||
▲ Show 20 Lines • Show All 1,675 Lines • Show Last 20 Lines |