[cfe-commits] [PATCH] struct{bool} -> int function argument coercion emits an invalid store on ARM

Eli Friedman eli.friedman at gmail.com
Wed Feb 8 21:34:25 PST 2012


Indentation generally looks strange... maybe some stray tabs?

+	  llvm::Value *Casted =
+	    Builder.CreateBitCast(TempAlloca,
llvm::PointerType::getUnqual(ConvertTypeForMem(Ty)));
+	  llvm::LoadInst *Load = Builder.CreateLoad(Casted);
+	  Builder.CreateStore(Load, Ptr);

Please use memcpy to copy structs, not load+store.

-      if (llvm::StructType *STy =
-            dyn_cast<llvm::StructType>(ArgI.getCoerceToType())) {
-        Ptr = Builder.CreateBitCast(Ptr, llvm::PointerType::getUnqual(STy));
+      llvm::StructType *STy =
dyn_cast<llvm::StructType>(ArgI.getCoerceToType());
+      if (STy && STy->getNumElements() > 1) {

For the case where STy->getNumElements() == 1, do we avoid storing a
struct type?  If not, can you fix that?

On a higher level, this isn't really ideal, but it's an improvement...
so I guess it's okay.

-Eli

On Wed, Feb 8, 2012 at 1:38 AM, Evgeniy Stepanov
<eugeni.stepanov at gmail.com> wrote:
> Please review.
>
> This change is blocking ASan for Chrome/Android.
>
> On Tue, Feb 7, 2012 at 10:17 AM, Evgeniy Stepanov
> <eugeni.stepanov at gmail.com> wrote:
>> ping
>>
>> On Sun, Feb 5, 2012 at 8:08 PM, Evgeniy Stepanov
>> <eugeni.stepanov at gmail.com> wrote:
>>> Please consider the new patch.
>>> This time, if the coerce-to type is larger than the real type, we
>>> reconstruct a value of the coerce-to type in a stack allocation, then
>>> bitcast & copy it into the destination.
>>> This is roughly the same logic as in CreateCoercedStore, but with
>>> multiple sources.
>>>
>>> On Sat, Feb 4, 2012 at 6:12 PM, Evgeniy Stepanov
>>> <eugeni.stepanov at gmail.com> wrote:
>>>> On Sat, Feb 4, 2012 at 1:07 AM, Eli Friedman <eli.friedman at gmail.com> wrote:
>>>>> On Fri, Feb 3, 2012 at 4:05 AM, Evgeniy Stepanov
>>>>> <eugeni.stepanov at gmail.com> wrote:
>>>>>> Hi,
>>>>>>
>>>>>> this is a fix for PR11905.
>>>>>>
>>>>>> The current behaviour when generation a function prolog for arguments
>>>>>> of coerced types is to allocate a stack temp of the real argument type
>>>>>> and store the argument(s) there. This is wrong, because storage size
>>>>>> of the coerce-to type can be larger than that of the real type.
>>>>>>
>>>>>> The new behaviour is to allocate a temp of the coerced type, copy it,
>>>>>> and then reference through a bitcasted pointer of the real type.
>>>>>>
>>>>>> Please review.
>>>>>
>>>>> The real type is sometimes larger than the coerced type... switching
>>>>> from one to the other only changes which cases are broken issues.
>>>>
>>>> Could you give an example of that?
>>>> In that case, what would you think of allocating the largest of the two types?
>>>>
>>>>>
>>>>> -Eli
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>



More information about the cfe-commits mailing list