comparison ir/irfunction.h @ 355:d8357f7004ca trunk

[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict. It is now possible to add label scopes in IrFunction and all labels names will be prefixed accordingly. Also disallow goto into finally blocks. Fixes nocompile/finally_02 and others.
author ChristianK
date Mon, 14 Jul 2008 11:48:55 +0200
parents a7a26f538d6e
children a34078905d01
comparison
equal deleted inserted replaced
354:ac654d4cb935 355:d8357f7004ca
3 3
4 #include "ir/ir.h" 4 #include "ir/ir.h"
5 #include "ir/irlandingpad.h" 5 #include "ir/irlandingpad.h"
6 6
7 #include <vector> 7 #include <vector>
8 #include <stack>
9 #include <map>
8 10
9 // represents a function 11 // represents a function
10 struct IrFunction : IrBase 12 struct IrFunction : IrBase
11 { 13 {
12 llvm::Function* func; 14 llvm::Function* func;
24 llvm::Constant* dwarfSubProg; 26 llvm::Constant* dwarfSubProg;
25 27
26 llvm::AllocaInst* srcfileArg; 28 llvm::AllocaInst* srcfileArg;
27 llvm::AllocaInst* msgArg; 29 llvm::AllocaInst* msgArg;
28 30
31 // pushes a unique label scope of the given name
32 void pushUniqueLabelScope(const char* name);
33 // pops a label scope
34 void popLabelScope();
35
36 // gets the string under which the label's BB
37 // is stored in the labelToBB map.
38 // essentially prefixes ident by the strings in labelScopes
39 std::string getScopedLabelName(const char* ident);
40
29 // label to basic block lookup 41 // label to basic block lookup
30 typedef std::map<std::string, llvm::BasicBlock*> LabelToBBMap; 42 typedef std::map<std::string, llvm::BasicBlock*> LabelToBBMap;
31 LabelToBBMap labelToBB; 43 LabelToBBMap labelToBB;
32 44
33 // landing pads for try statements 45 // landing pads for try statements
34 IRLandingPad landingPad; 46 IRLandingPad landingPad;
35 47
36 IrFunction(FuncDeclaration* fd); 48 IrFunction(FuncDeclaration* fd);
49
50 private:
51 // prefix for labels and gotos
52 // used for allowing labels to be emitted twice
53 std::vector<std::string> labelScopes;
54
55 // next unique id stack
56 std::stack<int> nextUnique;
37 }; 57 };
38 58
39 #endif 59 #endif