Skip to content

Commit b384d6d

Browse files
authored
[CodeGen] Don't include CGDebugInfo.h in CodeGenFunction.h (NFC) (llvm#134100)
This is an expensive header, only include it where needed. Move some functions out of line to achieve that. This reduces time to build clang by ~0.5% in terms of instructions retired.
1 parent a19c018 commit b384d6d

19 files changed

+53
-29
lines changed

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "ABIInfo.h"
1515
#include "CGCUDARuntime.h"
1616
#include "CGCXXABI.h"
17+
#include "CGDebugInfo.h"
1718
#include "CGObjCRuntime.h"
1819
#include "CGOpenCLRuntime.h"
1920
#include "CGRecordLayout.h"

clang/lib/CodeGen/CGCall.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "CGBlocks.h"
1818
#include "CGCXXABI.h"
1919
#include "CGCleanup.h"
20+
#include "CGDebugInfo.h"
2021
#include "CGRecordLayout.h"
2122
#include "CodeGenFunction.h"
2223
#include "CodeGenModule.h"

clang/lib/CodeGen/CGCoroutine.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "CGCleanup.h"
14+
#include "CGDebugInfo.h"
1415
#include "CodeGenFunction.h"
15-
#include "llvm/ADT/ScopeExit.h"
1616
#include "clang/AST/StmtCXX.h"
1717
#include "clang/AST/StmtVisitor.h"
18+
#include "llvm/ADT/ScopeExit.h"
1819

1920
using namespace clang;
2021
using namespace CodeGen;

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6223,3 +6223,23 @@ CGDebugInfo::createConstantValueExpression(const clang::ValueDecl *VD,
62236223

62246224
return nullptr;
62256225
}
6226+
6227+
CodeGenFunction::LexicalScope::LexicalScope(CodeGenFunction &CGF,
6228+
SourceRange Range)
6229+
: RunCleanupsScope(CGF), Range(Range), ParentScope(CGF.CurLexicalScope) {
6230+
CGF.CurLexicalScope = this;
6231+
if (CGDebugInfo *DI = CGF.getDebugInfo())
6232+
DI->EmitLexicalBlockStart(CGF.Builder, Range.getBegin());
6233+
}
6234+
6235+
CodeGenFunction::LexicalScope::~LexicalScope() {
6236+
if (CGDebugInfo *DI = CGF.getDebugInfo())
6237+
DI->EmitLexicalBlockEnd(CGF.Builder, Range.getEnd());
6238+
6239+
// If we should perform a cleanup, force them now. Note that
6240+
// this ends the cleanup scope before rescoping any labels.
6241+
if (PerformCleanup) {
6242+
ApplyDebugLocation DL(CGF, Range.getEnd());
6243+
ForceCleanup();
6244+
}
6245+
}

clang/lib/CodeGen/CGDeclCXX.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "CGCXXABI.h"
14+
#include "CGDebugInfo.h"
1415
#include "CGHLSLRuntime.h"
1516
#include "CGObjCRuntime.h"
1617
#include "CGOpenMPRuntime.h"

clang/lib/CodeGen/CGException.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "CGCXXABI.h"
1414
#include "CGCleanup.h"
15+
#include "CGDebugInfo.h"
1516
#include "CGObjCRuntime.h"
1617
#include "CodeGenFunction.h"
1718
#include "ConstantEmitter.h"

clang/lib/CodeGen/CGExprAgg.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "CGCXXABI.h"
14+
#include "CGDebugInfo.h"
1415
#include "CGHLSLRuntime.h"
1516
#include "CGObjCRuntime.h"
1617
#include "CGRecordLayout.h"

clang/lib/CodeGen/CGExprComplex.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#include "CGDebugInfo.h"
1314
#include "CGOpenMPRuntime.h"
1415
#include "CodeGenFunction.h"
1516
#include "CodeGenModule.h"

clang/lib/CodeGen/CGNonTrivialStruct.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//
1212
//===----------------------------------------------------------------------===//
1313

14+
#include "CGDebugInfo.h"
1415
#include "CodeGenFunction.h"
1516
#include "CodeGenModule.h"
1617
#include "clang/AST/NonTrivialTypeVisitor.h"

clang/lib/CodeGen/CGOpenMPRuntime.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "ABIInfoImpl.h"
1515
#include "CGCXXABI.h"
1616
#include "CGCleanup.h"
17+
#include "CGDebugInfo.h"
1718
#include "CGRecordLayout.h"
1819
#include "CodeGenFunction.h"
1920
#include "TargetInfo.h"

0 commit comments

Comments
 (0)