Skip to content

Commit a55c4a2

Browse files
committed
Address comments.
1 parent e39a9e2 commit a55c4a2

File tree

4 files changed

+109
-57
lines changed

4 files changed

+109
-57
lines changed

llvm/lib/Transforms/Utils/Local.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3359,9 +3359,7 @@ static void combineMetadata(Instruction *K, const Instruction *J,
33593359
// being removed as unknown metadata. The actual merging is handled
33603360
// separately below.
33613361
case LLVMContext::MD_mmra:
3362-
[[fallthrough]];
33633362
case LLVMContext::MD_memprof:
3364-
[[fallthrough]];
33653363
case LLVMContext::MD_callsite:
33663364
break;
33673365
case LLVMContext::MD_align:
@@ -3422,8 +3420,8 @@ static void combineMetadata(Instruction *K, const Instruction *J,
34223420
// Merge memprof metadata.
34233421
// Handle separately to support cases where only one instruction has the
34243422
// metadata.
3425-
auto JMemProf = J->getMetadata(LLVMContext::MD_memprof);
3426-
auto KMemProf = K->getMetadata(LLVMContext::MD_memprof);
3423+
auto *JMemProf = J->getMetadata(LLVMContext::MD_memprof);
3424+
auto *KMemProf = K->getMetadata(LLVMContext::MD_memprof);
34273425
if (!AAOnly && (JMemProf || KMemProf)) {
34283426
K->setMetadata(LLVMContext::MD_memprof,
34293427
MDNode::getMergedMemProfMetadata(KMemProf, JMemProf));
@@ -3432,8 +3430,8 @@ static void combineMetadata(Instruction *K, const Instruction *J,
34323430
// Merge callsite metadata.
34333431
// Handle separately to support cases where only one instruction has the
34343432
// metadata.
3435-
auto JCallSite = J->getMetadata(LLVMContext::MD_callsite);
3436-
auto KCallSite = K->getMetadata(LLVMContext::MD_callsite);
3433+
auto *JCallSite = J->getMetadata(LLVMContext::MD_callsite);
3434+
auto *KCallSite = K->getMetadata(LLVMContext::MD_callsite);
34373435
if (!AAOnly && (JCallSite || KCallSite)) {
34383436
K->setMetadata(LLVMContext::MD_callsite,
34393437
MDNode::getMergedCallsiteMetadata(KCallSite, JCallSite));
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
;; Test to ensure that memprof related metadata is not dropped when
3+
;; instructions are combined. Currently the metadata from the first instruction
4+
;; is kept, which prevents full loss of profile context information.
5+
6+
; RUN: opt < %s -passes=simplifycfg -S | FileCheck %s
7+
8+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
9+
target triple = "x86_64-unknown-linux-gnu"
10+
11+
define dso_local noundef nonnull ptr @_Z9test_leftb(i1 noundef zeroext %b) local_unnamed_addr #0 {
12+
; CHECK-LABEL: define dso_local noundef nonnull ptr @_Z9test_leftb(
13+
; CHECK-SAME: i1 noundef zeroext [[B:%.*]]) local_unnamed_addr {
14+
; CHECK-NEXT: [[ENTRY:.*:]]
15+
; CHECK-NEXT: [[CALL:%.*]] = call noalias noundef nonnull dereferenceable(4) ptr @_Znwm(i64 noundef 4), !memprof [[META0:![0-9]+]], !callsite [[META3:![0-9]+]]
16+
; CHECK-NEXT: ret ptr [[CALL]]
17+
;
18+
entry:
19+
br i1 %b, label %if.then, label %if.else
20+
21+
if.then: ; preds = %entry
22+
%call = call noalias noundef nonnull dereferenceable(4) ptr @_Znwm(i64 noundef 4), !memprof !0, !callsite !3
23+
br label %if.end
24+
25+
if.else: ; preds = %entry
26+
%call1 = call noalias noundef nonnull dereferenceable(4) ptr @_Znwm(i64 noundef 4)
27+
br label %if.end
28+
29+
if.end: ; preds = %if.else, %if.then
30+
%x.0 = phi ptr [ %call, %if.then ], [ %call1, %if.else ]
31+
ret ptr %x.0
32+
}
33+
34+
declare ptr @_Znwm(i64) nounwind readonly
35+
36+
!0 = !{!1}
37+
!1 = !{!2, !"notcold"}
38+
!2 = !{i64 -852997907418798798, i64 -2101080423462424381, i64 5188446645037944434}
39+
!3 = !{i64 -852997907418798798}
40+
!4 = !{!5}
41+
!5 = !{!6, !"cold"}
42+
!6 = !{i64 123, i64 -2101080423462424381, i64 5188446645037944434}
43+
!7 = !{i64 123}
44+
45+
46+
;.
47+
; CHECK: [[META0]] = !{[[META1:![0-9]+]]}
48+
; CHECK: [[META1]] = !{[[META2:![0-9]+]], !"notcold"}
49+
; CHECK: [[META2]] = !{i64 -852997907418798798, i64 -2101080423462424381, i64 5188446645037944434}
50+
; CHECK: [[META3]] = !{i64 -852997907418798798}
51+
;.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
;; Test to ensure that memprof related metadata is not dropped when
3+
;; instructions are combined. Currently the metadata from the first instruction
4+
;; is kept, which prevents full loss of profile context information.
5+
6+
; RUN: opt < %s -passes=simplifycfg -S | FileCheck %s
7+
8+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
9+
target triple = "x86_64-unknown-linux-gnu"
10+
11+
define dso_local noundef nonnull ptr @_Z10test_rightb(i1 noundef zeroext %b) local_unnamed_addr #0 {
12+
; CHECK-LABEL: define dso_local noundef nonnull ptr @_Z10test_rightb(
13+
; CHECK-SAME: i1 noundef zeroext [[B:%.*]]) local_unnamed_addr {
14+
; CHECK-NEXT: [[ENTRY:.*:]]
15+
; CHECK-NEXT: [[CALL:%.*]] = call noalias noundef nonnull dereferenceable(4) ptr @_Znwm(i64 noundef 4), !memprof [[META0:![0-9]+]], !callsite [[META3:![0-9]+]]
16+
; CHECK-NEXT: ret ptr [[CALL]]
17+
;
18+
entry:
19+
br i1 %b, label %if.then, label %if.else
20+
21+
if.then: ; preds = %entry
22+
%call = call noalias noundef nonnull dereferenceable(4) ptr @_Znwm(i64 noundef 4)
23+
br label %if.end
24+
25+
if.else: ; preds = %entry
26+
%call1 = call noalias noundef nonnull dereferenceable(4) ptr @_Znwm(i64 noundef 4), !memprof !4, !callsite !7
27+
br label %if.end
28+
29+
if.end: ; preds = %if.else, %if.then
30+
%x.0 = phi ptr [ %call, %if.then ], [ %call1, %if.else ]
31+
ret ptr %x.0
32+
}
33+
34+
declare ptr @_Znwm(i64) nounwind readonly
35+
36+
!0 = !{!1}
37+
!1 = !{!2, !"notcold"}
38+
!2 = !{i64 -852997907418798798, i64 -2101080423462424381, i64 5188446645037944434}
39+
!3 = !{i64 -852997907418798798}
40+
!4 = !{!5}
41+
!5 = !{!6, !"cold"}
42+
!6 = !{i64 123, i64 -2101080423462424381, i64 5188446645037944434}
43+
!7 = !{i64 123}
44+
45+
;.
46+
; CHECK: [[META0]] = !{[[META1:![0-9]+]]}
47+
; CHECK: [[META1]] = !{[[META2:![0-9]+]], !"cold"}
48+
; CHECK: [[META2]] = !{i64 123, i64 -2101080423462424381, i64 5188446645037944434}
49+
; CHECK: [[META3]] = !{i64 123}
50+
;.
Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
13
;; Test to ensure that memprof related metadata is not dropped when
24
;; instructions are combined. Currently the metadata from the first instruction
35
;; is kept, which prevents full loss of profile context information.
@@ -30,51 +32,6 @@ if.end: ; preds = %if.else, %if.then
3032
ret ptr %x.0
3133
}
3234

33-
define dso_local noundef nonnull ptr @_Z9test_leftb(i1 noundef zeroext %b) local_unnamed_addr #0 {
34-
; CHECK-LABEL: define dso_local noundef nonnull ptr @_Z9test_leftb(
35-
; CHECK-SAME: i1 noundef zeroext [[B:%.*]]) local_unnamed_addr {
36-
; CHECK-NEXT: [[ENTRY:.*:]]
37-
; CHECK-NEXT: [[CALL:%.*]] = call noalias noundef nonnull dereferenceable(4) ptr @_Znwm(i64 noundef 4), !memprof [[META0:![0-9]+]], !callsite [[META3:![0-9]+]]
38-
; CHECK-NEXT: ret ptr [[CALL]]
39-
;
40-
entry:
41-
br i1 %b, label %if.then, label %if.else
42-
43-
if.then: ; preds = %entry
44-
%call = call noalias noundef nonnull dereferenceable(4) ptr @_Znwm(i64 noundef 4), !memprof !0, !callsite !3
45-
br label %if.end
46-
47-
if.else: ; preds = %entry
48-
%call1 = call noalias noundef nonnull dereferenceable(4) ptr @_Znwm(i64 noundef 4)
49-
br label %if.end
50-
51-
if.end: ; preds = %if.else, %if.then
52-
%x.0 = phi ptr [ %call, %if.then ], [ %call1, %if.else ]
53-
ret ptr %x.0
54-
}
55-
56-
define dso_local noundef nonnull ptr @_Z10test_rightb(i1 noundef zeroext %b) local_unnamed_addr #0 {
57-
; CHECK-LABEL: define dso_local noundef nonnull ptr @_Z10test_rightb(
58-
; CHECK-SAME: i1 noundef zeroext [[B:%.*]]) local_unnamed_addr {
59-
; CHECK-NEXT: [[ENTRY:.*:]]
60-
; CHECK-NEXT: [[CALL:%.*]] = call noalias noundef nonnull dereferenceable(4) ptr @_Znwm(i64 noundef 4), !memprof [[META4:![0-9]+]], !callsite [[META7:![0-9]+]]
61-
; CHECK-NEXT: ret ptr [[CALL]]
62-
;
63-
entry:
64-
br i1 %b, label %if.then, label %if.else
65-
66-
if.then: ; preds = %entry
67-
%call = call noalias noundef nonnull dereferenceable(4) ptr @_Znwm(i64 noundef 4)
68-
br label %if.end
69-
70-
if.else: ; preds = %entry
71-
%call1 = call noalias noundef nonnull dereferenceable(4) ptr @_Znwm(i64 noundef 4), !memprof !4, !callsite !7
72-
br label %if.end
73-
74-
if.end: ; preds = %if.else, %if.then
75-
%x.0 = phi ptr [ %call, %if.then ], [ %call1, %if.else ]
76-
ret ptr %x.0
77-
}
7835

7936
declare ptr @_Znwm(i64) nounwind readonly
8037

@@ -86,13 +43,9 @@ declare ptr @_Znwm(i64) nounwind readonly
8643
!5 = !{!6, !"cold"}
8744
!6 = !{i64 123, i64 -2101080423462424381, i64 5188446645037944434}
8845
!7 = !{i64 123}
89-
46+
;.
9047
; CHECK: [[META0]] = !{[[META1:![0-9]+]]}
9148
; CHECK: [[META1]] = !{[[META2:![0-9]+]], !"notcold"}
9249
; CHECK: [[META2]] = !{i64 -852997907418798798, i64 -2101080423462424381, i64 5188446645037944434}
9350
; CHECK: [[META3]] = !{i64 -852997907418798798}
94-
; CHECK: [[META4]] = !{[[META5:![0-9]+]]}
95-
; CHECK: [[META5]] = !{[[META6:![0-9]+]], !"cold"}
96-
; CHECK: [[META6]] = !{i64 123, i64 -2101080423462424381, i64 5188446645037944434}
97-
; CHECK: [[META7]] = !{i64 123}
98-
51+
;.

0 commit comments

Comments
 (0)