Mercurial > projects > ldc
annotate ir/irfunction.cpp @ 612:d97b017a8aef
Fix issue with EH table indices and nested try-catch.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sun, 21 Sep 2008 17:18:35 +0200 |
parents | c7d7e2282ba3 |
children | df196c8dea26 |
rev | line source |
---|---|
309 | 1 |
2 #include "gen/llvm.h" | |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff
changeset
|
3 #include "gen/tollvm.h" |
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff
changeset
|
4 #include "ir/irfunction.h" |
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff
changeset
|
5 |
355
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
6 #include <sstream> |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
7 |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff
changeset
|
8 ////////////////////////////////////////////////////////////////////////////// |
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff
changeset
|
9 ////////////////////////////////////////////////////////////////////////////// |
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff
changeset
|
10 ////////////////////////////////////////////////////////////////////////////// |
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff
changeset
|
11 |
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff
changeset
|
12 IrFunction::IrFunction(FuncDeclaration* fd) |
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff
changeset
|
13 { |
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff
changeset
|
14 decl = fd; |
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff
changeset
|
15 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
355
diff
changeset
|
16 Type* t = fd->type->toBasetype(); |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff
changeset
|
17 assert(t->ty == Tfunction); |
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff
changeset
|
18 type = (TypeFunction*)t; |
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff
changeset
|
19 func = NULL; |
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff
changeset
|
20 allocapoint = NULL; |
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff
changeset
|
21 |
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff
changeset
|
22 queued = false; |
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff
changeset
|
23 defined = false; |
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff
changeset
|
24 |
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff
changeset
|
25 retArg = NULL; |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
355
diff
changeset
|
26 thisArg = NULL; |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
355
diff
changeset
|
27 nestArg = NULL; |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
355
diff
changeset
|
28 |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff
changeset
|
29 nestedVar = NULL; |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
355
diff
changeset
|
30 |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff
changeset
|
31 _arguments = NULL; |
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff
changeset
|
32 _argptr = NULL; |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
355
diff
changeset
|
33 |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff
changeset
|
34 dwarfSubProg = NULL; |
203
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
145
diff
changeset
|
35 |
e881c9b1c738
[svn r219] Fixed: the tango/lib/gc/basic garbage collector now compiles and links into an executable (change in tango/lib/llvmdc-posix.mak), closes #5 .
lindquist
parents:
145
diff
changeset
|
36 srcfileArg = NULL; |
207
e0b6040585b4
[svn r223] Fixed: assert with message could be broken.
lindquist
parents:
205
diff
changeset
|
37 msgArg = NULL; |
355
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
38 |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
39 nextUnique.push(0); |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff
changeset
|
40 } |
355
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
41 |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
42 std::string IrFunction::getScopedLabelName(const char* ident) |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
43 { |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
44 if(labelScopes.empty()) |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
45 return std::string(ident); |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
46 |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
47 std::string result = "__"; |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
48 for(unsigned int i = 0; i < labelScopes.size(); ++i) |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
49 result += labelScopes[i] + "_"; |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
50 return result + ident; |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
51 } |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
52 |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
53 void IrFunction::pushUniqueLabelScope(const char* name) |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
54 { |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
55 std::ostringstream uniquename; |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
56 uniquename << name << nextUnique.top()++; |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
57 nextUnique.push(0); |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
58 labelScopes.push_back(uniquename.str()); |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
59 } |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
60 |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
61 void IrFunction::popLabelScope() |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
62 { |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
63 labelScopes.pop_back(); |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
64 nextUnique.pop(); |
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
309
diff
changeset
|
65 } |
584
c7d7e2282ba3
Make sure functions containing inline asm are never inlined to avoid
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
66 |
c7d7e2282ba3
Make sure functions containing inline asm are never inlined to avoid
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
67 void IrFunction::setNeverInline() |
c7d7e2282ba3
Make sure functions containing inline asm are never inlined to avoid
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
68 { |
c7d7e2282ba3
Make sure functions containing inline asm are never inlined to avoid
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
69 llvm::FunctionNotes cur = func->getNotes(); |
c7d7e2282ba3
Make sure functions containing inline asm are never inlined to avoid
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
70 assert(!(cur & llvm::FN_NOTE_AlwaysInline) && "function can't be never- and always-inline at the same time"); |
c7d7e2282ba3
Make sure functions containing inline asm are never inlined to avoid
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
71 func->setNotes(cur | llvm::FN_NOTE_NoInline); |
c7d7e2282ba3
Make sure functions containing inline asm are never inlined to avoid
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
72 } |
c7d7e2282ba3
Make sure functions containing inline asm are never inlined to avoid
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
73 |
c7d7e2282ba3
Make sure functions containing inline asm are never inlined to avoid
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
74 void IrFunction::setAlwaysInline() |
c7d7e2282ba3
Make sure functions containing inline asm are never inlined to avoid
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
75 { |
c7d7e2282ba3
Make sure functions containing inline asm are never inlined to avoid
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
76 llvm::FunctionNotes cur = func->getNotes(); |
c7d7e2282ba3
Make sure functions containing inline asm are never inlined to avoid
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
77 assert(!(cur & llvm::FN_NOTE_NoInline) && "function can't be never- and always-inline at the same time"); |
c7d7e2282ba3
Make sure functions containing inline asm are never inlined to avoid
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
78 func->setNotes(cur | llvm::FN_NOTE_AlwaysInline); |
c7d7e2282ba3
Make sure functions containing inline asm are never inlined to avoid
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
79 } |