r228021 - Address review feedback for r228003.
Adrian Prantl
aprantl at apple.com
Tue Feb 3 12:00:54 PST 2015
Author: adrian
Date: Tue Feb 3 14:00:54 2015
New Revision: 228021
URL: http://llvm.org/viewvc/llvm-project?rev=228021&view=rev
Log:
Address review feedback for r228003.
- use named constructors
- get rid of MarkAsPrologue
Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGCleanup.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=228021&r1=228020&r2=228021&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Tue Feb 3 14:00:54 2015
@@ -1178,7 +1178,7 @@ CodeGenFunction::GenerateBlockFunction(G
Alloca->setAlignment(Align);
// Set the DebugLocation to empty, so the store is recognized as a
// frame setup instruction by llvm::DwarfDebug::beginFunction().
- ApplyDebugLocation NL(*this, ApplyDebugLocation::MarkAsPrologue);
+ auto NL = ApplyDebugLocation::CreateEmpty(*this);
Builder.CreateAlignedStore(BlockPointer, Alloca, Align);
BlockPointerDbgLoc = Alloca;
}
@@ -1328,11 +1328,10 @@ CodeGenFunction::GenerateCopyHelperFunct
nullptr, SC_Static,
false,
false);
- ApplyDebugLocation NL(*this, ApplyDebugLocation::MarkAsPrologue);
+ auto NL = ApplyDebugLocation::CreateEmpty(*this);
StartFunction(FD, C.VoidTy, Fn, FI, args);
// Create a scope with an artificial location for the body of this function.
- ApplyDebugLocation AL(*this, ApplyDebugLocation::Artificial);
-
+ auto AL = ApplyDebugLocation::CreateArtificial(*this);
llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();
llvm::Value *src = GetAddrOfLocalVar(&srcDecl);
@@ -1500,9 +1499,9 @@ CodeGenFunction::GenerateDestroyHelperFu
nullptr, SC_Static,
false, false);
// Create a scope with an artificial location for the body of this function.
- ApplyDebugLocation NL(*this, ApplyDebugLocation::MarkAsPrologue);
+ auto NL = ApplyDebugLocation::CreateEmpty(*this);
StartFunction(FD, C.VoidTy, Fn, FI, args);
- ApplyDebugLocation AL(*this, ApplyDebugLocation::Artificial);
+ auto AL = ApplyDebugLocation::CreateArtificial(*this);
llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();
Modified: cfe/trunk/lib/CodeGen/CGCleanup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCleanup.cpp?rev=228021&r1=228020&r2=228021&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCleanup.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCleanup.cpp Tue Feb 3 14:00:54 2015
@@ -861,7 +861,7 @@ void CodeGenFunction::PopCleanupBlock(bo
// Emit the EH cleanup if required.
if (RequiresEHCleanup) {
- ApplyDebugLocation AL(*this, ApplyDebugLocation::Artificial, CurEHLocation);
+ auto AL = ApplyDebugLocation::CreateDefaultArtificial(*this, CurEHLocation);
CGBuilderTy::InsertPoint SavedIP = Builder.saveAndClearIP();
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=228021&r1=228020&r2=228021&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Feb 3 14:00:54 2015
@@ -60,18 +60,18 @@ ApplyDebugLocation::ApplyDebugLocation(C
}
ApplyDebugLocation::ApplyDebugLocation(CodeGenFunction &CGF,
- bool MarkAsPrologue,
+ bool DefaultToEmpty,
SourceLocation TemporaryLocation)
: CGF(CGF) {
- init(TemporaryLocation, MarkAsPrologue);
+ init(TemporaryLocation, DefaultToEmpty);
}
void ApplyDebugLocation::init(SourceLocation TemporaryLocation,
- bool MarkAsPrologue) {
+ bool DefaultToEmpty) {
if (auto *DI = CGF.getDebugInfo()) {
OriginalLocation = CGF.Builder.getCurrentDebugLocation();
if (TemporaryLocation.isInvalid()) {
- if (MarkAsPrologue)
+ if (DefaultToEmpty)
CGF.Builder.SetCurrentDebugLocation(llvm::DebugLoc());
else {
// Construct a location that has a valid scope, but no line info.
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=228021&r1=228020&r2=228021&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Tue Feb 3 14:00:54 2015
@@ -447,22 +447,23 @@ private:
/// location or preferred location of the specified Expr.
class ApplyDebugLocation {
private:
- void init(SourceLocation TemporaryLocation, bool MarkAsPrologue = false);
+ void init(SourceLocation TemporaryLocation, bool DefaultToEmpty = false);
+ ApplyDebugLocation(CodeGenFunction &CGF, bool DefaultToEmpty,
+ SourceLocation TemporaryLocation);
-protected:
llvm::DebugLoc OriginalLocation;
CodeGenFunction &CGF;
-
public:
- enum { Artificial = false, MarkAsPrologue = true, NoLocation = true };
/// \brief Set the location to the (valid) TemporaryLocation.
ApplyDebugLocation(CodeGenFunction &CGF, SourceLocation TemporaryLocation);
- /// \brief Apply TemporaryLocation if it is valid, or apply a default
- /// location: If MarkAsPrologue is true, the IRBuilder will be set to not
- /// attach debug locations, thus marking the instructions as
- /// prologue. Otherwise this switches to an artificial debug location that has
- /// a valid scope, but no line information.
+ ApplyDebugLocation(CodeGenFunction &CGF, const Expr *E);
+ ApplyDebugLocation(CodeGenFunction &CGF, llvm::DebugLoc Loc);
+
+ ~ApplyDebugLocation();
+
+ /// \brief Apply TemporaryLocation if it is valid. Otherwise switch to an
+ /// artificial debug location that has a valid scope, but no line information.
///
/// Artificial locations are useful when emitting compiler-generated helper
/// functions that have no source location associated with them. The DWARF
@@ -470,11 +471,32 @@ public:
/// indicate code that can not be attributed to any source location. Note that
/// passing an empty SourceLocation to CGDebugInfo::setLocation() will result
/// in the last valid location being reused.
- ApplyDebugLocation(CodeGenFunction &CGF, bool MarkAsPrologue,
- SourceLocation TemporaryLocation = SourceLocation());
- ApplyDebugLocation(CodeGenFunction &CGF, const Expr *E);
- ApplyDebugLocation(CodeGenFunction &CGF, llvm::DebugLoc Loc);
- ~ApplyDebugLocation();
+ static ApplyDebugLocation CreateArtificial(CodeGenFunction &CGF) {
+ return ApplyDebugLocation(CGF, false, SourceLocation());
+ }
+ /// \brief Apply TemporaryLocation if it is valid. Otherwise switch to an
+ /// artificial debug location that has a valid scope, but no line information.
+ static ApplyDebugLocation CreateDefaultArtificial(CodeGenFunction &CGF,
+ SourceLocation TemporaryLocation) {
+ return ApplyDebugLocation(CGF, false, TemporaryLocation);
+ }
+
+ /// \brief Set the IRBuilder to not attach debug locations. Note that passing
+ /// an empty SourceLocation to CGDebugInfo::setLocation() will result in the
+ /// last valid location being reused. Note that all instructions that do not
+ /// have a location at the beginning of a function are counted towards to
+ /// funciton prologue.
+ static ApplyDebugLocation CreateEmpty(CodeGenFunction &CGF) {
+ return ApplyDebugLocation(CGF, true, SourceLocation());
+ }
+
+ /// \brief Apply TemporaryLocation if it is valid. Otherwise set the IRBuilder
+ /// to not attach debug locations.
+ static ApplyDebugLocation CreateDefaultEmpty(CodeGenFunction &CGF,
+ SourceLocation TemporaryLocation) {
+ return ApplyDebugLocation(CGF, true, TemporaryLocation);
+ }
+
};
Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=228021&r1=228020&r2=228021&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Tue Feb 3 14:00:54 2015
@@ -1090,7 +1090,7 @@ void CodeGenFunction::EmitAutoVarInit(co
if (emission.wasEmittedAsGlobal()) return;
const VarDecl &D = *emission.Variable;
- ApplyDebugLocation DL(*this, ApplyDebugLocation::Artificial, D.getLocation());
+ auto DL = ApplyDebugLocation::CreateDefaultArtificial(*this, D.getLocation());
QualType type = D.getType();
// If this local has an initializer, emit it now.
Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=228021&r1=228020&r2=228021&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Tue Feb 3 14:00:54 2015
@@ -469,11 +469,11 @@ CodeGenFunction::GenerateCXXGlobalInitFu
ArrayRef<llvm::Function *> Decls,
llvm::GlobalVariable *Guard) {
{
- ApplyDebugLocation NL(*this, ApplyDebugLocation::MarkAsPrologue);
+ auto NL = ApplyDebugLocation::CreateEmpty(*this);
StartFunction(GlobalDecl(), getContext().VoidTy, Fn,
getTypes().arrangeNullaryFunction(), FunctionArgList());
// Emit an artificial location for this function.
- ApplyDebugLocation AL(*this, ApplyDebugLocation::Artificial);
+ auto AL = ApplyDebugLocation::CreateArtificial(*this);
llvm::BasicBlock *ExitBlock = nullptr;
if (Guard) {
@@ -520,11 +520,11 @@ void CodeGenFunction::GenerateCXXGlobalD
const std::vector<std::pair<llvm::WeakVH, llvm::Constant*> >
&DtorsAndObjects) {
{
- ApplyDebugLocation NL(*this, ApplyDebugLocation::MarkAsPrologue);
+ auto NL = ApplyDebugLocation::CreateEmpty(*this);
StartFunction(GlobalDecl(), getContext().VoidTy, Fn,
getTypes().arrangeNullaryFunction(), FunctionArgList());
// Emit an artificial location for this function.
- ApplyDebugLocation AL(*this, ApplyDebugLocation::Artificial);
+ auto AL = ApplyDebugLocation::CreateArtificial(*this);
// Emit the dtors, in reverse order from construction.
for (unsigned i = 0, e = DtorsAndObjects.size(); i != e; ++i) {
Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=228021&r1=228020&r2=228021&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Tue Feb 3 14:00:54 2015
@@ -770,7 +770,7 @@ llvm::BasicBlock *CodeGenFunction::EmitL
// Save the current IR generation state.
CGBuilderTy::InsertPoint savedIP = Builder.saveAndClearIP();
- ApplyDebugLocation AL(*this, ApplyDebugLocation::Artificial, CurEHLocation);
+ auto DL = ApplyDebugLocation::CreateDefaultArtificial(*this, CurEHLocation);
const EHPersonality &personality = EHPersonality::get(CGM);
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=228021&r1=228020&r2=228021&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Tue Feb 3 14:00:54 2015
@@ -3043,7 +3043,7 @@ Value *ScalarExprEmitter::VisitBinLAnd(c
// Emit an unconditional branch from this block to ContBlock.
{
// There is no need to emit line number for unconditional branch.
- ApplyDebugLocation NL(CGF, ApplyDebugLocation::NoLocation);
+ auto NL = ApplyDebugLocation::CreateEmpty(CGF);
CGF.EmitBlock(ContBlock);
}
// Insert an entry into the phi node for the edge with the value of RHSCond.
Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=228021&r1=228020&r2=228021&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Tue Feb 3 14:00:54 2015
@@ -565,7 +565,7 @@ void CodeGenFunction::EmitIfStmt(const I
if (const Stmt *Else = S.getElse()) {
{
// There is no need to emit line number for an unconditional branch.
- ApplyDebugLocation NL(*this, ApplyDebugLocation::NoLocation);
+ auto NL = ApplyDebugLocation::CreateEmpty(*this);
EmitBlock(ElseBlock);
}
{
@@ -574,7 +574,7 @@ void CodeGenFunction::EmitIfStmt(const I
}
{
// There is no need to emit line number for an unconditional branch.
- ApplyDebugLocation NL(*this, ApplyDebugLocation::NoLocation);
+ auto NL = ApplyDebugLocation::CreateEmpty(*this);
EmitBranch(ContBlock);
}
}
Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=228021&r1=228020&r2=228021&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Tue Feb 3 14:00:54 2015
@@ -86,13 +86,13 @@ static void EmitOMPIfClause(CodeGenFunct
// Emit the 'else' code if present.
{
// There is no need to emit line number for unconditional branch.
- ApplyDebugLocation NL(CGF, ApplyDebugLocation::NoLocation);
+ auto NL = ApplyDebugLocation::CreateEmpty(CGF);
CGF.EmitBlock(ElseBlock);
}
CodeGen(/*ThenBlock*/ false);
{
// There is no need to emit line number for unconditional branch.
- ApplyDebugLocation NL(CGF, ApplyDebugLocation::NoLocation);
+ auto NL = ApplyDebugLocation::CreateEmpty(CGF);
CGF.EmitBranch(ContBlock);
}
// Emit the continuation block for code after the if.
More information about the cfe-commits
mailing list