@@ -82,24 +82,23 @@ struct LLTypeMemoryLayout
8282// / Removes padding fields for (non-union-containing!) structs
8383struct RemoveStructPadding : ABIRewrite {
8484 // / get a rewritten value back to its original form
85- LLValue* get (Type* dty, DValue * v) {
85+ LLValue* get (Type* dty, LLValue * v) {
8686 LLValue* lval = DtoAlloca (dty, " .rewritetmp" );
8787 getL (dty, v, lval);
8888 return lval;
8989 }
9090
9191 // / get a rewritten value back to its original form and store result in provided lvalue
92- // / this one is optional and defaults to calling the one above
93- void getL (Type* dty, DValue* v, LLValue* lval) {
92+ void getL (Type* dty, LLValue* v, LLValue* lval) {
9493 // Make sure the padding is zero, so struct comparisons work.
9594 // TODO: Only do this if there's padding, and/or only initialize padding.
9695 DtoMemSetZero (lval, DtoConstSize_t (getTypePaddedSize (DtoType (dty))));
97- DtoPaddedStruct (dty->toBasetype (), v-> getRVal () , lval);
96+ DtoPaddedStruct (dty->toBasetype (), v, lval);
9897 }
9998
10099 // / put out rewritten value
101- LLValue* put (Type* dty, DValue* v) {
102- return DtoUnpaddedStruct (dty ->toBasetype (), v->getRVal ());
100+ LLValue* put (DValue* v) {
101+ return DtoUnpaddedStruct (v-> getType () ->toBasetype (), v->getRVal ());
103102 }
104103
105104 // / return the transformed type for this rewrite
@@ -154,26 +153,22 @@ struct IntegerRewrite : ABIRewrite
154153 return LLTypeMemoryLayout::typesAreEquivalent (llType, integerType);
155154 }
156155
157- LLValue* get (Type* dty, DValue* dv )
156+ LLValue* get (Type* dty, LLValue* v )
158157 {
159- LLValue* integer = dv->getRVal ();
160- LLValue* integerDump = storeToMemory (integer, 0 , " .IntegerRewrite_dump" );
161-
158+ LLValue* integerDump = DtoAllocaDump (v, dty, " .IntegerRewrite_dump" );
162159 LLType* type = DtoType (dty);
163160 return loadFromMemory (integerDump, type, " .IntegerRewrite_getResult" );
164161 }
165162
166- void getL (Type* dty, DValue* dv , LLValue* lval)
163+ void getL (Type* dty, LLValue* v , LLValue* lval)
167164 {
168- LLValue* integer = dv->getRVal ();
169- storeToMemory (integer, lval);
165+ storeToMemory (v, lval);
170166 }
171167
172- LLValue* put (Type* dty, DValue* dv)
168+ LLValue* put (DValue* dv)
173169 {
174- assert (dty == dv->getType ());
175170 LLValue* address = getAddressOf (dv);
176- LLType* integerType = getIntegerType (dty ->size ());
171+ LLType* integerType = getIntegerType (dv-> getType () ->size ());
177172 return loadFromMemory (address, integerType, " .IntegerRewrite_putResult" );
178173 }
179174
@@ -205,21 +200,19 @@ struct ExplicitByvalRewrite : ABIRewrite
205200 ExplicitByvalRewrite (size_t alignment = 16 ) : alignment(alignment)
206201 { }
207202
208- LLValue* get (Type* dty, DValue * v)
203+ LLValue* get (Type* dty, LLValue * v)
209204 {
210- LLValue* pointer = v->getRVal ();
211- return DtoLoad (pointer, " .ExplicitByvalRewrite_getResult" );
205+ return DtoLoad (v, " .ExplicitByvalRewrite_getResult" );
212206 }
213207
214- void getL (Type* dty, DValue * v, LLValue* lval)
208+ void getL (Type* dty, LLValue * v, LLValue* lval)
215209 {
216- LLValue* pointer = v->getRVal ();
217- DtoAggrCopy (lval, pointer);
210+ DtoAggrCopy (lval, v);
218211 }
219212
220- LLValue* put (Type* dty, DValue* v)
213+ LLValue* put (DValue* v)
221214 {
222- if (DtoIsPassedByRef (dty ))
215+ if (DtoIsPassedByRef (v-> getType () ))
223216 {
224217 LLValue* originalPointer = v->getRVal ();
225218 LLType* type = originalPointer->getType ()->getPointerElementType ();
@@ -228,9 +221,7 @@ struct ExplicitByvalRewrite : ABIRewrite
228221 return copyForCallee;
229222 }
230223
231- LLValue* originalValue = v->getRVal ();
232- LLValue* copyForCallee = storeToMemory (originalValue, alignment, " .ExplicitByvalRewrite_putResult" );
233- return copyForCallee;
224+ return DtoAllocaDump (v->getRVal (), alignment, " .ExplicitByvalRewrite_putResult" );
234225 }
235226
236227 LLType* type (Type* dty, LLType* t)
0 commit comments