Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,9 @@ class IndexBitcodeWriter : public BitcodeWriterBase {
// are currently saved in the index in terms of GUID.
forEachSummary([&](GVInfo I, bool IsAliasee) {
GUIDToValueIdMap[I.first] = ++GlobalValueId;
// If this is invoked for an aliasee, we want to record the above mapping,
// but not the information needed for its summary entry (if the aliasee is
// to be imported, we will invoke this separately with IsAliasee=false).
if (IsAliasee)
return;
auto *FS = dyn_cast<FunctionSummary>(I.second);
Expand Down Expand Up @@ -4847,6 +4850,11 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
// radix tree array are identified based on this order.
MapVector<CallStackId, llvm::SmallVector<LinearFrameId>> CallStacks;
forEachSummary([&](GVInfo I, bool IsAliasee) {
// Don't collect this when invoked for an aliasee, as it is not needed for
// the alias summary. If the aliasee is to be imported, we will invoke this
// separately with IsAliasee=false.
if (IsAliasee)
return;
GlobalValueSummary *S = I.second;
assert(S);
auto *FS = dyn_cast<FunctionSummary>(S);
Expand Down
9 changes: 7 additions & 2 deletions llvm/test/ThinLTO/X86/memprof_direct_recursion.ll
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
; RUN: -supports-hot-cold-new \
; RUN: -thinlto-distributed-indexes \
; RUN: -r=%t/b.o,_Z3fooi,plx \
; RUN: -r=%t/b.o,aliasee,plx \
; RUN: -r=%t/b.o,a \
; RUN: -r=%t/b.o,b \
; RUN: -r=%t/b.o,_Znam \
Expand Down Expand Up @@ -65,11 +66,15 @@ source_filename = "b.cpp"
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"
target triple = "x86_64-unknown-linux-gnu"

;; Make sure the distributed summary bitcode writing succeeds when the memprof
;; metadata is in an aliasee.
@_Z3fooi = alias void (), ptr @aliasee

@a = external local_unnamed_addr global ptr, align 8
@b = external local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3fooi(i32 noundef %0) local_unnamed_addr #0 !dbg !9 {
define dso_local void @aliasee(i32 noundef %0) local_unnamed_addr #0 !dbg !9 {
br label %2, !dbg !12

2: ; preds = %7, %1
Expand Down Expand Up @@ -222,4 +227,4 @@ attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "t
!19 = !DILocation(line: 7, column: 5, scope: !9)
!20 = !{i64 8256520048276991898}
!21 = !DILocation(line: 8, column: 5, scope: !9)
!22 = !DISubprogram(name: "foo", linkageName: "_Z3fooi", scope: !1, file: !1, line: 1, type: !10, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)
!22 = !DISubprogram(name: "foo", linkageName: "_Z3fooi", scope: !1, file: !1, line: 1, type: !10, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)
Loading