195 lines · plain
1; RUN: llc -mtriple=mips-linux-gnu -relocation-model=pic -mips-tail-calls=1 \2; RUN: -O2 < %s | \3; RUN: FileCheck %s -check-prefixes=ALL,JALR-ALL,JALR-32,JALR-32R2,TAILCALL-32R24 5; RUN: llc -mtriple=mips64-linux-gnu -relocation-model=pic -mips-tail-calls=1 \6; RUN: -O2 < %s | \7; RUN: FileCheck %s -check-prefixes=ALL,JALR-ALL,JALR-64,JALR-64R2,TAILCALL-64R28 9; RUN: llc -mtriple=mips-linux-gnu -relocation-model=pic -mips-tail-calls=1 \10; RUN: -O2 -mcpu=mips32r6 -mips-compact-branches=always < %s | \11; RUN: FileCheck %s -check-prefixes=ALL,JALR-ALL,JALR-32,JALR-32R6,TAILCALL-32R612 13; RUN: llc -mtriple=mips64-linux-gnu -relocation-model=pic -mips-tail-calls=1 \14; RUN: -O2 -mcpu=mips64r6 -mips-compact-branches=always < %s | \15; RUN: FileCheck %s -check-prefixes=ALL,JALR-ALL,JALR-64,JALR-64R6,TAILCALL-64R616 17; RUN: llc -mtriple=mips-linux-gnu -relocation-model=pic -mips-tail-calls=1 \18; RUN: -O2 -mcpu=mips32r6 -mips-compact-branches=never < %s | \19; RUN: FileCheck %s -check-prefixes=ALL,JALR-ALL,JALR-32,JALR-32R2,TAILCALL-32R220 21; RUN: llc -mtriple=mips64-linux-gnu -relocation-model=pic -mips-tail-calls=1 \22; RUN: -O2 -mcpu=mips64r6 -mips-compact-branches=never < %s | \23; RUN: FileCheck %s -check-prefixes=ALL,JALR-ALL,JALR-64,JALR-64R2,TAILCALL-64R224 25; RUN: llc -mtriple=mips-linux-gnu -relocation-model=pic -mips-tail-calls=1 \26; RUN: -O2 -mattr=+micromips -mcpu=mips32r2 < %s | \27; RUN: FileCheck %s -check-prefixes=ALL,JALR-ALL,JALR-MM,TAILCALL-MM28 29; RUN: llc -mtriple=mips-linux-gnu -relocation-model=pic -mips-tail-calls=1 \30; RUN: -O2 -mattr=+micromips -mcpu=mips32r6 < %s | \31; RUN: FileCheck %s -check-prefixes=ALL,JALR-ALL,JALR-MM,TAILCALL-MM32 33; RUN: llc -mtriple=mips-linux-gnu -relocation-model=pic \34; RUN: -O0 < %s | FileCheck %s -check-prefixes=ALL,JALR-ALL,JALR-32,JALR-32R2,PIC-NOTAILCALL-R235 36; RUN: llc -mtriple=mips64-linux-gnu -relocation-model=pic \37; RUN: -O0 < %s | FileCheck %s -check-prefixes=ALL,JALR-ALL,JALR-64,JALR-64R2,PIC-NOTAILCALL-R238 39; RUN: llc -mtriple=mips-linux-gnu -relocation-model=pic \40; RUN: -O0 -mcpu=mips32r6 -mips-compact-branches=always < %s | \41; RUN: FileCheck %s -check-prefixes=ALL,JALR-ALL,JALR-32,JALR-32R6,PIC-NOTAILCALL-R642 43; RUN: llc -mtriple=mips64-linux-gnu -relocation-model=pic \44; RUN: -O0 -mcpu=mips64r6 -mips-compact-branches=always < %s | \45; RUN: FileCheck %s -check-prefixes=ALL,JALR-ALL,JALR-64,JALR-64R6,PIC-NOTAILCALL-R646 47; RUN: llc -mtriple=mips-linux-gnu -relocation-model=pic \48; RUN: -O0 -mcpu=mips32r6 -mips-compact-branches=never < %s | \49; RUN: FileCheck %s -check-prefixes=ALL,JALR-ALL,JALR-32,JALR-32R2,PIC-NOTAILCALL-R250 51; RUN: llc -mtriple=mips64-linux-gnu -relocation-model=pic \52; RUN: -O0 -mcpu=mips64r6 -mips-compact-branches=never < %s | \53; RUN: FileCheck %s -check-prefixes=ALL,JALR-ALL,JALR-64,JALR-64R2,PIC-NOTAILCALL-R254 55; RUN: llc -mtriple=mips-linux-gnu -relocation-model=pic \56; RUN: -O0 -mattr=+micromips -mcpu=mips32r2 < %s | \57; RUN: FileCheck %s -check-prefixes=ALL,JALR-ALL,JALR-MM,PIC-NOTAILCALL-MM58 59; RUN: llc -mtriple=mips-linux-gnu -relocation-model=pic \60; RUN: -O0 -mattr=+micromips -mcpu=mips32r6 < %s | \61; RUN: FileCheck %s -check-prefixes=ALL,JALR-ALL,JALR-MM,PIC-NOTAILCALL-MM62 63; RUN: llc -mtriple=mips-linux-gnu -relocation-model=pic -mips-tail-calls=1 \64; RUN: -O2 -mips-jalr-reloc=false < %s | \65; RUN: FileCheck %s -check-prefixes=ALL,NORELOC66 67; RUN: llc -mtriple=mips-linux-gnu -relocation-model=static -mips-tail-calls=1 \68; RUN: -O2 < %s | \69; RUN: FileCheck %s -check-prefixes=ALL,NORELOC70 71; RUN: llc -mtriple=mips-linux-gnu -relocation-model=pic -mips-tail-calls=1 \72; RUN: -O0 -mips-jalr-reloc=false < %s | \73; RUN: FileCheck %s -check-prefixes=ALL,NORELOC74 75; RUN: llc -mtriple=mips-linux-gnu -relocation-model=static -mips-tail-calls=1 \76; RUN: -O0 < %s | \77; RUN: FileCheck %s -check-prefixes=ALL,NORELOC78 79; RUN: llc -mtriple=mips64-linux-gnu -relocation-model=pic -mips-tail-calls=1 \80; RUN: -O2 -mips-jalr-reloc=false < %s | \81; RUN: FileCheck %s -check-prefixes=ALL,NORELOC82 83; RUN: llc -mtriple=mips64-linux-gnu -mips-tail-calls=1 \84; RUN: -O2 -relocation-model=static < %s | \85; RUN: FileCheck %s -check-prefixes=ALL,NORELOC86 87; RUN: llc -mtriple=mips64-linux-gnu -relocation-model=pic \88; RUN: -O0 -mips-jalr-reloc=false < %s | \89; RUN: FileCheck %s -check-prefixes=ALL,NORELOC90 91; RUN: llc -mtriple=mips64-linux-gnu -relocation-model=static \92; RUN: -O0 < %s | \93; RUN: FileCheck %s -check-prefixes=ALL,NORELOC94 95define internal void @foo() noinline {96entry:97 ret void98}99 100define void @checkCall() {101entry:102; ALL-LABEL: checkCall:103; ALL-NOT: MIPS_JALR104 call void @foo()105; JALR-32: .reloc [[TMPLABEL:\$.+]], R_MIPS_JALR, foo106; JALR-64: .reloc [[TMPLABEL:\..+]], R_MIPS_JALR, foo107; JALR-MM: .reloc [[TMPLABEL:\$.+]], R_MICROMIPS_JALR, foo108; NORELOC-NOT: .reloc109; JALR-ALL-NEXT: [[TMPLABEL]]:110; JALR-32R2-NEXT: jalr $25111; JALR-64R2-NEXT: jalr $25112; JALR-32R6-NEXT: jalrc $25113; JALR-64R6-NEXT: jalrc $25114; JALR-MM-NEXT: jalr $25115; ALL-NOT: MIPS_JALR116 ret void117}118 119define void @checkTailCall() {120entry:121; ALL-LABEL: checkTailCall:122; ALL-NOT: MIPS_JALR123 tail call void @foo()124; JALR-32: .reloc [[TMPLABEL:\$.+]], R_MIPS_JALR, foo125; JALR-64: .reloc [[TMPLABEL:\..+]], R_MIPS_JALR, foo126; JALR-MM: .reloc [[TMPLABEL:\$.+]], R_MICROMIPS_JALR, foo127; JALR-ALL-NEXT: [[TMPLABEL]]:128; NORELOC-NOT: .reloc129; TAILCALL-32R2-NEXT: jr $25130; TAILCALL-64R2-NEXT: jr $25131; TAILCALL-MM-NEXT: jrc $25132; TAILCALL-32R6-NEXT: jrc $25133; TAILCALL-64R6-NEXT: jrc $25134; PIC-NOTAILCALL-R2-NEXT: jalr $25135; PIC-NOTAILCALL-R6-NEXT: jalrc $25136; PIC-NOTAILCALL-MM-NEXT: jalr $25137; ALL-NOT: MIPS_JALR138 ret void139}140 141; Check that we don't emit R_MIPS_JALR relocations against function pointers.142; This resulted in run-time crashes until lld was modified to ignore143; R_MIPS_JALR relocations against data symbols (commit 5bab291b7b).144; However, the better approach is to not emit these relocations in the first145; place so check that we no longer emit them.146; Previously we were adding them for local dynamic TLS function pointers and147; function pointers with internal linkage.148 149@fnptr_internal = internal global ptr @checkFunctionPointerCall150@fnptr_internal_const = internal constant ptr @checkFunctionPointerCall151@fnptr_const = constant ptr @checkFunctionPointerCall152@fnptr_global = global ptr @checkFunctionPointerCall153 154define void @checkFunctionPointerCall() {155entry:156; ALL-LABEL: checkFunctionPointerCall:157; ALL-NOT: MIPS_JALR158 %func_internal = load ptr, ptr @fnptr_internal159 call void %func_internal()160 %func_internal_const = load ptr, ptr @fnptr_internal_const161 call void %func_internal_const()162 %func_const = load ptr, ptr @fnptr_const163 call void %func_const()164 %func_global = load ptr, ptr @fnptr_global165 call void %func_global()166 ret void167}168 169@tls_fnptr_gd = thread_local global ptr @checkTlsFunctionPointerCall170@tls_fnptr_ld = thread_local(localdynamic) global ptr @checkTlsFunctionPointerCall171@tls_fnptr_ie = thread_local(initialexec) global ptr @checkTlsFunctionPointerCall172@tls_fnptr_le = thread_local(localexec) global ptr @checkTlsFunctionPointerCall173 174define void @checkTlsFunctionPointerCall() {175entry:176; There should not be any *JALR relocations in this function other than the177; calls to __tls_get_addr:178; ALL-LABEL: checkTlsFunctionPointerCall:179; ALL-NOT: MIPS_JALR180; JALR-ALL: .reloc {{.+}}MIPS_JALR, __tls_get_addr181; ALL-NOT: MIPS_JALR182; JALR-ALL: .reloc {{.+}}MIPS_JALR, __tls_get_addr183; NORELOC-NOT: .reloc184; ALL-NOT: _MIPS_JALR185 %func_gd = load ptr, ptr @tls_fnptr_gd186 call void %func_gd()187 %func_ld = load ptr, ptr @tls_fnptr_ld188 call void %func_ld()189 %func_ie = load ptr, ptr @tls_fnptr_ie190 call void %func_ie()191 %func_le = load ptr, ptr @tls_fnptr_le192 call void %func_le()193 ret void194}195