Skip to content

Commit 2479680

Browse files
committed
[Kaleidoscope] Fix static global ordering to prevent crash on exit.
If TheModule is declared before LLVMContext then it will be destructed after it, crashing when it tries to deregister itself from the destructed context. llvm-svn: 270381
1 parent 69a710c commit 2479680

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

llvm/examples/Kaleidoscope/Chapter3/toy.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,9 @@ static std::unique_ptr<PrototypeAST> ParseExtern() {
388388
// Code Generation
389389
//===----------------------------------------------------------------------===//
390390

391-
static std::unique_ptr<Module> TheModule;
392391
static LLVMContext TheContext;
393392
static IRBuilder<> Builder(TheContext);
393+
static std::unique_ptr<Module> TheModule;
394394
static std::map<std::string, Value *> NamedValues;
395395

396396
Value *LogErrorV(const char *Str) {

llvm/examples/Kaleidoscope/Chapter4/toy.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,9 @@ static std::unique_ptr<PrototypeAST> ParseExtern() {
397397
// Code Generation
398398
//===----------------------------------------------------------------------===//
399399

400-
static std::unique_ptr<Module> TheModule;
401400
static LLVMContext TheContext;
402401
static IRBuilder<> Builder(TheContext);
402+
static std::unique_ptr<Module> TheModule;
403403
static std::map<std::string, Value *> NamedValues;
404404
static std::unique_ptr<legacy::FunctionPassManager> TheFPM;
405405
static std::unique_ptr<KaleidoscopeJIT> TheJIT;

llvm/examples/Kaleidoscope/Chapter5/toy.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -522,9 +522,9 @@ static std::unique_ptr<PrototypeAST> ParseExtern() {
522522
// Code Generation
523523
//===----------------------------------------------------------------------===//
524524

525-
static std::unique_ptr<Module> TheModule;
526525
static LLVMContext TheContext;
527526
static IRBuilder<> Builder(TheContext);
527+
static std::unique_ptr<Module> TheModule;
528528
static std::map<std::string, Value *> NamedValues;
529529
static std::unique_ptr<legacy::FunctionPassManager> TheFPM;
530530
static std::unique_ptr<KaleidoscopeJIT> TheJIT;

llvm/examples/Kaleidoscope/Chapter6/toy.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -613,9 +613,9 @@ static std::unique_ptr<PrototypeAST> ParseExtern() {
613613
// Code Generation
614614
//===----------------------------------------------------------------------===//
615615

616-
static std::unique_ptr<Module> TheModule;
617616
static LLVMContext TheContext;
618617
static IRBuilder<> Builder(TheContext);
618+
static std::unique_ptr<Module> TheModule;
619619
static std::map<std::string, Value *> NamedValues;
620620
static std::unique_ptr<legacy::FunctionPassManager> TheFPM;
621621
static std::unique_ptr<KaleidoscopeJIT> TheJIT;

llvm/examples/Kaleidoscope/Chapter7/toy.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -684,9 +684,9 @@ static std::unique_ptr<PrototypeAST> ParseExtern() {
684684
// Code Generation
685685
//===----------------------------------------------------------------------===//
686686

687-
static std::unique_ptr<Module> TheModule;
688687
static LLVMContext TheContext;
689688
static IRBuilder<> Builder(TheContext);
689+
static std::unique_ptr<Module> TheModule;
690690
static std::map<std::string, AllocaInst *> NamedValues;
691691
static std::unique_ptr<legacy::FunctionPassManager> TheFPM;
692692
static std::unique_ptr<KaleidoscopeJIT> TheJIT;

0 commit comments

Comments
 (0)