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

    <tr>
        <th>Summary</th>
        <td>
            Attributor assigns `!invariant.load` attribute incorrectly
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          igogo-x86
      </td>
    </tr>
</table>

<pre>
    Reproducer:

```
; ModuleID = 'test-invariant.c'
source_filename = "test-invariant.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32"
target triple = "aarch64-unknown-linux-gnu"

define void @init(ptr %call) #0 {
        store i32 100, ptr %call, align 4
        ret void
}

define i32 @read(ptr %call) {
  %arrayidx = getelementptr inbounds float, ptr %call, i64 0
 %result = load i32, ptr %arrayidx
        ret i32 %result
}

define i32 @x() {
  %call = alloca i32, align 4
  call void @init(ptr %call)
  %r = call i32 @read(ptr %call)
  ret i32 %r
}

attributes #0 = { noinline }
```

After running `opt -S -passes=attributor,inline,gvn < test-invariant.ll` function `x` returns under and `load i32, ptr %call` gets incorrect `!invaraint.load` attribute:


```
; Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(argmem: write)
define void @init(ptr nofree noundef nonnull writeonly align 4 captures(none) dereferenceable(4) %call) #0 {
  store i32 100, ptr %call, align 4
  ret void
}

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read)
define i32 @read(ptr nofree nonnull readonly align 4 captures(none) dereferenceable(4) %call) #1 {
  %result = load i32, ptr %call, align 4, !invariant.load !0
 ret i32 %result
}

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
define i32 @x() #2 {
  %call = alloca i32, align 4
  call void @init(ptr noalias nofree noundef nonnull writeonly align 4 captures(none) dereferenceable(4) %call) #4
  call void @llvm.experimental.noalias.scope.decl(metadata !1)
  ret i32 undef
}

```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy0VsuOqzgQ_RpnUyIyhhBYsKA7ijSL2cz9gJHBBe0ZYyM_upO_H9nk1X37tmZG90oRwbgep46rDnDn5KQRW7J7IrvDhgf_YmwrJzOZ7FRXm96Ic_sHLtaIMKAlRUdo-lX08qMdKZ7gdyOCwt8OQIoDELb36Hwm9Su3kmu_HQjbE9o5E-yAf45SoeYzXozZ98aM0M5zO6EHwT1X_GyCv5pjNpOiw2xhe0qKrmDpEpf5-2W8q8p0yWRNiq5et2RekaJLl7i6meQsGuSsznSx-mbf4uoYl4-YvJWLusHn3A4vVZkF_bc2bzpTUodTNumw-hDaCRylRng1UgApqdTSE1Yv3gJhu4ErRVgDhBUUyP4puTTOG4sgCwY5pYQ9wzvrZ-BKThrK1diiT8Hjan94lzNGICW1yMUnKVM2iI-4tfwsxSkVNaFHhTNqHx2k7k3QwsGoDPefYJFVCbER4jOLLqj1qJThIuZ_8LhmucNO-K5uP8Z_Iqz-gDhmT3m4Umbg10x3YgCSyZesX4PZFCnZf8VYMn-E_YiYe29lHzy6y1nG9tg_gTZSq1jLxfJxdGjXjR4t2KC11BOQiprFQ_YNsoU7h44Uh2tcYwl7XkMR9jy9aiDFM3wYHqVIRWEMevDS6BjvFB9Y9MFqB0ELtMC1iDufHFCqs6KxAxxIPRhrcfDRmLA8ZeEyZjFcRLNbyXdh-F4bjlcwnffWkaKDOTi_WDNZdA60GS3inSVtLA7BunjnznoAbYJ-k1rAm1RqLQRmnI09E1ZzO80Y9QDerPS4ntGP5-2WLBIxgjZaB6VWX6PV-do-MPDFB4uOsFqbSHgDAi2OaFEPyHuFhNXlOrefjTDAv5_gtaU-DvB_oe7_Mba2ePOVWNwyrDzFnZ9CU_44yV9rxke-2DNce3Ht-OhCWJ4U6EtJ-VWMXir_sWixuP4pyqUNV5K7X9_Hn8BQ6nXe4mlBK-OrgavtB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