Mercurial > projects > ldc
comparison gen/functions.cpp @ 739:1ae94fb1dbbd
Fix accidental double-inreg caused by shared TupleType. Enabled inreg by default.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Thu, 30 Oct 2008 10:16:37 +0100 |
parents | 6de2ed4f0abe |
children | 2d7bcfa68128 |
comparison
equal
deleted
inserted
replaced
738:ecb429ee0648 | 739:1ae94fb1dbbd |
---|---|
201 if (global.params.cpu == ARCHx86) | 201 if (global.params.cpu == ARCHx86) |
202 { | 202 { |
203 // pass first param in EAX if it fits, is not floating point and is not a 3 byte struct. | 203 // pass first param in EAX if it fits, is not floating point and is not a 3 byte struct. |
204 // FIXME: struct are not passed in EAX yet | 204 // FIXME: struct are not passed in EAX yet |
205 | 205 |
206 int n_inreg = f->reverseParams ? n - 1 : 0; | |
207 Argument* arg = Argument::getNth(f->parameters, n_inreg); | |
208 | |
206 // if there is a implicit context parameter, pass it in EAX | 209 // if there is a implicit context parameter, pass it in EAX |
207 if (usesthis || usesnest) | 210 if (usesthis || usesnest) |
208 { | 211 { |
209 f->thisAttrs |= llvm::Attribute::InReg; | 212 f->thisAttrs |= llvm::Attribute::InReg; |
213 assert((!arg || (arg->llvmAttrs & llvm::Attribute::InReg) == 0) && "can't have two inreg args!"); | |
210 } | 214 } |
211 // otherwise check the first formal parameter | 215 // otherwise check the first formal parameter |
212 else | 216 else |
213 { | 217 { |
214 int inreg = f->reverseParams ? n - 1 : 0; | |
215 Argument* arg = Argument::getNth(f->parameters, inreg); | |
216 Type* t = arg->type->toBasetype(); | 218 Type* t = arg->type->toBasetype(); |
217 | 219 |
218 // 32bit ints, pointers, classes, static arrays and AAs | 220 // 32bit ints, pointers, classes, static arrays and AAs |
219 // are candidate for being passed in EAX | 221 // are candidate for being passed in EAX |
220 if ((arg->storageClass & STCin) && | 222 if ((arg->storageClass & STCin) && |
221 ((t->isscalar() && !t->isfloating()) || | 223 ((t->isscalar() && !t->isfloating()) || |
222 t->ty == Tclass || t->ty == Tsarray || t->ty == Taarray) && | 224 t->ty == Tclass || t->ty == Tsarray || t->ty == Taarray) && |
223 (t->size() <= PTRSIZE)) | 225 (t->size() <= PTRSIZE)) |
224 { | 226 { |
225 arg->llvmAttrs |= llvm::Attribute::InReg; | 227 arg->llvmAttrs |= llvm::Attribute::InReg; |
228 assert((f->thisAttrs & llvm::Attribute::InReg) == 0 && "can't have two inreg args!"); | |
226 } | 229 } |
227 } | 230 } |
228 } | 231 } |
229 } | 232 } |
230 #endif // X86_PASS_IN_EAX | 233 #endif // X86_PASS_IN_EAX |