<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/64459>64459</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [OpaquePointers] ElementType only legal on intrinsics and inline asm
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          wsmoses
      </td>
    </tr>
</table>

<pre>
    @nikic 

I'm trying to adapt some Julia + Enzyme (autodiff) code to opaque pointers and hitting an issue. 

For a given differentiable argument, we'll duplicate that argument. If that argument is an sret that means there are now two "sret"-like arguments (sret have special semantics for julia's GC). Obviously two arguments marked sret is invalid. Therefore in a non-opaque pointer land I just added a special "enzyme_sret" string attribute, and all was well.

Unfortunately, this of course loses the inner sret type which presents issues when using Opaque pointers (Julia is only experimenting with that now). As string attributes (since Enzyme is presently out of tree) do not permit type arguments, I looked to preserve the type in a different way. To remedy this I tried using an elementtype attribute at that location. However, unfortunately I hit the issue that " Attribute 'elementtype' can only be applied to intrinsics and inline asm".  

What would you recommend here to support opaque pointers in this context.

cc @vchuravy 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0lE-T4jYQxT-NuHSNywgzwIHD7M6SkMvmMKkcU43d4J6R1Y7Uwut8-pRs5l-2coEqkLr7_d5rYYx88UR7s_5i1o8LTNpK2A-xk0hxcZJm3Juq9PzCNZjy0ZQP8-fR2E0HGkb2F1ABbLBXiNIR_JYcIxj7Bb75f8aOwNgtJpWGz2djd1BLQ_mK9Ph3IuiFvVKIgL6BllVzRfTAMSYqPjU9SACEC1_JQ65GgbwynhwBhkvqyKuxX2EgYzfOQZN6xzUqgbaob0cKOJ4__wKcu0MMpPMfHaGPoC2FXJnAywA6CBhr8yFj7Z3jl_euMWucrrd4JYg91YwOInXolesIZwnwnLkYu4nwy1djdwV8P11ZUnTjVPu9Vofh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