[PATCH v2] Respect alignment when loading up a coerced function argument
John McCall
rjmccall at apple.com
Mon Jun 22 17:39:49 PDT 2015
> On Jun 22, 2015, at 5:30 PM, Hal Finkel <hfinkel at anl.gov> wrote:
>
> [+John]
>
> Hi Uli,
>
> - CGF.Builder.CreateStore(Src, DstPtr, DstIsVolatile);
> + llvm::StoreInst *SI = CGF.Builder.CreateStore(Src, DstPtr, DstIsVolatile);
> + SI->setAlignment(DstAlign.getQuantity());
> return;
>
> You can use CreateAlignedStore instead of CreateStore here (and in several other places).
>
> + llvm::AllocaInst *Tmp = CGF.CreateTempAlloca(SrcTy);
> + Tmp->setAlignment(DstAlign.getQuantity());
>
> As follow-up, we should make CreateTempAlloca take an optional alignment. Running:
>
> grep -r -A 2 CreateTempAlloca * | grep setAlign
>
> reveals that this patten already occurs in several places.
Seems reasonable to me.
In the Swift frontend, I actually deleted the unaligned CreateLoad/CreateStore
methods from our IRBuilder subclass in an effort to avoid ever creating something
without alignment. That would be a good goal to achieve in Clang as well.
John.
More information about the cfe-commits
mailing list