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

    <tr>
        <th>Summary</th>
        <td>
            Opt Crash "LLVM ERROR: Broken module found, compilation aborted!"
        </td>
    </tr>

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

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

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

<pre>
    Hi, when I optimize the following program

```
define i32 @test1() #0 {
entry:
  ret i32 100
}

; Function Attrs: argmemonly nounwind optnone readonly
declare i32 @test2(i8*, i8*) #1

; Function Attrs: argmemonly nounwind optnone readonly
declare i32 @test3(i8*) local_unnamed_addr #1

; Function Attrs: argmemonly nounwind optnone readonly
declare i32 @__memcpy_chk(i8* nocapture readonly align 8, i8* nocapture readonly align 8, i32, i32) #1

; Function Attrs: argmemonly nounwind optnone readonly
declare i32 @__memset_chk(i8* nocapture readonly, i32, i32, i8) #1

attributes #0 = { nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+fxsr,+mmx,+sse,+sse2,+sse3,+ssse3" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { argmemonly nounwind optnone readonly }

!llvm.module.flags =!{!0,!1,!2,!3}

!0 =!{i32 1,!"Dwarf Version", i32 4}
!1 =!{i32 2,!"Debug Info Version", i32 3}
!2 =!{i32 1,!"wchar_size", i32 4}
!3 =!{!""}
```

with the command

```bash
opt -O3 a.ll -mtriple=x86_64-unknown-linux-gnu -o a-opt.ll
```

I got the following error

```
Attribute 'optnone' requires 'noinline'!
ptr @test1
Attribute 'optnone' requires 'noinline'!
ptr @test2
Attribute 'optnone' requires 'noinline'!
ptr @test3
Attribute 'optnone' requires 'noinline'!
ptr @__memcpy_chk
Attribute 'optnone' requires 'noinline'!
ptr @__memset_chk
incorrect number of operands in module flag
!3 = !{!""}
LLVM ERROR: Broken module found, compilation aborted!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: opt -O3 a.ll -mtriple=x86_64-unknown-linux-gnu -o a-opt.ll
...
[1]    2414403 abort opt -O3 a.ll -mtriple=x86_64-unknown-linux-gnu -o a-opt.ll
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0V1uP2zgP_TXKC6HApp3bQx4mkw6-Av3QogUK7FMg27Stjiy5ujST_vqF5Vw2bTqz2E6DwFasI_JQPiQV4ZxsNNGazTZstp2I4Ftj138J3dy3pA9B6ElhqsP6f5LhPexb0vAWTO9lJ78T-JagNkqZvdQN9NY0VnQs2bLk7nidJ8dv_FlRLTWBzBBYnnhyPmW4ZLgChlkCbLEZcaS9PbDsaATAko-L0uRoiC22V26yDTwEXXppNNx5bx3L7kDYpqPOaHUAbYLeS10N1LXRBJZENcyceJVK2CtiyHAplwzvhriPg0gz_cOOs4vjFShTCrULWouOqp2oKvunKex2HXVlf9iV7eOJCWhTit4He1kLQslGw_K8Oy9hMjzf_vg2xhgc-Rdi-JHXGMnP7IT3VhbBkzvKNNsOUv2ZFEMsjbVUenXg1gRdUcUr-U1WxN1X63nd8074liGybMsQa6EcMcRhZSWdKBRxL6TipVDK3YQpco73lkrpiNd9J6qbMG14bUVHvDdSe7KclOzOSG_Ds0CujeaKRH0BSV27Z_lrw7-Erud-iOI2d224FvpFM7EkVfw7WfMi1lvR91I3vwY5L8pH3lvjqfTG8iLUNVnu5Hc645dHrBe2Ic_LPpynetL2oK_naxKDkC5BMtyUT-mc4T3DTf3k7Djquqdx4AY2xwGeR9lp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