XCore target: fix handling of unsized global arrays in large code model
Robert Lytton
robert at xmos.com
Fri Nov 29 03:24:16 PST 2013
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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PatchUnsizedGlb
Type: application/octet-stream
Size: 2950 bytes
Desc: PatchUnsizedGlb
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131129/429723fd/attachment.obj>
More information about the llvm-commits
mailing list