diff options
author | Eric Andersen <andersen@codepoet.org> | 2004-02-14 11:54:09 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2004-02-14 11:54:09 +0000 |
commit | d891064218c362387465ab1ad98e438d8d0b4b91 (patch) | |
tree | ab14ea12ddc2456c13520784381a7418f6566c18 | |
parent | deec524084aa2faad66f7aae7e8b5ba1ab6789fd (diff) |
Give gcc branch prediction some hits on obviously unlikely branches
-rw-r--r-- | ldso/ldso/arm/elfinterp.c | 10 | ||||
-rw-r--r-- | ldso/ldso/cris/elfinterp.c | 8 | ||||
-rw-r--r-- | ldso/ldso/i386/elfinterp.c | 4 | ||||
-rw-r--r-- | ldso/ldso/m68k/elfinterp.c | 4 | ||||
-rw-r--r-- | ldso/ldso/mips/elfinterp.c | 2 | ||||
-rw-r--r-- | ldso/ldso/powerpc/elfinterp.c | 10 | ||||
-rw-r--r-- | ldso/ldso/sh/elfinterp.c | 8 | ||||
-rw-r--r-- | ldso/ldso/sh64/elfinterp.c | 9 | ||||
-rw-r--r-- | ldso/ldso/sparc/elfinterp.c | 6 |
9 files changed, 31 insertions, 30 deletions
diff --git a/ldso/ldso/arm/elfinterp.c b/ldso/ldso/arm/elfinterp.c index 5ab1f148d..c04477561 100644 --- a/ldso/ldso/arm/elfinterp.c +++ b/ldso/ldso/arm/elfinterp.c @@ -137,7 +137,7 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry) symname = strtab + symtab[symtab_index].st_name; - if (reloc_type != R_ARM_JUMP_SLOT) { + if (unlikely(reloc_type != R_ARM_JUMP_SLOT)) { _dl_dprintf(2, "%s: Incorrect relocation type in jump relocations\n", _dl_progname); _dl_exit(1); @@ -151,7 +151,7 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry) /* Get the address of the GOT entry */ new_addr = _dl_find_hash(symname, tpnt->symbol_scope, ELF_RTYPE_CLASS_PLT); - if (!new_addr) { + if (unlikely(!new_addr)) { _dl_dprintf(2, "%s: can't resolve symbol '%s'\n", _dl_progname, symname); _dl_exit(1); @@ -223,7 +223,7 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope, if (symtab_index) _dl_dprintf(2, "symbol '%s': ", strtab + symtab[symtab_index].st_name); - if (res <0) + if (unlikely(res <0)) { int reloc_type = ELF32_R_TYPE(rpnt->r_info); #if defined (__SUPPORT_LD_DEBUG__) @@ -233,7 +233,7 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope, #endif _dl_exit(-res); } - else if (res >0) + if (unlikely(res >0)) { _dl_dprintf(2, "can't resolve symbol\n"); goof += res; @@ -321,7 +321,7 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope, newvalue = fix_bad_pc24(reloc_addr, symbol_addr) - (unsigned long)reloc_addr + (addend << 2); topbits = newvalue & 0xfe000000; - if (topbits != 0xfe000000 && topbits != 0x00000000) + if (unlikely(topbits != 0xfe000000 && topbits != 0x00000000)) { _dl_dprintf(2,"symbol '%s': R_ARM_PC24 relocation out of range.", symtab[symtab_index].st_name); diff --git a/ldso/ldso/cris/elfinterp.c b/ldso/ldso/cris/elfinterp.c index 3e1b554e5..2fed69e74 100644 --- a/ldso/ldso/cris/elfinterp.c +++ b/ldso/ldso/cris/elfinterp.c @@ -131,7 +131,7 @@ _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry) strtab = (char *)(tpnt->dynamic_info[DT_STRTAB] + tpnt->loadaddr); symname = strtab + symtab[symtab_index].st_name; - if (reloc_type != R_CRIS_JUMP_SLOT) { + if (unlikely(reloc_type != R_CRIS_JUMP_SLOT)) { _dl_dprintf(2, "%s: Incorrect relocation type for jump relocations.\n", _dl_progname); _dl_exit(1); @@ -143,7 +143,7 @@ _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry) /* Fetch the address of the GOT entry. */ new_addr = _dl_find_hash(symname, tpnt->symbol_scope, ELF_RTYPE_CLASS_PLT); - if (!new_addr) { + if (unlikely(!new_addr)) { _dl_dprintf(2, "%s: Can't resolv symbol '%s'\n", _dl_progname, symname); _dl_exit(1); } @@ -210,7 +210,7 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope, unsigned long rel_add if (symtab_index) _dl_dprintf(2, "symbol '%s': ", strtab + symtab[symtab_index].st_name); - if (res < 0) { + if (unlikely(res < 0)) { int reloc_type = ELF32_R_TYPE(rpnt->r_info); #if defined (__SUPPORT_LD_DEBUG__) @@ -220,7 +220,7 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope, unsigned long rel_add #endif _dl_exit(-res); } - else if (res > 0) { + if (unlikely(res > 0)) { _dl_dprintf(2, "can't resolv symbol\n"); return res; } diff --git a/ldso/ldso/i386/elfinterp.c b/ldso/ldso/i386/elfinterp.c index 362df3c96..a80dcad54 100644 --- a/ldso/ldso/i386/elfinterp.c +++ b/ldso/ldso/i386/elfinterp.c @@ -217,7 +217,7 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope, if (symtab_index) _dl_dprintf(2, "symbol '%s': ", strtab + symtab[symtab_index].st_name); - if (res <0) + if (unlikely(res <0)) { int reloc_type = ELF32_R_TYPE(rpnt->r_info); #if defined (__SUPPORT_LD_DEBUG__) @@ -227,7 +227,7 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope, #endif _dl_exit(-res); } - else if (res >0) + if (unlikely(res >0)) { _dl_dprintf(2, "can't resolve symbol\n"); return res; diff --git a/ldso/ldso/m68k/elfinterp.c b/ldso/ldso/m68k/elfinterp.c index a03352976..a3f529402 100644 --- a/ldso/ldso/m68k/elfinterp.c +++ b/ldso/ldso/m68k/elfinterp.c @@ -79,7 +79,7 @@ unsigned int _dl_linux_resolver (int dummy1, int dummy2, strtab = (char *) (tpnt->dynamic_info[DT_STRTAB] + tpnt->loadaddr); - if (reloc_type != R_68K_JMP_SLOT) + if (unlikely(reloc_type != R_68K_JMP_SLOT)) { _dl_dprintf (2, "%s: incorrect relocation type in jump relocations\n", _dl_progname); @@ -99,7 +99,7 @@ unsigned int _dl_linux_resolver (int dummy1, int dummy2, /* Get the address of the GOT entry. */ new_addr = _dl_find_hash (strtab + symtab[symtab_index].st_name, tpnt->symbol_scope, ELF_RTYPE_CLASS_PLT); - if (!new_addr) + if (unlikely(!new_addr)) { _dl_dprintf (2, "%s: can't resolve symbol '%s'\n", _dl_progname, strtab + symtab[symtab_index].st_name); diff --git a/ldso/ldso/mips/elfinterp.c b/ldso/ldso/mips/elfinterp.c index 5d3355b88..97923caa3 100644 --- a/ldso/ldso/mips/elfinterp.c +++ b/ldso/ldso/mips/elfinterp.c @@ -130,7 +130,7 @@ unsigned long _dl_linux_resolver(unsigned long sym_index, new_addr = (unsigned long) _dl_find_hash(symname, tpnt->symbol_scope, ELF_RTYPE_CLASS_PLT); - if (!new_addr) { + if (unlikely(!new_addr)) { _dl_dprintf (2, "%s: can't resolve symbol '%s'\n", _dl_progname, symname); _dl_exit (1); diff --git a/ldso/ldso/powerpc/elfinterp.c b/ldso/ldso/powerpc/elfinterp.c index fec92e6fc..13a8be9ba 100644 --- a/ldso/ldso/powerpc/elfinterp.c +++ b/ldso/ldso/powerpc/elfinterp.c @@ -194,7 +194,7 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry) debug_sym(symtab,strtab,symtab_index); debug_reloc(symtab,strtab,this_reloc); - if (ELF32_R_TYPE(this_reloc->r_info) != R_PPC_JMP_SLOT) { + if (unlikely(ELF32_R_TYPE(this_reloc->r_info) != R_PPC_JMP_SLOT)) { _dl_dprintf(2, "%s: Incorrect relocation type in jump relocation\n", _dl_progname); _dl_exit(1); }; @@ -211,7 +211,7 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry) /* Get the address of the GOT entry */ finaladdr = (Elf32_Addr) _dl_find_hash(symname, tpnt->symbol_scope, ELF_RTYPE_CLASS_PLT); - if (!finaladdr) { + if (unlikely(!finaladdr)) { _dl_dprintf(2, "%s: can't resolve symbol '%s'\n", _dl_progname, symname); _dl_exit(1); }; @@ -351,7 +351,7 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope, case R_PPC_REL24: { Elf32_Sword delta = finaladdr - (Elf32_Word)reloc_addr; - if(delta<<6>>6 != delta){ + if(unlikely(delta<<6>>6 != delta)) { _dl_dprintf(2, "%s: symbol '%s' R_PPC_REL24 is out of range.\n\t" "Compile shared libraries with -fPIC!\n", _dl_progname, symname); @@ -472,7 +472,7 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope, if (symtab_index) _dl_dprintf(2, "symbol '%s': ", strtab + symtab[symtab_index].st_name); - if (res <0) + if (unlikely(res <0)) { int reloc_type = ELF32_R_TYPE(rpnt->r_info); #if defined (__SUPPORT_LD_DEBUG__) @@ -482,7 +482,7 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope, #endif _dl_exit(-res); } - else if (res >0) + if (unlikely(res >0)) { _dl_dprintf(2, "can't resolve symbol\n"); return res; diff --git a/ldso/ldso/sh/elfinterp.c b/ldso/ldso/sh/elfinterp.c index e0032601c..fe920bb9a 100644 --- a/ldso/ldso/sh/elfinterp.c +++ b/ldso/ldso/sh/elfinterp.c @@ -136,7 +136,7 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry) strtab = (char *) (tpnt->dynamic_info[DT_STRTAB] + tpnt->loadaddr); symname = strtab + symtab[symtab_index].st_name; - if (reloc_type != R_SH_JMP_SLOT) { + if (unlikely(reloc_type != R_SH_JMP_SLOT)) { _dl_dprintf(2, "%s: Incorrect relocation type in jump relocations\n", _dl_progname); _dl_exit(1); @@ -150,7 +150,7 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry) /* Get the address of the GOT entry */ new_addr = _dl_find_hash(symname, tpnt->symbol_scope, ELF_RTYPE_CLASS_PLT); - if (!new_addr) { + if (unlikely(!new_addr)) { _dl_dprintf(2, "%s: can't resolve symbol '%s'\n", _dl_progname, symname); _dl_exit(1); } @@ -222,7 +222,7 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope, if (symtab_index) _dl_dprintf(2, "symbol '%s': ", strtab + symtab[symtab_index].st_name); - if (res <0) + if (unlikely(res <0)) { int reloc_type = ELF32_R_TYPE(rpnt->r_info); #if defined (__SUPPORT_LD_DEBUG__) @@ -232,7 +232,7 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope, #endif _dl_exit(-res); } - else if (res >0) + if (unlikely(res >0)) { _dl_dprintf(2, "can't resolve symbol\n"); return res; diff --git a/ldso/ldso/sh64/elfinterp.c b/ldso/ldso/sh64/elfinterp.c index d4f45d52f..3a2b4172c 100644 --- a/ldso/ldso/sh64/elfinterp.c +++ b/ldso/ldso/sh64/elfinterp.c @@ -177,7 +177,7 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry) strtab = (char *)(tpnt->dynamic_info[DT_STRTAB] + tpnt->loadaddr); symname = strtab + symtab[symtab_index].st_name; - if (reloc_type != R_SH_JMP_SLOT) { + if (unlikely(reloc_type != R_SH_JMP_SLOT)) { _dl_dprintf(2, "%s: Incorrect relocation type in jump reloc\n", _dl_progname); _dl_exit(1); @@ -191,7 +191,7 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry) /* Get the address of the GOT entry */ new_addr = _dl_find_hash(symname, tpnt->symbol_scope, ELF_RTYPE_CLASS_PLT); - if (!new_addr) { + if (unlikely(!new_addr)) { _dl_dprintf(2, "%s: can't resolve symbol '%s'\n", _dl_progname, symname); _dl_exit(1); @@ -268,7 +268,7 @@ static int _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope, _dl_dprintf(2, "symbol '%s': ", strtab + symtab[symtab_index].st_name); - if (res < 0) { + if (unlikely(res < 0)) { int reloc_type = ELF32_R_TYPE(rpnt->r_info); _dl_dprintf(2, "can't handle reloc type " @@ -280,7 +280,8 @@ static int _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope, ); _dl_exit(-res); - } else if (res > 0) { + } + if (unlikely(res > 0)) { _dl_dprintf(2, "can't resolve symbol\n"); return res; diff --git a/ldso/ldso/sparc/elfinterp.c b/ldso/ldso/sparc/elfinterp.c index ada72bfe5..41bde4fa8 100644 --- a/ldso/ldso/sparc/elfinterp.c +++ b/ldso/ldso/sparc/elfinterp.c @@ -88,7 +88,7 @@ unsigned int _dl_linux_resolver(unsigned int reloc_entry, unsigned int * plt) _dl_dprintf(2, "strtab = %x\n", strtab); - if (reloc_type != R_SPARC_JMP_SLOT) { + if (unlikely(reloc_type != R_SPARC_JMP_SLOT)) { _dl_dprintf(2, "%s: incorrect relocation type in jump relocations (%d)\n", _dl_progname, reloc_type); _dl_exit(30); @@ -110,7 +110,7 @@ unsigned int _dl_linux_resolver(unsigned int reloc_entry, unsigned int * plt) /* Get the address of the GOT entry */ new_addr = _dl_find_hash(strtab + symtab[symtab_index].st_name, tpnt->symbol_scope, ELF_RTYPE_CLASS_PLT); - if(!new_addr) { + if(unlikely(!new_addr)) { _dl_dprintf(2, "%s: can't resolve symbol '%s'\n", _dl_progname, strtab + symtab[symtab_index].st_name); _dl_exit(31); @@ -225,7 +225,7 @@ int _dl_parse_relocation_information(struct dyn_elf *rpnt, symbol_addr = (unsigned int) _dl_find_hash(strtab + symtab[symtab_index].st_name, - tpnt->symbol_scope, elf_machine_type_class(reloc_type); + tpnt->symbol_scope, elf_machine_type_class(reloc_type)); if(!symbol_addr && ELF32_ST_BIND(symtab [symtab_index].st_info) == STB_GLOBAL) { |