Skip to content

Commit eaa5678

Browse files
committed
Clean up and improve tests
1 parent 20d634f commit eaa5678

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

llvm/lib/Target/Mips/MipsISelLowering.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3408,15 +3408,13 @@ MipsTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
34083408
// For non-musttail calls, restrict to functions that won't require $gp
34093409
// restoration. In PIC mode, calling external functions via tail call can
34103410
// cause issues with $gp register handling (see D24763).
3411-
bool InternalLinkage = false;
34123411
bool IsMustTail = CLI.CB && CLI.CB->isMustTailCall();
34133412
if (IsTailCall) {
34143413
IsTailCall = isEligibleForTailCallOptimization(
34153414
CCInfo, StackSize, *MF.getInfo<MipsFunctionInfo>(), IsMustTail);
34163415
// For non-musttail calls, restrict to local or non-interposable functions
34173416
if (IsTailCall && !IsMustTail) {
34183417
if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee)) {
3419-
InternalLinkage = G->getGlobal()->hasInternalLinkage();
34203418
IsTailCall &= (G->getGlobal()->hasLocalLinkage() ||
34213419
G->getGlobal()->hasHiddenVisibility() ||
34223420
G->getGlobal()->hasProtectedVisibility());
@@ -3600,6 +3598,7 @@ MipsTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
36003598
}
36013599
}
36023600

3601+
bool InternalLinkage = false;
36033602
if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee)) {
36043603
if (Subtarget.isTargetCOFF() &&
36053604
G->getGlobal()->hasDLLImportStorageClass()) {

llvm/lib/Target/Mips/MipsSEISelLowering.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,10 @@ class TargetRegisterClass;
6363
const TargetRegisterClass *getRepRegClassFor(MVT VT) const override;
6464

6565
private:
66-
bool isEligibleForTailCallOptimization(
67-
const CCState &CCInfo, unsigned NextStackOffset,
68-
const MipsFunctionInfo &FI, bool IsMustTail) const override;
66+
bool isEligibleForTailCallOptimization(const CCState &CCInfo,
67+
unsigned NextStackOffset,
68+
const MipsFunctionInfo &FI,
69+
bool IsMustTail) const override;
6970

7071
void
7172
getOpndList(SmallVectorImpl<SDValue> &Ops,

llvm/test/CodeGen/Mips/musttail.ll

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,20 @@ define float @test_musttail_mixed_args(i32 %a, float %b, i32 %c, float %d, i32 %
9595
%ret = musttail call float @mixed_args_callee(i32 %a, float %b, i32 %c, float %d, i32 %e, float %f)
9696
ret float %ret
9797
}
98+
99+
; Test musttail with indirect call
100+
define i32 @test_musttail_fptr(ptr %fptr, i32 %x) {
101+
; MIPS32-LABEL: test_musttail_fptr:
102+
; MIPS32: # %bb.0:
103+
; MIPS32-NEXT: move $25, $4
104+
; MIPS32-NEXT: jr $25
105+
; MIPS32-NEXT: nop
106+
;
107+
; MIPS64-LABEL: test_musttail_fptr:
108+
; MIPS64: # %bb.0:
109+
; MIPS64-NEXT: move $25, $4
110+
; MIPS64-NEXT: jr $25
111+
; MIPS64-NEXT: nop
112+
%ret = musttail call i32 %fptr(ptr %fptr, i32 %x)
113+
ret i32 %ret
114+
}

0 commit comments

Comments
 (0)