[lld] r195106 - Use early continue. Style fix. No functionality change.
Rui Ueyama
ruiu at google.com
Mon Nov 18 22:10:13 PST 2013
Author: ruiu
Date: Tue Nov 19 00:10:13 2013
New Revision: 195106
URL: http://llvm.org/viewvc/llvm-project?rev=195106&view=rev
Log:
Use early continue. Style fix. No functionality change.
Modified:
lld/trunk/include/lld/Core/Pass.h
lld/trunk/lib/Passes/StubsPass.cpp
Modified: lld/trunk/include/lld/Core/Pass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Pass.h?rev=195106&r1=195105&r2=195106&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Pass.h (original)
+++ lld/trunk/include/lld/Core/Pass.h Tue Nov 19 00:10:13 2013
@@ -75,6 +75,9 @@ public:
/// it will call this method to add all the stub (and support) atoms to the
/// master file object.
virtual void addStubAtoms(MutableFile &masterFile) = 0;
+
+private:
+ void replaceCalleeWithStub(const Atom *target, const Reference *ref);
};
/// Pass for adding GOT entries for pointers to functions/data
Modified: lld/trunk/lib/Passes/StubsPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Passes/StubsPass.cpp?rev=195106&r1=195105&r2=195106&view=diff
==============================================================================
--- lld/trunk/lib/Passes/StubsPass.cpp (original)
+++ lld/trunk/lib/Passes/StubsPass.cpp Tue Nov 19 00:10:13 2013
@@ -25,42 +25,42 @@ namespace lld {
void StubsPass::perform(std::unique_ptr<MutableFile> &mergedFile) {
// Skip this pass if output format uses text relocations instead of stubs.
- if ( ! this->noTextRelocs() )
+ if (!this->noTextRelocs())
return;
// Scan all references in all atoms.
for (const DefinedAtom *atom : mergedFile->defined()) {
for (const Reference *ref : *atom) {
// Look at call-sites.
- if (this->isCallSite(ref->kind()) ) {
- const Atom* target = ref->target();
- assert(target != nullptr);
- bool replaceCalleeWithStub = false;
- if ( target->definition() == Atom::definitionSharedLibrary ) {
- // Calls to shared libraries go through stubs.
- replaceCalleeWithStub = true;
- }
- else if (const DefinedAtom* defTarget =
- dyn_cast<DefinedAtom>(target)) {
- if ( defTarget->interposable() != DefinedAtom::interposeNo ) {
- // Calls to interposable functions in same linkage unit
- // must also go through a stub.
- assert(defTarget->scope() != DefinedAtom::scopeTranslationUnit);
- replaceCalleeWithStub = true;
- }
- }
- if ( replaceCalleeWithStub ) {
- // Make file-format specific stub and other support atoms.
- const DefinedAtom* stub = this->getStub(*target);
- assert(stub != nullptr);
- // Switch call site to reference stub atom instead.
- (const_cast<Reference*>(ref))->setTarget(stub);
- }
+ if (!this->isCallSite(ref->kind()))
+ continue;
+ const Atom *target = ref->target();
+ assert(target != nullptr);
+ if (target->definition() == Atom::definitionSharedLibrary) {
+ // Calls to shared libraries go through stubs.
+ replaceCalleeWithStub(target, ref);
+ continue;
+ }
+ const DefinedAtom *defTarget = dyn_cast<DefinedAtom>(target);
+ if (defTarget && defTarget->interposable() != DefinedAtom::interposeNo) {
+ // Calls to interposable functions in same linkage unit must also go
+ // through a stub.
+ assert(defTarget->scope() != DefinedAtom::scopeTranslationUnit);
+ replaceCalleeWithStub(target, ref);
}
}
}
-
// Add all created stubs and support Atoms.
this->addStubAtoms(*mergedFile);
}
+
+void StubsPass::replaceCalleeWithStub(const Atom *target,
+ const Reference *ref) {
+ // Make file-format specific stub and other support atoms.
+ const DefinedAtom *stub = this->getStub(*target);
+ assert(stub != nullptr);
+ // Switch call site to reference stub atom instead.
+ const_cast<Reference *>(ref)->setTarget(stub);
}
+
+} // end namespace lld
More information about the llvm-commits
mailing list