summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2013-02-26 01:35:30 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2013-02-26 01:35:30 +0000
commit7f09a3d54eba478eccb19280e9946e69ce096ff7 (patch)
treed01b86f3f366537a43b483243d548e6e2174cc26
parentc33b6ac7c9dba85265ae9f5676a6c2dfb8060f8e (diff)
downloadbcm5719-llvm-7f09a3d54eba478eccb19280e9946e69ce096ff7.tar.gz
bcm5719-llvm-7f09a3d54eba478eccb19280e9946e69ce096ff7.zip
[Pass][Layout] Fix bug and add debug printing.
Fix a bug where if two atoms had the same index in the override map, the compare would return false. It now goes to the next check when they are equal. No test because it currently can't be tested. An upcomming patch will test it. llvm-svn: 176073
-rw-r--r--lld/lib/Passes/LayoutPass.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/lld/lib/Passes/LayoutPass.cpp b/lld/lib/Passes/LayoutPass.cpp
index 63940a676ba..38afcc1b595 100644
--- a/lld/lib/Passes/LayoutPass.cpp
+++ b/lld/lib/Passes/LayoutPass.cpp
@@ -8,8 +8,12 @@
//===----------------------------------------------------------------------===//
//===----------------------------------------------------------------------===//
+#define DEBUG_TYPE "LayoutPass"
+
#include "lld/Passes/LayoutPass.h"
+#include "llvm/Support/Debug.h"
+
using namespace lld;
/// The function compares atoms by sorting atoms in the following order
@@ -21,15 +25,20 @@ using namespace lld;
/// f) Sorts atoms on how they appear within the File
bool LayoutPass::CompareAtoms::operator()(const DefinedAtom *left,
const DefinedAtom *right) {
+ DEBUG(llvm::dbgs() << "Sorting " << left->name() << " " << right->name() << "\n");
if (left == right)
return false;
+ DEBUG(llvm::dbgs() << "Sorting by perms\n");
+
// Sort same permissions together.
DefinedAtom::ContentPermissions leftPerms = left->permissions();
DefinedAtom::ContentPermissions rightPerms = right->permissions();
if (leftPerms != rightPerms)
return leftPerms < rightPerms;
+ DEBUG(llvm::dbgs() << "Sorting by contentType\n");
+
// Sort same content types together.
DefinedAtom::ContentType leftType = left->contentType();
DefinedAtom::ContentType rightType = right->contentType();
@@ -38,6 +47,8 @@ bool LayoutPass::CompareAtoms::operator()(const DefinedAtom *left,
// TO DO: Sort atoms in customs sections together.
+ DEBUG(llvm::dbgs() << "Sorting by sectionPos\n");
+
// Sort by section position preference.
DefinedAtom::SectionPosition leftPos = left->sectionPosition();
DefinedAtom::SectionPosition rightPos = right->sectionPosition();
@@ -48,13 +59,16 @@ bool LayoutPass::CompareAtoms::operator()(const DefinedAtom *left,
return leftPos < rightPos;
}
+ DEBUG(llvm::dbgs() << "Sorting by override\n");
+
AtomToOrdinalT::const_iterator lPos = _layout._ordinalOverrideMap.find(left);
AtomToOrdinalT::const_iterator rPos = _layout._ordinalOverrideMap.find(right);
AtomToOrdinalT::const_iterator end = _layout._ordinalOverrideMap.end();
if (lPos != end) {
if (rPos != end) {
// both left and right are overridden, so compare overridden ordinals
- return lPos->second < rPos->second;
+ if (lPos->second != rPos->second)
+ return lPos->second < rPos->second;
} else {
// left is overridden and right is not, so left < right
return true;
@@ -69,18 +83,24 @@ bool LayoutPass::CompareAtoms::operator()(const DefinedAtom *left,
}
}
+ DEBUG(llvm::dbgs() << "Sorting by .o order\n");
+
// Sort by .o order.
const File *leftFile = &left->file();
const File *rightFile = &right->file();
if (leftFile != rightFile)
return leftFile->ordinal() < rightFile->ordinal();
+ DEBUG(llvm::dbgs() << "Sorting by ordinal\n");
+
// Sort by atom order with .o file.
uint64_t leftOrdinal = left->ordinal();
uint64_t rightOrdinal = right->ordinal();
if (leftOrdinal != rightOrdinal)
return leftOrdinal < rightOrdinal;
+ DEBUG(llvm::dbgs() << "Unordered\n");
+
return false;
}
@@ -366,7 +386,6 @@ void LayoutPass::buildOrdinalOverrideMap(MutableFile::DefinedAtomRange &range) {
/// Perform the actual pass
void LayoutPass::perform(MutableFile &mergedFile) {
-
MutableFile::DefinedAtomRange atomRange = mergedFile.definedAtoms();
// Build follow on tables
OpenPOWER on IntegriCloud