File tree 2 files changed +41
-0
lines changed
test/Transforms/Attributor 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -1504,6 +1504,14 @@ ChangeStatus Attributor::rewriteFunctionSignatures(
1504
1504
NewFn->getBasicBlockList ().splice (NewFn->begin (),
1505
1505
OldFn->getBasicBlockList ());
1506
1506
1507
+ // Fixup block addresses to reference new function.
1508
+ SmallVector<BlockAddress *, 8u > BlockAddresses;
1509
+ for (User *U : OldFn->users ())
1510
+ if (auto *BA = dyn_cast<BlockAddress>(U))
1511
+ BlockAddresses.push_back (BA);
1512
+ for (auto *BA : BlockAddresses)
1513
+ BA->replaceAllUsesWith (BlockAddress::get (NewFn, BA->getBasicBlock ()));
1514
+
1507
1515
// Set of all "call-like" instructions that invoke the old function mapped
1508
1516
// to their new replacements.
1509
1517
SmallVector<std::pair<CallBase *, CallBase *>, 8 > CallSitePairs;
Original file line number Diff line number Diff line change @@ -75,3 +75,36 @@ ret_bb:
75
75
%2 = load i32 , i32* @var2
76
76
ret i32 %2
77
77
}
78
+
79
+ define void @func4 () {
80
+ ; CHECK-LABEL: define {{[^@]+}}@func4
81
+ ; CHECK-NEXT: call void @func5()
82
+ ; CHECK-NEXT: ret void
83
+ ;
84
+ call void @func5 (i32 0 )
85
+ ret void
86
+ }
87
+
88
+ define internal void @func5 (i32 %0 ) {
89
+ ; CHECK-LABEL: define {{[^@]+}}@func5
90
+ ; CHECK-NEXT: [[TMP1:%.*]] = alloca i8*
91
+ ; CHECK-NEXT: br label %block
92
+ ; CHECK: block:
93
+ ; CHECK-NEXT: store i8* blockaddress(@func5, %block), i8** [[TMP1]]
94
+ ; CHECK-NEXT: [[TMP2:%.*]] = load i8*, i8** [[TMP1]]
95
+ ; CHECK-NEXT: call void @func6(i8* [[TMP2]])
96
+ ; CHECK-NEXT: ret void
97
+ ;
98
+ %tmp = alloca i8*
99
+ br label %block
100
+
101
+ block:
102
+ store i8* blockaddress (@func5 , %block ), i8** %tmp
103
+ %addr = load i8* , i8** %tmp
104
+ call void @func6 (i8* %addr )
105
+ ret void
106
+ }
107
+
108
+ ; CHECK-LABEL: declare {{[^@]+}}@func6
109
+ ; CHECK-SAME: (i8*)
110
+ declare void @func6 (i8* )
You can’t perform that action at this time.
0 commit comments