[lld] r192280 - [Layout] Dont set ordinals to Files by default.
Shankar Easwaran
shankare at codeaurora.org
Wed Oct 9 00:32:48 PDT 2013
Author: shankare
Date: Wed Oct 9 02:32:47 2013
New Revision: 192280
URL: http://llvm.org/viewvc/llvm-project?rev=192280&view=rev
Log:
[Layout] Dont set ordinals to Files by default.
This change removes code in various places which was setting the File Ordinals.
This is because the file ordinals are assigned by the way files are resolved.
There was no other way than making the getNextFileAndOrdinal be set const and
change the _nextOrdinal to mutable.
There are so many places in code, that you would need to cleanup to make
LinkingContext non-const!
Modified:
lld/trunk/include/lld/Core/File.h
lld/trunk/include/lld/Core/LinkingContext.h
lld/trunk/include/lld/ReaderWriter/Simple.h
lld/trunk/lib/Core/Resolver.cpp
lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.cpp
lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp
lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp
Modified: lld/trunk/include/lld/Core/File.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/File.h?rev=192280&r1=192279&r2=192280&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/File.h (original)
+++ lld/trunk/include/lld/Core/File.h Wed Oct 9 02:32:47 2013
@@ -220,7 +220,8 @@ protected:
static atom_collection_empty<SharedLibraryAtom> _noSharedLibraryAtoms;
static atom_collection_empty<AbsoluteAtom> _noAbsoluteAtoms;
- StringRef _path;
+private:
+ StringRef _path;
Kind _kind;
mutable uint64_t _ordinal;
};
Modified: lld/trunk/include/lld/Core/LinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/LinkingContext.h?rev=192280&r1=192279&r2=192280&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/LinkingContext.h (original)
+++ lld/trunk/include/lld/Core/LinkingContext.h Wed Oct 9 02:32:47 2013
@@ -316,7 +316,7 @@ public:
virtual void setResolverState(uint32_t resolverState);
/// Return the next ordinal and Increment it.
- virtual uint64_t getNextOrdinalAndIncrement() { return _nextOrdinal++; }
+ virtual uint64_t getNextOrdinalAndIncrement() const { return _nextOrdinal++; }
/// @}
@@ -367,7 +367,7 @@ protected:
std::unique_ptr<InputGraph> _inputGraph;
mutable llvm::BumpPtrAllocator _allocator;
InputElement *_currentInputElement;
- uint64_t _nextOrdinal;
+ mutable uint64_t _nextOrdinal;
private:
/// Validate the subclass bits. Only called by validate.
Modified: lld/trunk/include/lld/ReaderWriter/Simple.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/Simple.h?rev=192280&r1=192279&r2=192280&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/Simple.h (original)
+++ lld/trunk/include/lld/ReaderWriter/Simple.h Wed Oct 9 02:32:47 2013
@@ -24,10 +24,7 @@ namespace lld {
class SimpleFile : public MutableFile {
public:
SimpleFile(const LinkingContext &context, StringRef path)
- : MutableFile(context, path) {
- static uint32_t lastOrdinal = 0;
- _ordinal = lastOrdinal++;
- }
+ : MutableFile(context, path) {}
virtual void addAtom(const Atom &atom) {
if (const DefinedAtom *defAtom = dyn_cast<DefinedAtom>(&atom)) {
Modified: lld/trunk/lib/Core/Resolver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Resolver.cpp?rev=192280&r1=192279&r2=192280&view=diff
==============================================================================
--- lld/trunk/lib/Core/Resolver.cpp (original)
+++ lld/trunk/lib/Core/Resolver.cpp Wed Oct 9 02:32:47 2013
@@ -299,6 +299,7 @@ void Resolver::resolveUndefines() {
if (error_code(nextFile) == InputGraphError::no_more_files)
break;
if (nextFile->kind() == File::kindObject) {
+ assert(!nextFile->hasOrdinal());
nextFile->setOrdinal(_context.getNextOrdinalAndIncrement());
handleFile(*nextFile);
}
Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.cpp?rev=192280&r1=192279&r2=192280&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.cpp Wed Oct 9 02:32:47 2013
@@ -62,9 +62,8 @@ public:
class HexagonInitFiniFile : public SimpleFile {
public:
- HexagonInitFiniFile(const ELFLinkingContext &context):
- SimpleFile(context, "command line option -init/-fini")
- {}
+ HexagonInitFiniFile(const ELFLinkingContext &context)
+ : SimpleFile(context, "command line option -init/-fini"), _ordinal(0) {}
void addInitFunction(StringRef name) {
Atom *initFunctionAtom = new (_allocator) SimpleUndefinedAtom(*this, name);
@@ -88,6 +87,7 @@ public:
private:
llvm::BumpPtrAllocator _allocator;
+ uint64_t _ordinal;
};
}
Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp?rev=192280&r1=192279&r2=192280&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp Wed Oct 9 02:32:47 2013
@@ -107,7 +107,9 @@ public:
class ELFPassFile : public SimpleFile {
public:
- ELFPassFile(const ELFLinkingContext &eti) : SimpleFile(eti, "ELFPassFile") {}
+ ELFPassFile(const ELFLinkingContext &eti) : SimpleFile(eti, "ELFPassFile") {
+ setOrdinal(eti.getNextOrdinalAndIncrement());
+ }
llvm::BumpPtrAllocator _alloc;
};
Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp?rev=192280&r1=192279&r2=192280&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp Wed Oct 9 02:32:47 2013
@@ -78,7 +78,9 @@ public:
class ELFPassFile : public SimpleFile {
public:
- ELFPassFile(const ELFLinkingContext &eti) : SimpleFile(eti, "ELFPassFile") {}
+ ELFPassFile(const ELFLinkingContext &eti) : SimpleFile(eti, "ELFPassFile") {
+ setOrdinal(eti.getNextOrdinalAndIncrement());
+ }
llvm::BumpPtrAllocator _alloc;
};
@@ -478,9 +480,8 @@ public:
class X86_64InitFiniFile : public SimpleFile {
public:
- X86_64InitFiniFile(const ELFLinkingContext &context):
- SimpleFile(context, "command line option -init/-fini")
- {}
+ X86_64InitFiniFile(const ELFLinkingContext &context)
+ : SimpleFile(context, "command line option -init/-fini"), _ordinal(0) {}
void addInitFunction(StringRef name) {
Atom *initFunctionAtom = new (_allocator) SimpleUndefinedAtom(*this, name);
@@ -504,6 +505,7 @@ public:
private:
llvm::BumpPtrAllocator _allocator;
+ uint64_t _ordinal;
};
} // end anon namespace
More information about the llvm-commits
mailing list