mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Move DebugScopeStack from SILBuilder to SILGenFunction, using the swift new
InsertedInstrs facility. No functionality change intended. Swift SVN r7520
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
#ifndef SWIFT_SIL_SILBUILDER_H
|
||||
#define SWIFT_SIL_SILBUILDER_H
|
||||
|
||||
#include "swift/SIL/SILDebugScope.h"
|
||||
#include "swift/SIL/SILFunction.h"
|
||||
#include "swift/SIL/SILModule.h"
|
||||
|
||||
@@ -26,8 +25,6 @@ class SILBuilder {
|
||||
SILFunction &F;
|
||||
SILBasicBlock *BB;
|
||||
SILBasicBlock::iterator InsertPt;
|
||||
/// Keep track of our current nested scope.
|
||||
std::vector<SILDebugScope*> DebugScopeStack;
|
||||
|
||||
/// InsertedInstrs - If this pointer is non-null, then any inserted
|
||||
/// instruction is recorded in this list.
|
||||
@@ -143,21 +140,6 @@ public:
|
||||
moveBlockToEnd(BB);
|
||||
}
|
||||
|
||||
/// enterDebugScope - Push a new debug scope and set its parent pointer.
|
||||
void enterDebugScope(SILDebugScope *DS) {
|
||||
if (DebugScopeStack.size())
|
||||
DS->setParent(DebugScopeStack.back());
|
||||
else
|
||||
DS->setParent(F.getDebugScope());
|
||||
DebugScopeStack.push_back(DS);
|
||||
}
|
||||
|
||||
/// enterDebugScope - return to the previous debug scope.
|
||||
void leaveDebugScope() {
|
||||
assert(DebugScopeStack.size());
|
||||
DebugScopeStack.pop_back();
|
||||
}
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// SILInstruction Creation Methods
|
||||
//===--------------------------------------------------------------------===//
|
||||
@@ -793,9 +775,6 @@ private:
|
||||
void insertImpl(SILInstruction *TheInst) {
|
||||
if (BB == 0) return;
|
||||
|
||||
if (DebugScopeStack.size())
|
||||
TheInst->setDebugScope(DebugScopeStack.back());
|
||||
|
||||
// If the SILBuilder client wants to know about new instructions, record
|
||||
// this.
|
||||
if (InsertedInstrs)
|
||||
|
||||
@@ -30,7 +30,8 @@ using namespace Lowering;
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
SILGenFunction::SILGenFunction(SILGenModule &SGM, SILFunction &F)
|
||||
: SGM(SGM), F(F), B(new (F.getModule()) SILBasicBlock(&F)),
|
||||
: SGM(SGM), F(F), LastInsnWithoutScope(0),
|
||||
B(new (F.getModule()) SILBasicBlock(&F), &InsertedInstrs),
|
||||
CurrentSILLoc(F.getLocation()), Cleanups(*this)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
#include "ASTVisitor.h"
|
||||
#include "Cleanup.h"
|
||||
#include "Condition.h"
|
||||
#include "Scope.h"
|
||||
#include "swift/AST/ASTContext.h"
|
||||
#include "swift/AST/DiagnosticEngine.h"
|
||||
#include "swift/Basic/Optional.h"
|
||||
#include "swift/SIL/SILDebugScope.h"
|
||||
#include "swift/SIL/SILFunction.h"
|
||||
#include "swift/SIL/SILModule.h"
|
||||
#include "swift/SIL/SILBuilder.h"
|
||||
@@ -260,6 +260,10 @@ public:
|
||||
/// The SILFunction being constructed.
|
||||
SILFunction &F;
|
||||
|
||||
/// This is used to keep track of all SILInstructions inserted by \c B.
|
||||
SmallVector<SILInstruction*, 32> InsertedInstrs;
|
||||
size_t LastInsnWithoutScope;
|
||||
|
||||
/// B - The SILBuilder used to construct the SILFunction. It is what maintains
|
||||
/// the notion of the current block being emitted into.
|
||||
SILBuilder B;
|
||||
@@ -272,6 +276,8 @@ public:
|
||||
std::vector<JumpDest> BreakDestStack;
|
||||
std::vector<JumpDest> ContinueDestStack;
|
||||
std::vector<SwitchContext *> SwitchStack;
|
||||
/// Keep track of our current nested scope.
|
||||
std::vector<SILDebugScope*> DebugScopeStack;
|
||||
|
||||
/// The cleanup depth and epilog BB for "return" instructions.
|
||||
JumpDest ReturnDest;
|
||||
@@ -375,6 +381,32 @@ public:
|
||||
return SGM.Types.getTypeLowering(type);
|
||||
}
|
||||
|
||||
/// enterDebugScope - Push a new debug scope and set its parent pointer.
|
||||
void enterDebugScope(SILDebugScope *DS) {
|
||||
if (DebugScopeStack.size())
|
||||
DS->setParent(DebugScopeStack.back());
|
||||
else
|
||||
DS->setParent(F.getDebugScope());
|
||||
DebugScopeStack.push_back(DS);
|
||||
setDebugScopeForInsertedInstrs(DS->Parent);
|
||||
}
|
||||
|
||||
/// enterDebugScope - return to the previous debug scope.
|
||||
void leaveDebugScope() {
|
||||
assert(DebugScopeStack.size());
|
||||
setDebugScopeForInsertedInstrs(DebugScopeStack.back());
|
||||
DebugScopeStack.pop_back();
|
||||
}
|
||||
|
||||
/// Set the debug scope for all SILInstructions that where emitted
|
||||
/// from when we entered the last scope up to the current one.
|
||||
void setDebugScopeForInsertedInstrs(SILDebugScope *DS) {
|
||||
while (LastInsnWithoutScope < InsertedInstrs.size()) {
|
||||
InsertedInstrs[LastInsnWithoutScope]->setDebugScope(DS);
|
||||
++LastInsnWithoutScope;
|
||||
}
|
||||
}
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Entry points for codegen
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "SILGen.h"
|
||||
#include "Scope.h"
|
||||
#include "swift/AST/AST.h"
|
||||
#include "swift/AST/Decl.h"
|
||||
#include "swift/AST/Types.h"
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "SILGen.h"
|
||||
#include "Scope.h"
|
||||
#include "Cleanup.h"
|
||||
#include "Initialization.h"
|
||||
#include "RValue.h"
|
||||
|
||||
@@ -86,7 +86,7 @@ Condition SILGenFunction::emitCondition(SILLocation Loc, Expr *E,
|
||||
|
||||
void SILGenFunction::visitBraceStmt(BraceStmt *S) {
|
||||
// Enter a new scope.
|
||||
LexicalScope BraceScope(Cleanups, B, S);
|
||||
LexicalScope BraceScope(Cleanups, *this, S);
|
||||
|
||||
for (auto &ESD : S->getElements()) {
|
||||
assert(B.hasValidInsertionPoint());
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#ifndef SCOPE_H
|
||||
#define SCOPE_H
|
||||
|
||||
#include "swift/SIL/SILBuilder.h"
|
||||
#include "SILGen.h"
|
||||
#include "swift/SIL/SILDebugScope.h"
|
||||
#include "Cleanup.h"
|
||||
|
||||
@@ -74,19 +74,19 @@ public:
|
||||
|
||||
/// A LexicalScope is a Scope that is also exposed to the debug info.
|
||||
class LLVM_LIBRARY_VISIBILITY LexicalScope : private Scope {
|
||||
SILBuilder& Builder;
|
||||
SILGenFunction& SGF;
|
||||
public:
|
||||
explicit LexicalScope(CleanupManager &Cleanups,
|
||||
SILBuilder& B,
|
||||
SILGenFunction& SGF,
|
||||
SILLocation Loc)
|
||||
: Scope(Cleanups), Builder(B) {
|
||||
SILDebugScope *DS = new (B.getFunction().getModule()) SILDebugScope(Loc);
|
||||
Builder.enterDebugScope(DS);
|
||||
: Scope(Cleanups), SGF(SGF) {
|
||||
SILDebugScope *DS = new (SGF.SGM.M) SILDebugScope(Loc);
|
||||
SGF.enterDebugScope(DS);
|
||||
}
|
||||
using Scope::pop;
|
||||
|
||||
~LexicalScope() {
|
||||
Builder.leaveDebugScope();
|
||||
SGF.leaveDebugScope();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user