Skip to content

Commit f8182f1

Browse files
committed
[ThinLTO] Fix printing of aliases for distributed backend indexes
Summary: When we import an alias (which will import a copy of the aliasee), but aren't going to import the aliasee directly, the distributed backend index will not contain the aliasee summary. Handle this in the summary assembly printer by printing "null" as the aliasee. Reviewers: davidxl, dexonsmith Subscribers: mehdi_amini, inglorion, eraman, steven_wu, llvm-commits Differential Revision: https://reviews.llvm.org/D48699 llvm-svn: 336160
1 parent 0409a8a commit f8182f1

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

llvm/lib/IR/AsmWriter.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2788,8 +2788,14 @@ static const char *getSummaryKindName(GlobalValueSummary::SummaryKind SK) {
27882788
}
27892789

27902790
void AssemblyWriter::printAliasSummary(const AliasSummary *AS) {
2791-
Out << ", aliasee: ^"
2792-
<< Machine.getGUIDSlot(SummaryToGUIDMap[&AS->getAliasee()]);
2791+
Out << ", aliasee: ";
2792+
// The indexes emitted for distributed backends may not include the
2793+
// aliasee summary (only if it is being imported directly). Handle
2794+
// that case by just emitting "null" as the aliasee.
2795+
if (AS->hasAliasee())
2796+
Out << "^" << Machine.getGUIDSlot(SummaryToGUIDMap[&AS->getAliasee()]);
2797+
else
2798+
Out << "null";
27932799
}
27942800

27952801
void AssemblyWriter::printGlobalVarSummary(const GlobalVarSummary *GS) {

llvm/test/ThinLTO/X86/distributed_indexes.ll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@
4040
; BACKEND2-NEXT: <COMBINED_ALIAS
4141
; BACKEND2-NEXT: </GLOBALVAL_SUMMARY_BLOCK
4242

43+
; Make sure that when the alias is imported as a copy of the aliasee, but the
44+
; aliasee is not being imported by itself, that we can still print the summary.
45+
; The aliasee should be "null".
46+
; RUN: llvm-dis %t1.bc.thinlto.bc -o - | FileCheck %s --check-prefix=DIS
47+
; DIS: aliasee: null
48+
4349
declare void @g(...)
4450
declare void @analias(...)
4551

0 commit comments

Comments
 (0)