llvm / llvm/llvm-project

[WinEH] Branch folding can lead to `Missing .seh_endepilogue` error

Open
#199,290 1 comment 0 reactions 0 assignees View on GitHub
confirmed crash-on-valid
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

https://llvm.godbolt.org/z/qsM85P37d (llc (trunk))

Reduced code:
$ llc -O2 -mcpu=znver3
```llvm
target triple = "x86_64-pc-windows-msvc19.50.35728"

define i1 @"?getSemanticInterposition@Module@llvm@@QEBA_NXZ"(ptr %0, i32 %1, i32 %2, ptr %3, ptr %4, i1 %5, i64 %.pre) #0 !prof !0 {
br label %7

7:
%8 = load i64, ptr %3, align 8
store i64 %.pre, ptr %4, align 8
br i1 %5, label %9, label %12

9:
%10 = getelementptr [8 x i8], ptr %0, i64 %8
%11 = icmp ne ptr %10, null
br label %common.ret

12:
%13 = icmp eq i32 %1, %2
br i1 %13, label %common.ret, label %7

common.ret:
%common.ret.op = phi i1 [ false, %12 ], [ %11, %9 ]
ret i1 %common.ret.op
}

attributes #0 = { uwtable }

!0 = !{!"function_entry_count", i64 189700382}
```
Output:
```
:0: error: Missing .seh_endepilogue in ?getSemanticInterposition@Module@llvm@@QEBA_NXZ
```
Cause:
The `block-placement` pass folds tails with `SEH_EndEpilogue` instructions, causing a mismatch with `SEH_BeginEpilogue` instructions. See https://llvm.godbolt.org/z/M97qv5Kr9.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.