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
6 changes: 6 additions & 0 deletions llvm/include/llvm/IR/ModuleSummaryIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -1449,6 +1449,9 @@ class ModuleSummaryIndex {
/// every summary of a GV is synchronized.
bool WithDSOLocalPropagation = false;

/// Indicates that summary-based internalization and promotion has run.
bool WithInternalizeAndPromote = false;

/// Indicates that we have whole program visibility.
bool WithWholeProgramVisibility = false;

Expand Down Expand Up @@ -1653,6 +1656,9 @@ class ModuleSummaryIndex {
bool withDSOLocalPropagation() const { return WithDSOLocalPropagation; }
void setWithDSOLocalPropagation() { WithDSOLocalPropagation = true; }

bool withInternalizeAndPromote() const { return WithInternalizeAndPromote; }
void setWithInternalizeAndPromote() { WithInternalizeAndPromote = true; }

bool withWholeProgramVisibility() const { return WithWholeProgramVisibility; }
void setWithWholeProgramVisibility() { WithWholeProgramVisibility = true; }

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Bitcode/Reader/BitcodeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8601,7 +8601,7 @@ getEnableSplitLTOUnitAndUnifiedFlag(BitstreamCursor &Stream,
case bitc::FS_FLAGS: { // [flags]
uint64_t Flags = Record[0];
// Scan flags.
assert(Flags <= 0x2ff && "Unexpected bits in flag");
assert(Flags <= 0x7ff && "Unexpected bits in flag");

bool EnableSplitLTOUnit = Flags & 0x8;
bool UnifiedLTO = Flags & 0x200;
Expand Down
8 changes: 7 additions & 1 deletion llvm/lib/IR/ModuleSummaryIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,13 @@ uint64_t ModuleSummaryIndex::getFlags() const {
Flags |= 0x100;
if (hasUnifiedLTO())
Flags |= 0x200;
if (withInternalizeAndPromote())
Flags |= 0x400;
return Flags;
}

void ModuleSummaryIndex::setFlags(uint64_t Flags) {
assert(Flags <= 0x2ff && "Unexpected bits in flag");
assert(Flags <= 0x7ff && "Unexpected bits in flag");
// 1 bit: WithGlobalValueDeadStripping flag.
// Set on combined index only.
if (Flags & 0x1)
Expand Down Expand Up @@ -154,6 +156,10 @@ void ModuleSummaryIndex::setFlags(uint64_t Flags) {
// Set on combined index only.
if (Flags & 0x200)
setUnifiedLTO();
// 1 bit: WithInternalizeAndPromote flag.
// Set on combined index only.
if (Flags & 0x400)
setWithInternalizeAndPromote();
}

// Collect for the given module the list of function it defines
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/LTO/LTO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,9 +551,11 @@ void llvm::thinLTOInternalizeAndPromoteInIndex(
function_ref<bool(StringRef, ValueInfo)> isExported,
function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
isPrevailing) {
assert(!Index.withInternalizeAndPromote());
for (auto &I : Index)
thinLTOInternalizeAndPromoteGUID(Index.getValueInfo(I), isExported,
isPrevailing);
Index.setWithInternalizeAndPromote();
}

// Requires a destructor for std::vector<InputModule>.
Expand Down
20 changes: 0 additions & 20 deletions llvm/test/Bitcode/thinlto-deadstrip-flag.ll

This file was deleted.

39 changes: 39 additions & 0 deletions llvm/test/Bitcode/thinlto-index-flags.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
; REQUIRES: x86-registered-target
; RUN: opt -module-summary %s -o %t.o

;; By default, the indexing step should perform and set the appropriate index
;; flags for dead stripping, attribute propagation, DSO local propagation,
;; and internalization/promotion.
; RUN: llvm-lto2 run %t.o -o %t.out -thinlto-distributed-indexes \
; RUN: -r %t.o,glob,plx
; RUN: llvm-bcanalyzer -dump %t.o.thinlto.bc | FileCheck %s --check-prefix=ALL
;; The flag value should be 0x461 aka 1121:
;; 0x1: Dead stripping
;; 0x20: Attribute propagation
;; 0x40: DSO local propagation
;; 0x400: Internalization/promotion
; ALL: <FLAGS op0=1121/>

;; Ensure dead stripping performed flag is not set on distributed index
;; when option used to disable dead stripping computation.
; RUN: llvm-lto2 run %t.o -o %t.out -thinlto-distributed-indexes \
; RUN: -r %t.o,glob,plx -compute-dead=false
; RUN: llvm-bcanalyzer -dump %t.o.thinlto.bc | FileCheck %s --check-prefix=NODEAD
;; Flag should be 0x460 aka 1120.
; NODEAD: <FLAGS op0=1120/>

;; Disabling attribute propagation should disable that as well as DSO local
;; propagation.
; RUN: llvm-lto2 run %t.o -o %t.out -thinlto-distributed-indexes \
; RUN: -r %t.o,glob,plx -propagate-attrs=false
; RUN: llvm-bcanalyzer -dump %t.o.thinlto.bc | FileCheck %s --check-prefix=NOPROP
;; Flag should be 0x401 aka 1025.
; NOPROP: <FLAGS op0=1025/>

;; Note there isn't currently a way to disable internalization+promotion, which
;; are performed together.

target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@glob = global i32 0