aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGStmt.cpp
diff options
context:
space:
mode:
authorRoman Divacky <rdivacky@FreeBSD.org>2010-05-27 15:17:06 +0000
committerRoman Divacky <rdivacky@FreeBSD.org>2010-05-27 15:17:06 +0000
commitd7279c4c177bca357ef96ff1379fd9bc420bfe83 (patch)
tree3558f327a6f9ab59c5d7a06528d84e1560445247 /lib/CodeGen/CGStmt.cpp
parentbe17651f5cd2e94922c1b732bc8589e180698193 (diff)
downloadsrc-d7279c4c177bca357ef96ff1379fd9bc420bfe83.tar.gz
src-d7279c4c177bca357ef96ff1379fd9bc420bfe83.zip
Update clang to r104832.vendor/clang/clang-r104832
Notes
Notes: svn path=/vendor/clang/dist/; revision=208600 svn path=/vendor/clang/clang-r104832/; revision=208977; tag=vendor/clang/clang-r104832
Diffstat (limited to 'lib/CodeGen/CGStmt.cpp')
-rw-r--r--lib/CodeGen/CGStmt.cpp31
1 files changed, 24 insertions, 7 deletions
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp
index a914c80da2ac..efde3807111f 100644
--- a/lib/CodeGen/CGStmt.cpp
+++ b/lib/CodeGen/CGStmt.cpp
@@ -30,7 +30,10 @@ using namespace CodeGen;
void CodeGenFunction::EmitStopPoint(const Stmt *S) {
if (CGDebugInfo *DI = getDebugInfo()) {
- DI->setLocation(S->getLocStart());
+ if (isa<DeclStmt>(S))
+ DI->setLocation(S->getLocEnd());
+ else
+ DI->setLocation(S->getLocStart());
DI->EmitStopPoint(CurFn, Builder);
}
}
@@ -76,8 +79,11 @@ void CodeGenFunction::EmitStmt(const Stmt *S) {
// Expression emitters don't handle unreachable blocks yet, so look for one
// explicitly here. This handles the common case of a call to a noreturn
// function.
+ // We can't erase blocks with an associated cleanup size here since the
+ // memory might be reused, leaving the old cleanup info pointing at a new
+ // block.
if (llvm::BasicBlock *CurBB = Builder.GetInsertBlock()) {
- if (CurBB->empty() && CurBB->use_empty()) {
+ if (CurBB->empty() && CurBB->use_empty() && !BlockScopes.count(CurBB)) {
CurBB->eraseFromParent();
Builder.ClearInsertionPoint();
}
@@ -484,8 +490,6 @@ void CodeGenFunction::EmitDoStmt(const DoStmt &S) {
}
void CodeGenFunction::EmitForStmt(const ForStmt &S) {
- // FIXME: What do we do if the increment (f.e.) contains a stmt expression,
- // which contains a continue/break?
CleanupScope ForScope(*this);
// Evaluate the first part before the loop.
@@ -555,14 +559,14 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S) {
EmitStmt(S.getBody());
}
- BreakContinueStack.pop_back();
-
// If there is an increment, emit it next.
if (S.getInc()) {
EmitBlock(IncBlock);
EmitStmt(S.getInc());
}
+ BreakContinueStack.pop_back();
+
// Finally, branch back up to the condition for the next iteration.
if (CondCleanup) {
// Branch to the cleanup block.
@@ -604,7 +608,20 @@ void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) {
// FIXME: Clean this up by using an LValue for ReturnTemp,
// EmitStoreThroughLValue, and EmitAnyExpr.
- if (!ReturnValue) {
+ if (S.getNRVOCandidate() && S.getNRVOCandidate()->isNRVOVariable() &&
+ !Target.useGlobalsForAutomaticVariables()) {
+ // Apply the named return value optimization for this return statement,
+ // which means doing nothing: the appropriate result has already been
+ // constructed into the NRVO variable.
+
+ // If there is an NRVO flag for this variable, set it to 1 into indicate
+ // that the cleanup code should not destroy the variable.
+ if (llvm::Value *NRVOFlag = NRVOFlags[S.getNRVOCandidate()]) {
+ const llvm::Type *BoolTy = llvm::Type::getInt1Ty(VMContext);
+ llvm::Value *One = llvm::ConstantInt::get(BoolTy, 1);
+ Builder.CreateStore(One, NRVOFlag);
+ }
+ } else if (!ReturnValue) {
// Make sure not to return anything, but evaluate the expression
// for side effects.
if (RV)