Skip to content

Commit 124ada4

Browse files
committed
Move O0 logic to front of codegen, minor test and code fixups
1 parent cde7206 commit 124ada4

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

clang/lib/CodeGen/CGCleanup.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,11 @@ bool EHScopeStack::containsOnlyNoopCleanups(
116116
EHScopeStack::stable_iterator Old) const {
117117
for (EHScopeStack::iterator it = begin(); stabilize(it) != Old; it++) {
118118
EHCleanupScope *cleanup = dyn_cast<EHCleanupScope>(&*it);
119-
if (!cleanup || !(cleanup->isLifetimeMarker() || cleanup->isFakeUse()))
119+
// If this is anything other than a lifetime marker or fake use cleanup,
120+
// then the scope stack does not contain only noop cleanups.
121+
if (!cleanup)
122+
return false;
123+
if (!cleanup->isLifetimeMarker() && !cleanup->isFakeUse())
120124
return false;
121125
}
122126

clang/lib/CodeGen/CGDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1717,7 +1717,7 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
17171717
if (CGM.getCodeGenOpts().ExtendLifetimes) {
17181718
if (extendLifetime(getContext(), CurCodeDecl, D, CXXABIThisDecl))
17191719
EHStack.pushCleanup<FakeUse>(NormalFakeUse,
1720-
emission.getAllocatedAddress());
1720+
emission.getOriginalAllocatedAddress());
17211721
}
17221722

17231723
return emission;

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,6 +1834,13 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
18341834
Opts.setInlining(CodeGenOptions::NormalInlining);
18351835
}
18361836

1837+
// Extended lifetimes are meaningless if we are not going to run any
1838+
// optimizations, so skip them here.
1839+
if (Opts.OptimizationLevel == 0 && !Opts.DisableO0ImplyOptNone) {
1840+
Opts.ExtendLifetimes = false;
1841+
Opts.ExtendThisPtr = false;
1842+
}
1843+
18371844
// PIC defaults to -fno-direct-access-external-data while non-PIC defaults to
18381845
// -fdirect-access-external-data.
18391846
Opts.DirectAccessExternalData =

clang/test/CodeGen/fake-use-landingpad.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 %s -O0 -disable-O0-optnone -emit-llvm -fextend-lifetimes -fexceptions -o - | FileCheck %s --implicit-check-not=landingpad
1+
// RUN: %clang_cc1 %s -O0 -disable-O0-optnone -emit-llvm -fextend-lifetimes -fexceptions -o - | FileCheck %s --implicit-check-not="landingpad {"
22

33
// Check that fake uses do not mistakenly cause a landing pad to be generated when
44
// exceptions are enabled.

0 commit comments

Comments
 (0)