Mercurial > projects > ldc
comparison ir/irtypeclass.cpp @ 1351:8d501abecd24
Initial (but disabled) fix for ticket #294 , the actual part that fixes the bug is in a #if 0 block as I'm afraid it will cause regressions. I'm most likely not going to be around tonight, and maybe not tomorrow as well, so I'm pushing it in case someone wants to run some serious testing/investigate the problem noted in llvmhelpers.cpp : realignOffset .
author | Tomas Lindquist Olsen <tomas.l.olsen gmail com> |
---|---|
date | Thu, 14 May 2009 17:20:17 +0200 |
parents | 49fd0c8040e6 |
children | 638d16625da2 |
comparison
equal
deleted
inserted
replaced
1350:15e9762bb620 | 1351:8d501abecd24 |
---|---|
7 | 7 |
8 #include "gen/irstate.h" | 8 #include "gen/irstate.h" |
9 #include "gen/logger.h" | 9 #include "gen/logger.h" |
10 #include "gen/tollvm.h" | 10 #include "gen/tollvm.h" |
11 #include "gen/utils.h" | 11 #include "gen/utils.h" |
12 #include "gen/llvmhelpers.h" | |
12 #include "ir/irtypeclass.h" | 13 #include "ir/irtypeclass.h" |
13 | 14 |
14 ////////////////////////////////////////////////////////////////////////////// | 15 ////////////////////////////////////////////////////////////////////////////// |
15 | 16 |
16 extern size_t add_zeros(std::vector<const llvm::Type*>& defaultTypes, size_t diff); | 17 extern size_t add_zeros(std::vector<const llvm::Type*>& defaultTypes, size_t diff); |
141 // add to default field list | 142 // add to default field list |
142 if (cd == base) | 143 if (cd == base) |
143 default_fields.push_back(vd); | 144 default_fields.push_back(vd); |
144 | 145 |
145 // get next aligned offset for this type | 146 // get next aligned offset for this type |
146 size_t alignsize = vd->type->alignsize(); | 147 size_t alignedoffset = realignOffset(offset, vd->type); |
147 size_t alignedoffset = (offset + alignsize - 1) & ~(alignsize - 1); | |
148 | 148 |
149 // insert explicit padding? | 149 // insert explicit padding? |
150 if (alignedoffset < vd->offset) | 150 if (alignedoffset < vd->offset) |
151 { | 151 { |
152 field_index += add_zeros(defaultTypes, vd->offset - alignedoffset); | 152 field_index += add_zeros(defaultTypes, vd->offset - alignedoffset); |