diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2017-12-21 21:45:35 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2017-12-21 21:45:35 +0000 |
| commit | a973cc2282d4fa6f9822a87377e2c6cc28caa175 (patch) | |
| tree | 661fbd8ecd272236d7639aeb1931f5dfc62f9453 | |
| parent | 8c20828b5c2833b5d63539992dde30bd29429491 (diff) | |
| download | bcm5719-llvm-a973cc2282d4fa6f9822a87377e2c6cc28caa175.tar.gz bcm5719-llvm-a973cc2282d4fa6f9822a87377e2c6cc28caa175.zip | |
Call isStaticLinkTimeConstant only once per relocation.
It is a pretty expensive function. Some of the speedups:
clang: 1.92%
chrome: 1.15%
linux-kernel: 1.40%
llvm-svn: 321311
| -rw-r--r-- | lld/ELF/Relocations.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index ec4c8b6fc0c..d7be315929b 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -556,7 +556,8 @@ static void errorOrWarn(const Twine &Msg) { template <class ELFT> static RelExpr adjustExpr(Symbol &Sym, RelExpr Expr, RelType Type, - InputSectionBase &S, uint64_t RelOff) { + InputSectionBase &S, uint64_t RelOff, + bool &IsConstant) { // We can create any dynamic relocation if a section is simply writable. if (S.Flags & SHF_WRITE) return Expr; @@ -569,7 +570,7 @@ static RelExpr adjustExpr(Symbol &Sym, RelExpr Expr, RelType Type, // If a relocation can be applied at link-time, we don't need to // create a dynamic relocation in the first place. - if (isStaticLinkTimeConstant<ELFT>(Expr, Type, Sym, S, RelOff)) + if (IsConstant) return Expr; // If we got here we know that this relocation would require the dynamic @@ -579,6 +580,7 @@ static RelExpr adjustExpr(Symbol &Sym, RelExpr Expr, RelType Type, // non preemptible 0. if (Sym.isUndefWeak()) { Sym.IsPreemptible = false; + IsConstant = true; return Expr; } @@ -611,6 +613,7 @@ static RelExpr adjustExpr(Symbol &Sym, RelExpr Expr, RelType Type, addCopyRelSymbol<ELFT>(B); } + IsConstant = true; return Expr; } @@ -637,6 +640,7 @@ static RelExpr adjustExpr(Symbol &Sym, RelExpr Expr, RelType Type, // R_386_JMP_SLOT, etc). Sym.NeedsPltAddr = true; Sym.IsPreemptible = false; + IsConstant = true; return toPlt(Expr); } @@ -923,7 +927,10 @@ static void scanRelocs(InputSectionBase &Sec, ArrayRef<RelTy> Rels) { else if (!Preemptible) Expr = fromPlt(Expr); - Expr = adjustExpr<ELFT>(Sym, Expr, Type, Sec, Rel.r_offset); + bool IsConstant = + isStaticLinkTimeConstant<ELFT>(Expr, Type, Sym, Sec, Rel.r_offset); + + Expr = adjustExpr<ELFT>(Sym, Expr, Type, Sec, Rel.r_offset, IsConstant); if (errorCount()) continue; @@ -1005,10 +1012,6 @@ static void scanRelocs(InputSectionBase &Sec, ArrayRef<RelTy> Rels) { continue; } - // If the relocation points to something in the file, we can process it. - bool IsConstant = - isStaticLinkTimeConstant<ELFT>(Expr, Type, Sym, Sec, Rel.r_offset); - // The size is not going to change, so we fold it in here. if (Expr == R_SIZE) Addend += Sym.getSize(); |

