llvm.org GIT mirror llvm / bfa8bdb
[CodeExtractor] Use 'normal destination' BB as insert point to store invoke results. Currently CodeExtractor tries to use the next node after an invoke to place the store for the result of the invoke, if it is an out parameter of the region. This fails, as the invoke terminates the current BB. In that case, we can place the store in the 'normal destination' BB, as the result will only be available in that case. Reviewers: davidxl, davide, efriedma Reviewed By: davidxl Differential Revision: https://reviews.llvm.org/D51037 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340331 91177308-0d34-0410-b5e6-96231b3b80d8 Florian Hahn 1 year, 1 month ago
2 changed file(s) with 56 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
924924 auto *OutI = dyn_cast(outputs[i]);
925925 if (!OutI)
926926 continue;
927
927928 // Find proper insertion point.
928 Instruction *InsertPt = OutI->getNextNode();
929 Instruction *InsertPt;
930 // In case OutI is an invoke, we insert the store at the beginning in the
931 // 'normal destination' BB. Otherwise we insert the store right after OutI.
932 if (auto *InvokeI = dyn_cast(OutI))
933 InsertPt = InvokeI->getNormalDest()->getFirstNonPHI();
934 else
935 InsertPt = OutI->getNextNode();
936
929937 // Let's assume that there is no other guy interleave non-PHI in PHIs.
930938 if (isa(InsertPt))
931939 InsertPt = InsertPt->getParent()->getFirstNonPHI();
0 ; RUN: opt < %s -partial-inliner -S | FileCheck %s
1
2 ; Function Attrs: nounwind uwtable
3 define dso_local i8* @bar(i32 %arg) local_unnamed_addr #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
4 bb:
5 %tmp = icmp slt i32 %arg, 0
6 br i1 %tmp, label %bb1, label %bb5
7
8 bb1: ; preds = %bb
9 %call26 = invoke i8* @invoke_callee() #2
10 to label %cont unwind label %lpad
11 lpad: ; preds = %if.end
12 %0 = landingpad { i8*, i32 }
13 cleanup
14 resume { i8*, i32 } undef
15
16 cont:
17 br label %bb5
18
19 bb5: ; preds = %bb4, %bb1, %bb
20 %retval = phi i8* [ %call26, %cont ], [ undef, %bb]
21 ret i8* %retval
22 }
23
24 ; CHECK-LABEL: @dummy_caller
25 ; CHECK-LABEL: bb:
26 ; CHECK-NEXT: [[CALL26LOC:%.*]] = alloca i8*
27 ; CHECK-LABEL: codeRepl.i:
28 ; CHECK-NEXT: call void @bar.1_bb1(i8** [[CALL26LOC]])
29 define i8* @dummy_caller(i32 %arg) {
30 bb:
31 %tmp = tail call i8* @bar(i32 %arg)
32 ret i8* %tmp
33 }
34
35 ; CHECK-LABEL: define internal void @bar.1_bb1
36 ; CHECK-LABEL: bb1:
37 ; CHECK-NEXT: %call26 = invoke i8* @invoke_callee()
38 ; CHECK-NEXT: to label %cont unwind label %lpad
39 ; CHECK-LABEL: cont:
40 ; CHECK-NEXT: store i8* %call26, i8** %call26.out
41 ; CHECK-NEXT: br label %bb5.exitStub
42
43 ; Function Attrs: nobuiltin
44 declare dso_local noalias nonnull i8* @invoke_callee() local_unnamed_addr #1
45
46 declare dso_local i32 @__gxx_personality_v0(...)