• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s | FileCheck %s
2
3; In PR44697, the register allocator inserted loads into the __except block
4; before the instructions that restore EBP and ESP back to what they should be.
5; Make sure they are the first instructions in the __except block.
6
7; ModuleID = 't.cpp'
8source_filename = "t.cpp"
9target datalayout = "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:32-n8:16:32-a:0:32-S32"
10target triple = "i386-pc-windows-msvc19.24.28315"
11
12declare i8* @llvm.frameaddress.p0i8(i32 immarg)
13declare i8* @llvm.eh.recoverfp(i8*, i8*)
14declare i8* @llvm.localrecover(i8*, i8*, i32 immarg)
15declare dso_local i32 @_except_handler3(...)
16declare void @llvm.localescape(...)
17
18define dso_local zeroext i1 @invokewrapper(
19    void ()* nocapture %Fn,
20    i1 zeroext %DumpStackAndCleanup,
21    i32* nocapture dereferenceable(4) %RetCode)
22        personality i32 (...)* @_except_handler3 {
23entry:
24  %__exception_code = alloca i32, align 4
25  call void (...) @llvm.localescape(i32* nonnull %__exception_code)
26  invoke void %Fn()
27          to label %return unwind label %catch.dispatch
28
29catch.dispatch:                                   ; preds = %entry
30  %0 = catchswitch within none [label %__except.ret] unwind to caller
31
32__except.ret:                                     ; preds = %catch.dispatch
33  %1 = catchpad within %0 [i8* bitcast (i32 ()* @filter to i8*)]
34  catchret from %1 to label %__except
35
36__except:                                         ; preds = %__except.ret
37  %2 = load i32, i32* %__exception_code, align 4
38  store i32 %2, i32* %RetCode, align 4
39  br label %return
40
41return:                                           ; preds = %entry, %__except
42  %retval.0 = phi i1 [ false, %__except ], [ true, %entry ]
43  ret i1 %retval.0
44}
45
46; CHECK-LABEL: _invokewrapper:                         # @invokewrapper
47; CHECK:         calll   *8(%ebp)
48; CHECK: LBB0_2:                                 # %return
49
50; CHECK: LBB0_1:                                 # %__except.ret
51; CHECK-NEXT:         movl    -24(%ebp), %esp
52; CHECK-NEXT:         addl    $12, %ebp
53
54; Function Attrs: nofree nounwind
55define internal i32 @filter() {
56entry:
57  %0 = tail call i8* @llvm.frameaddress.p0i8(i32 1)
58  %1 = tail call i8* @llvm.eh.recoverfp(i8* bitcast (i1 (void ()*, i1, i32*)* @invokewrapper to i8*), i8* %0)
59  %2 = tail call i8* @llvm.localrecover(i8* bitcast (i1 (void ()*, i1, i32*)* @invokewrapper to i8*), i8* %1, i32 0)
60  %__exception_code = bitcast i8* %2 to i32*
61  %3 = getelementptr inbounds i8, i8* %0, i32 -20
62  %4 = bitcast i8* %3 to { i32*, i8* }**
63  %5 = load { i32*, i8* }*, { i32*, i8* }** %4, align 4
64  %6 = getelementptr inbounds { i32*, i8* }, { i32*, i8* }* %5, i32 0, i32 0
65  %7 = load i32*, i32** %6, align 4
66  %8 = load i32, i32* %7, align 4
67  store i32 %8, i32* %__exception_code, align 4
68  ret i32 1
69}
70