XCore target: fix handling of unsized global arrays in large code model

Richard Osborne richard at xmos.com
Wed Dec 11 13:52:48 PST 2013


Looks good to me

On 29 Nov 2013, at 11:24, Robert Lytton <robert at xmos.com> wrote:

> Quite right, 'type opaque' was not being handled correcty.
> Here is an updated patch following comments.
> Robert
> 
> 
> ________________________________________
> From: Richard Osborne
> Sent: 28 November 2013 21:19
> To: Robert Lytton
> Cc: llvm-commits at cs.uiuc.edu
> Subject: Re: XCore target: fix handling of unsized global arrays in large code model
> 
> diff --git a/lib/Target/XCore/XCoreISelLowering.cpp b/lib/Target/XCore/XCoreISelLowering.cpp
> index b3fbb61..d40ec1b 100644
> --- a/lib/Target/XCore/XCoreISelLowering.cpp
> +++ b/lib/Target/XCore/XCoreISelLowering.cpp
> @@ -276,9 +276,17 @@ LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const
>   SDLoc DL(GN);
>   int64_t Offset = GN->getOffset();
>   Type *ObjType = GV->getType()->getPointerElementType();
> -  if (getTargetMachine().getCodeModel() == CodeModel::Small ||
> -      !ObjType->isSized() ||
> -      getDataLayout()->getTypeAllocSize(ObjType) < CodeModelLargeSize) {
> +
> +  bool SmallObject = true;
> +  if (ObjType->isSized() &&
> +      getTargetMachine().getCodeModel() == CodeModel::Large) {
> +    unsigned ObjSize = getDataLayout()->getTypeAllocSize(ObjType);
> +    if (ObjSize >= CodeModelLargeSize ||
> +        (ObjType->isArrayTy() && ObjSize == 0))
> +      SmallObject = false;
> +  }
> +
> 
> This conditional is getting pretty complicated - maybe extract it into a static helper function? Also does the code also handle the following case correctly?
> 
> // Incomplete structure type
> extern struct foo x;
> 
> struct foo *f() {
>  return &x;
> }
> 
> <PatchUnsizedGlb>





More information about the llvm-commits mailing list