File tree Expand file tree Collapse file tree 4 files changed +25
-6
lines changed Expand file tree Collapse file tree 4 files changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,8 @@ class PrettyStackTraceSILFunction : public llvm::PrettyStackTraceEntry {
50
50
PrettyStackTraceSILFunction (const char *action, SILFunction *F)
51
51
: TheFn(F), Action(action) {}
52
52
virtual void print (llvm::raw_ostream &OS) const ;
53
+ protected:
54
+ void printFunctionInfo (llvm::raw_ostream &out) const ;
53
55
};
54
56
55
57
} // end namespace swift
Original file line number Diff line number Diff line change 13
13
#ifndef SWIFT_SILOPTIMIZER_PASSMANAGER_PRETTYSTACKTRACE_H
14
14
#define SWIFT_SILOPTIMIZER_PASSMANAGER_PRETTYSTACKTRACE_H
15
15
16
+ #include " swift/SIL/PrettyStackTrace.h"
16
17
#include " llvm/Support/PrettyStackTrace.h"
17
18
18
19
namespace swift {
@@ -21,14 +22,14 @@ class SILFunctionTransform;
21
22
class SILModuleTransform ;
22
23
23
24
class PrettyStackTraceSILFunctionTransform
24
- : public llvm::PrettyStackTraceEntry {
25
+ : public PrettyStackTraceSILFunction {
25
26
SILFunctionTransform *SFT;
26
27
unsigned PassNumber;
27
28
28
29
public:
29
30
PrettyStackTraceSILFunctionTransform (SILFunctionTransform *SFT,
30
- unsigned PassNumber)
31
- : SFT(SFT), PassNumber(PassNumber) {}
31
+ unsigned PassNumber);
32
+
32
33
virtual void print (llvm::raw_ostream &OS) const ;
33
34
};
34
35
Original file line number Diff line number Diff line change 22
22
23
23
using namespace swift ;
24
24
25
+ llvm::cl::opt<bool >
26
+ SILPrintOnError (" sil-print-on-error" , llvm::cl::init(false ),
27
+ llvm::cl::desc(" Printing SIL function bodies in crash diagnostics." ));
28
+
25
29
void swift::printSILLocationDescription (llvm::raw_ostream &out,
26
30
SILLocation loc,
27
31
ASTContext &Context) {
@@ -52,11 +56,19 @@ void PrettyStackTraceSILFunction::print(llvm::raw_ostream &out) const {
52
56
return ;
53
57
}
54
58
59
+ printFunctionInfo (out);
60
+ }
61
+
62
+ void PrettyStackTraceSILFunction::printFunctionInfo (llvm::raw_ostream &out) const {
63
+ out << " \" " ;
55
64
TheFn->printName (out);
65
+ out << " \" .\n " ;
56
66
57
67
if (!TheFn->getLocation ().isNull ()) {
58
68
out << " for " ;
59
69
printSILLocationDescription (out, TheFn->getLocation (),
60
70
TheFn->getModule ().getASTContext ());
61
71
}
72
+ if (SILPrintOnError)
73
+ TheFn->print (out);
62
74
}
Original file line number Diff line number Diff line change 17
17
18
18
using namespace swift ;
19
19
20
+ PrettyStackTraceSILFunctionTransform::PrettyStackTraceSILFunctionTransform (
21
+ SILFunctionTransform *SFT, unsigned PassNumber):
22
+ PrettyStackTraceSILFunction(" Running SIL Function Transform" ,
23
+ SFT->getFunction ()),
24
+ SFT(SFT), PassNumber(PassNumber) {}
25
+
20
26
void PrettyStackTraceSILFunctionTransform::print (llvm::raw_ostream &out) const {
21
27
out << " While running pass #" << PassNumber
22
28
<< " SILFunctionTransform \" " << SFT->getName ()
@@ -25,9 +31,7 @@ void PrettyStackTraceSILFunctionTransform::print(llvm::raw_ostream &out) const {
25
31
out << " <<null>>" ;
26
32
return ;
27
33
}
28
- out << " \" " ;
29
- SFT->getFunction ()->printName (out);
30
- out << " \" .\n " ;
34
+ printFunctionInfo (out);
31
35
}
32
36
33
37
void PrettyStackTraceSILModuleTransform::print (llvm::raw_ostream &out) const {
You can’t perform that action at this time.
0 commit comments