Skip to content

Commit 4422763

Browse files
necipfazilPrabhuk
authored andcommitted
Rebase on top of parent change.
Created using spr 1.3.6-beta.1
2 parents ceef7e4 + f07f515 commit 4422763

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

llvm/lib/Transforms/Utils/Local.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3158,14 +3158,17 @@ static void combineMetadata(Instruction *K, const Instruction *J,
31583158
}
31593159

31603160
// Merge callee_type metadata.
3161-
// Given the called operands are identical, presence of at least one
3162-
// callee_type metadata guarantees the intended callee.
3163-
auto *JCalleeType = J->getMetadata(LLVMContext::MD_callee_type);
3164-
auto *KCalleeType = K->getMetadata(LLVMContext::MD_callee_type);
3165-
if (!AAOnly && (JCalleeType || KCalleeType)) {
3166-
K->setMetadata(LLVMContext::MD_callee_type,
3167-
MDNode::getMergedCalleeTypeMetadata(
3168-
K->getContext(), KCalleeType, JCalleeType));
3161+
if (!AAOnly) {
3162+
auto *JCalleeType = J->getMetadata(LLVMContext::MD_callee_type);
3163+
auto *KCalleeType = K->getMetadata(LLVMContext::MD_callee_type);
3164+
// Drop the callee_type metadata if either of the call instructions do not
3165+
// have it.
3166+
if (JCalleeType && KCalleeType) {
3167+
K->setMetadata(LLVMContext::MD_callee_type,
3168+
MDNode::getMergedCalleeTypeMetadata(
3169+
K->getContext(), KCalleeType, JCalleeType));
3170+
} else
3171+
K->setMetadata(LLVMContext::MD_callee_type, nullptr);
31693172
}
31703173

31713174
// Merge prof metadata.

llvm/test/Transforms/SimplifyCFG/merge-callee-type-metadata.ll

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ if.end: ; preds = %if.else, %if.then
6161
ret ptr %x.0
6262
}
6363

64-
;; Test if the callee_type metadata is merged correctly when
64+
;; Test if the callee_type metadata is dropped correctly when
6565
;; only the left instruction has callee_type metadata.
6666
define ptr @_Z10test_leftb(i1 zeroext %b) {
6767
; CHECK-LABEL: define ptr @_Z10test_leftb(
6868
; CHECK-SAME: i1 zeroext [[B:%.*]]) {
6969
; CHECK-NEXT: [[ENTRY:.*:]]
7070
; CHECK-NEXT: [[FN:%.*]] = alloca ptr, align 8
7171
; CHECK-NEXT: store ptr @_Znwm, ptr [[FN]], align 8
72-
; CHECK-NEXT: [[CALL:%.*]] = call ptr [[FN]](i64 4), !callee_type [[META4:![0-9]+]]
72+
; CHECK-NEXT: [[CALL:%.*]] = call ptr [[FN]](i64 4)
7373
; CHECK-NEXT: ret ptr [[CALL]]
7474
;
7575
entry:
@@ -90,15 +90,15 @@ if.end: ; preds = %if.else, %if.then
9090
ret ptr %x.0
9191
}
9292

93-
;; Test if the callee_type metadata is merged correctly when
93+
;; Test if the callee_type metadata is dropped correctly when
9494
;; only the right instruction has callee_type metadata.
9595
define ptr @_Z10test_rightb(i1 zeroext %b) {
9696
; CHECK-LABEL: define ptr @_Z10test_rightb(
9797
; CHECK-SAME: i1 zeroext [[B:%.*]]) {
9898
; CHECK-NEXT: [[ENTRY:.*:]]
9999
; CHECK-NEXT: [[FN:%.*]] = alloca ptr, align 8
100100
; CHECK-NEXT: store ptr @_Znwm, ptr [[FN]], align 8
101-
; CHECK-NEXT: [[CALL:%.*]] = call ptr [[FN]](i64 4), !callee_type [[META3]]
101+
; CHECK-NEXT: [[CALL:%.*]] = call ptr [[FN]](i64 4)
102102
; CHECK-NEXT: ret ptr [[CALL]]
103103
;
104104
entry:
@@ -127,7 +127,7 @@ define ptr @_Z10test_listb(i1 zeroext %b) {
127127
; CHECK-NEXT: [[ENTRY:.*:]]
128128
; CHECK-NEXT: [[FN:%.*]] = alloca ptr, align 8
129129
; CHECK-NEXT: store ptr @_Znwm, ptr [[FN]], align 8
130-
; CHECK-NEXT: [[CALL:%.*]] = call ptr [[FN]](i64 4), !callee_type [[META5:![0-9]+]]
130+
; CHECK-NEXT: [[CALL:%.*]] = call ptr [[FN]](i64 4), !callee_type [[META4:![0-9]+]]
131131
; CHECK-NEXT: ret ptr [[CALL]]
132132
;
133133
entry:
@@ -162,7 +162,6 @@ declare ptr @_Znwm(i64)
162162
; CHECK: [[META1]] = !{i64 0, !"callee_type2.generalized"}
163163
; CHECK: [[META2]] = !{i64 0, !"callee_type0.generalized"}
164164
; CHECK: [[META3]] = !{[[META2]]}
165-
; CHECK: [[META4]] = !{[[META1]]}
166-
; CHECK: [[META5]] = !{[[META2]], [[META1]], [[META6:![0-9]+]]}
167-
; CHECK: [[META6]] = !{i64 0, !"callee_type1.generalized"}
165+
; CHECK: [[META4]] = !{[[META2]], [[META1]], [[META5:![0-9]+]]}
166+
; CHECK: [[META5]] = !{i64 0, !"callee_type1.generalized"}
168167
;.

0 commit comments

Comments
 (0)