llvm / llvm/llvm-project

[MoveAutoInit] Moving an auto-init store into a block with a leading catchpad catches `-verify-memoryssa` asserts

Open
#221,568 0 comments 0 reactions 0 assignees View on GitHub
confirmed crash-on-valid llvm:optimizations
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

```llvm
target triple = "x86_64-pc-windows-msvc"

declare void @dummy()
declare i32 @__CxxFrameHandler3(...)

define void @test() personality ptr @__CxxFrameHandler3 {
entry:
%p = alloca i32
store i32 0, ptr %p, !annotation !0
invoke void @dummy() to label %clean unwind label %catchbb

clean:
ret void

catchbb:
%cs = catchswitch within none [label %pad] unwind to caller

pad:
%c = catchpad within %cs [i32 0]
ret void
}

!0 = !{!"auto-init"}
```

```
$ opt -passes=move-auto-init -verify-memoryssa test.ll -disable-output
opt: llvm/lib/Analysis/MemorySSA.cpp:2096: void llvm::MemorySSA::verifyOrderingDominationAndDefUses(...): Assertion `&*ALI == *AAI && "Not the same accesses in the same order"' failed.
...
11 opt llvm::MoveAutoInitPass::run(llvm::Function&, llvm::AnalysisManager&)
```

Reproducer: https://godbolt.org/z/Kxqrdzq5b

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with opt -passes=move-auto-init -verify-memoryssa using the provided test.ll, then inspect llvm/lib/Analysis/MemorySSA.cpp and the MoveAutoInitPass stack entry. Done means the reproducer completes with -verify-memoryssa enabled without the ordering assertion.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.