<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jan 9, 2022 at 6:29 AM Russell Wallace via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">... no, when I feed the second output as input into clang again, it objects to the undeclared type:<div><br></div><div>(c1) C:\t>clang -mllvm -opaque-pointers 2.ll<br>2.ll:6:38: error: use of undefined type named 'struct.Unknown'<br>@Unknown = external dso_local global %struct.Unknown, align 1<br> ^<br>1 error generated.<br></div><div><br></div><div>So this seems to be just a bug in this particular version of clang, probably because the opaque pointers conversion is still a work in progress?</div></div></blockquote><div><br></div><div>Yes, this is a bug in the opaque pointers implementation. The TypeFinder does not find the struct type here, because it is neither reachable from the global type, nor the (absent) global initializer, but only from the global value type. We'll have to port some changes from the ValueEnumerator to the TypeFinder.<br></div><div><br></div><div>Regards,</div><div>Nikita<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jan 9, 2022 at 4:20 AM Russell Wallace <<a href="mailto:russell.wallace@gmail.com" target="_blank">russell.wallace@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Given the following code:<div><br></div><div>struct Unknown;<br>extern struct Unknown Unknown;<br><br>struct Unknown *foo(void) {<br> return &Unknown;<br>}<br></div><div><br></div><div>And compiling it with a recent (trunk of a few days ago) clang with default options gives (abridged):</div><div><br></div><div>%struct.Unknown = type opaque<br><br>@Unknown = external dso_local global %struct.Unknown, align 1<br><br>; Function Attrs: noinline nounwind optnone uwtable<br>define dso_local %struct.Unknown* @foo() #0 {<br>entry:<br> ret %struct.Unknown* @Unknown<br>}<br></div><div><br></div><div>Okay, so I think I understand what's going on there. Now, trying the same input with the same compiler and adding the option -mllvm -opaque-pointers (because opaque pointers are good; I think they are a very worthwhile simplification):</div><div><br></div><div>@Unknown = external dso_local global %struct.Unknown, align 1<br><br>; Function Attrs: noinline nounwind optnone uwtable<br>define dso_local ptr @foo() #0 {<br>entry:<br> ret ptr @Unknown<br>}<br></div><div><br></div><div>So that's mostly clear except one thing I'm not quite clear about: %struct.Unknown is referred to, but not declared anywhere. Is that intentional? Is the rule now intended to be that whenever a %<a href="http://type.name" target="_blank">type.name</a> is used that was not declared anywhere, it should be taken to be an opaque type? (I'm fine with that if it is, just figure I better make sure.)</div></div>
</blockquote></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div>