mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
Revert "UseListOrder: Order GlobalValue uses after initializers"
This reverts commits r214242 and r214243 while I investigate buildbot failures [1][2][3]. I can't reproduce these failures locally, so if anyone can see what I've done wrong, I'd appreciate a note. [1]: http://lab.llvm.org:8011/builders/llvm-hexagon-elf/builds/9840 [2]: http://lab.llvm.org:8011/builders/clang-hexagon-elf/builds/14981 [3]: http://bb.pgr.jp/builders/cmake-llvm-x86_64-linux/builds/15191 llvm-svn: 214249
This commit is contained in:
parent
afb8bfcb47
commit
cc8a88fa18
@ -28,17 +28,6 @@ using namespace llvm;
|
|||||||
namespace {
|
namespace {
|
||||||
struct OrderMap {
|
struct OrderMap {
|
||||||
DenseMap<const Value *, std::pair<unsigned, bool>> IDs;
|
DenseMap<const Value *, std::pair<unsigned, bool>> IDs;
|
||||||
unsigned LastGlobalConstantID;
|
|
||||||
unsigned LastGlobalValueID;
|
|
||||||
|
|
||||||
OrderMap() : LastGlobalConstantID(0), LastGlobalValueID(0) {}
|
|
||||||
|
|
||||||
bool isGlobalConstant(unsigned ID) const {
|
|
||||||
return ID <= LastGlobalConstantID;
|
|
||||||
}
|
|
||||||
bool isGlobalValue(unsigned ID) const {
|
|
||||||
return ID <= LastGlobalValueID && !isGlobalConstant(ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned size() const { return IDs.size(); }
|
unsigned size() const { return IDs.size(); }
|
||||||
std::pair<unsigned, bool> &operator[](const Value *V) { return IDs[V]; }
|
std::pair<unsigned, bool> &operator[](const Value *V) { return IDs[V]; }
|
||||||
@ -55,7 +44,7 @@ static void orderValue(const Value *V, OrderMap &OM) {
|
|||||||
if (const Constant *C = dyn_cast<Constant>(V))
|
if (const Constant *C = dyn_cast<Constant>(V))
|
||||||
if (C->getNumOperands() && !isa<GlobalValue>(C))
|
if (C->getNumOperands() && !isa<GlobalValue>(C))
|
||||||
for (const Value *Op : C->operands())
|
for (const Value *Op : C->operands())
|
||||||
if (!isa<BasicBlock>(Op) && !isa<GlobalValue>(Op))
|
if (!isa<BasicBlock>(Op))
|
||||||
orderValue(Op, OM);
|
orderValue(Op, OM);
|
||||||
|
|
||||||
// Note: we cannot cache this lookup above, since inserting into the map
|
// Note: we cannot cache this lookup above, since inserting into the map
|
||||||
@ -68,11 +57,12 @@ static OrderMap orderModule(const Module *M) {
|
|||||||
// and ValueEnumerator::incorporateFunction().
|
// and ValueEnumerator::incorporateFunction().
|
||||||
OrderMap OM;
|
OrderMap OM;
|
||||||
|
|
||||||
// In the reader, initializers of GlobalValues are set *after* all the
|
for (const GlobalVariable &G : M->globals())
|
||||||
// globals have been read. Rather than awkwardly modeling this behaviour
|
orderValue(&G, OM);
|
||||||
// directly in predictValueUseListOrderImpl(), just assign IDs to
|
for (const Function &F : *M)
|
||||||
// initializers of GlobalValues before GlobalValues themselves to model this
|
orderValue(&F, OM);
|
||||||
// implicitly.
|
for (const GlobalAlias &A : M->aliases())
|
||||||
|
orderValue(&A, OM);
|
||||||
for (const GlobalVariable &G : M->globals())
|
for (const GlobalVariable &G : M->globals())
|
||||||
if (G.hasInitializer())
|
if (G.hasInitializer())
|
||||||
orderValue(G.getInitializer(), OM);
|
orderValue(G.getInitializer(), OM);
|
||||||
@ -81,23 +71,6 @@ static OrderMap orderModule(const Module *M) {
|
|||||||
for (const Function &F : *M)
|
for (const Function &F : *M)
|
||||||
if (F.hasPrefixData())
|
if (F.hasPrefixData())
|
||||||
orderValue(F.getPrefixData(), OM);
|
orderValue(F.getPrefixData(), OM);
|
||||||
OM.LastGlobalConstantID = OM.size();
|
|
||||||
|
|
||||||
// Initializers of GlobalValues are processed in
|
|
||||||
// BitcodeReader::ResolveGlobalAndAliasInits(). Match the order there rather
|
|
||||||
// than ValueEnumerator, and match the code in predictValueUseListOrderImpl()
|
|
||||||
// by giving IDs in reverse order.
|
|
||||||
//
|
|
||||||
// Since GlobalValues never reference each other directly (just through
|
|
||||||
// initializers), their relative IDs only matter for determining order of
|
|
||||||
// uses in their initializers.
|
|
||||||
for (const Function &F : *M)
|
|
||||||
orderValue(&F, OM);
|
|
||||||
for (const GlobalAlias &A : M->aliases())
|
|
||||||
orderValue(&A, OM);
|
|
||||||
for (const GlobalVariable &G : M->globals())
|
|
||||||
orderValue(&G, OM);
|
|
||||||
OM.LastGlobalValueID = OM.size();
|
|
||||||
|
|
||||||
for (const Function &F : *M) {
|
for (const Function &F : *M) {
|
||||||
if (F.isDeclaration())
|
if (F.isDeclaration())
|
||||||
@ -137,8 +110,8 @@ static void predictValueUseListOrderImpl(const Value *V, const Function *F,
|
|||||||
// We may have lost some users.
|
// We may have lost some users.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool IsGlobalValue = OM.isGlobalValue(ID);
|
std::sort(List.begin(), List.end(),
|
||||||
std::sort(List.begin(), List.end(), [&](const Entry &L, const Entry &R) {
|
[&OM, ID](const Entry &L, const Entry &R) {
|
||||||
const Use *LU = L.first;
|
const Use *LU = L.first;
|
||||||
const Use *RU = R.first;
|
const Use *RU = R.first;
|
||||||
if (LU == RU)
|
if (LU == RU)
|
||||||
@ -146,36 +119,22 @@ static void predictValueUseListOrderImpl(const Value *V, const Function *F,
|
|||||||
|
|
||||||
auto LID = OM.lookup(LU->getUser()).first;
|
auto LID = OM.lookup(LU->getUser()).first;
|
||||||
auto RID = OM.lookup(RU->getUser()).first;
|
auto RID = OM.lookup(RU->getUser()).first;
|
||||||
|
|
||||||
// Global values are processed in reverse order.
|
|
||||||
//
|
|
||||||
// Moreover, initializers of GlobalValues are set *after* all the globals
|
|
||||||
// have been read (despite having earlier IDs). Rather than awkwardly
|
|
||||||
// modeling this behaviour here, orderModule() has assigned IDs to
|
|
||||||
// initializers of GlobalValues before GlobalValues themselves.
|
|
||||||
if (OM.isGlobalValue(LID) && OM.isGlobalValue(RID))
|
|
||||||
return LID < RID;
|
|
||||||
|
|
||||||
// If ID is 4, then expect: 7 6 5 1 2 3.
|
// If ID is 4, then expect: 7 6 5 1 2 3.
|
||||||
if (LID < RID) {
|
if (LID < RID) {
|
||||||
if (RID < ID)
|
if (RID < ID)
|
||||||
if (!IsGlobalValue) // GlobalValue uses don't get reversed.
|
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (RID < LID) {
|
if (RID < LID) {
|
||||||
if (LID < ID)
|
if (LID < ID)
|
||||||
if (!IsGlobalValue) // GlobalValue uses don't get reversed.
|
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// LID and RID are equal, so we have different operands of the same user.
|
// LID and RID are equal, so we have different operands of the same user.
|
||||||
// Assume operands are added in order for all instructions.
|
// Assume operands are added in order for all instructions.
|
||||||
if (LID < ID)
|
if (LU->getOperandNo() < RU->getOperandNo())
|
||||||
if (!IsGlobalValue) // GlobalValue uses don't get reversed.
|
return LID < ID;
|
||||||
return LU->getOperandNo() < RU->getOperandNo();
|
return ID < LID;
|
||||||
return LU->getOperandNo() > RU->getOperandNo();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (std::is_sorted(
|
if (std::is_sorted(
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
; RUN: llvm-dis < %s.bc | FileCheck %s
|
; RUN: llvm-dis < %s.bc | FileCheck %s
|
||||||
; RUN: llvm-uselistorder < %s.bc -preserve-bc-use-list-order -num-shuffles=5
|
|
||||||
|
|
||||||
; local-linkage-default-visibility.3.4.ll.bc was generated by passing this file
|
; local-linkage-default-visibility.3.4.ll.bc was generated by passing this file
|
||||||
; to llvm-as-3.4. The test checks that LLVM upgrades visibility of symbols
|
; to llvm-as-3.4. The test checks that LLVM upgrades visibility of symbols
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
; RUN: llvm-dis < %s.bc | FileCheck %s
|
; RUN: llvm-dis < %s.bc | FileCheck %s
|
||||||
; RUN: llvm-uselistorder < %s.bc -preserve-bc-use-list-order -num-shuffles=5
|
|
||||||
|
|
||||||
; old-aliases.bc consist of this file assembled with an old llvm-as (3.5 trunk)
|
; old-aliases.bc consist of this file assembled with an old llvm-as (3.5 trunk)
|
||||||
; from when aliases contained a ConstantExpr.
|
; from when aliases contained a ConstantExpr.
|
||||||
|
@ -3,20 +3,6 @@
|
|||||||
@a = global [4 x i1] [i1 0, i1 1, i1 0, i1 1]
|
@a = global [4 x i1] [i1 0, i1 1, i1 0, i1 1]
|
||||||
@b = alias i1* getelementptr ([4 x i1]* @a, i64 0, i64 2)
|
@b = alias i1* getelementptr ([4 x i1]* @a, i64 0, i64 2)
|
||||||
|
|
||||||
; Check use-list order of constants used by globals.
|
|
||||||
@glob1 = global i5 7
|
|
||||||
@glob2 = global i5 7
|
|
||||||
@glob3 = global i5 7
|
|
||||||
|
|
||||||
; Check use-list order between variables and aliases.
|
|
||||||
@target = global i3 zeroinitializer
|
|
||||||
@alias1 = alias i3* @target
|
|
||||||
@alias2 = alias i3* @target
|
|
||||||
@alias3 = alias i3* @target
|
|
||||||
@var1 = global i3* @target
|
|
||||||
@var2 = global i3* @target
|
|
||||||
@var3 = global i3* @target
|
|
||||||
|
|
||||||
define i64 @f(i64 %f) {
|
define i64 @f(i64 %f) {
|
||||||
entry:
|
entry:
|
||||||
%sum = add i64 %f, 0
|
%sum = add i64 %f, 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user