[cfe-commits] [cfe-dev][patch] Strange LLVM IR result on recursive type

Jin Gu Kang jaykang10 at imrc.kist.re.kr
Sat Nov 10 15:56:01 PST 2012


I misunderstood something about ABI converting.

> struct S1 { int x; };
> struct S2 { struct S1 (*g)(void); };
> struct S2 g;

Above example, struct S1 is changed to shadow parameter as following.

%struct.S2 = type { void (%struct.S1*)* }
%struct.S1 = type { i32 }
@g = common global %struct.S2 zeroinitializer, align 4

I think ABI converter is based on AST node so incomplete function type is not problem. My previous patch seemed to include several problems and I modified patch. Clang of trunk with modified patch didn't generate error on above example. Please review this patch.

Thanks,
Jin-Gu Kang
________________________________________
From: Eli Friedman [eli.friedman at gmail.com]
Sent: Saturday, November 10, 2012 7:22 AM
To: Jin Gu Kang
Cc: cfe-commits at cs.uiuc.edu
Subject: Re: [cfe-commits] [cfe-dev][patch] Strange LLVM IR result on recursive type

On Fri, Nov 9, 2012 at 1:05 AM, Jin Gu Kang <jaykang10 at imrc.kist.re.kr> wrote:
> Hi Eli,
>
> Thanks for your comment.
>
> I and my colleague tried to cut the cycle at struct type without returning null on ConvertType. This patch cuts cycle on just struct type with checking functions being processed. This method defers these struct types. I also send test case for this situation. I didn't have experience to make test case. Please check this test case and reivew the patch file. If there are something wrong, please let me know about that.

Your patch makes clang crash on the following:

struct S1 { int x; };
struct S2 { struct S1 (*g)(void); };
struct S2 g;

-Eli
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Recursive_type.patch
Type: application/octet-stream
Size: 2153 bytes
Desc: Recursive_type.patch
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121111/cef625dc/attachment.obj>


More information about the cfe-commits mailing list