<div dir="ltr">I think it makes more sense to do something like that in a pass like InferFunctionAttrsPass. We should decide to visit declarations consistently with function pass managers, which currently don't visit declarations. Adding declarations to the new PM CGSCC infra would add complexity and passes would have to check if they're working with a declaration vs definition.<br></div><div dir="ltr"></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 9, 2021 at 1:41 PM Philip Reames <<a href="mailto:listmail@philipreames.com" target="_blank">listmail@philipreames.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">I ran across a dependency in the way the new and old pass managers <br>
interact with function-attrs. I'm not sure whether this is expected <br>
behavior or not, but with some digging, I couldn't find a clear <br>
motivation. Anyone have context on this?<br>
<br>
Essentially, under the old pass manager, FunctionAttrs appears to visit <br>
declarations, and under the new one, it doesn't. Here's an example <br>
that shows how this can change the output of function-attrs:<br>
<br>
$ cat decl.ll<br>
<br>
declare void @readnone() readnone<br>
<br>
$ ./opt -S -function-attrs decl.ll -enable-new-pm=1<br>
; ModuleID = 'decl.ll'<br>
source_filename = "decl.ll"<br>
<br>
; Function Attrs: readnone<br>
declare void @readnone() #0<br>
<br>
attributes #0 = { readnone }<br>
<br>
$ ./opt -S -function-attrs decl.ll -enable-new-pm=0<br>
; ModuleID = 'decl.ll'<br>
source_filename = "decl.ll"<br>
<br>
; Function Attrs: nofree nosync readnone<br>
declare void @readnone() #0<br>
<br>
attributes #0 = { nofree nosync readnone }<br>
<br>
(The example uses nofree and nosync, but please don't focus on the <br>
semantics of those attributes. That's a separate discussion.)<br>
<br>
To me, it seems odd to not have declarations be SCCs of their own, and <br>
thus passed to function-attrs. Does anyone have a good explanation for <br>
why we made this change? And in particular, what the "right" way of <br>
inferring attributes for a partially annotated declaration might be in <br>
our new world?<br>
<br>
Philip<br>
<br>
</blockquote></div>