Skip to content

Commit 9a77adf

Browse files
committed
Address comments
1 parent ac9497e commit 9a77adf

File tree

7 files changed

+22
-31
lines changed

7 files changed

+22
-31
lines changed

llvm/lib/Target/Mips/Mips16ISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ Mips16TargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI,
248248

249249
bool Mips16TargetLowering::isEligibleForTailCallOptimization(
250250
const CCState &CCInfo, unsigned NextStackOffset,
251-
const MipsFunctionInfo &FI) const {
251+
const MipsFunctionInfo &FI, bool IsMustTail) const {
252252
// No tail call optimization for mips16.
253253
return false;
254254
}

llvm/lib/Target/Mips/Mips16ISelLowering.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ namespace llvm {
3333
private:
3434
bool isEligibleForTailCallOptimization(
3535
const CCState &CCInfo, unsigned NextStackOffset,
36-
const MipsFunctionInfo &FI) const override;
36+
const MipsFunctionInfo &FI,
37+
bool IsMustTail = false) const override;
3738

3839
void setMips16HardFloatLibCalls();
3940

llvm/lib/Target/Mips/MipsISelLowering.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3408,15 +3408,18 @@ MipsTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
34083408
// that are part of this compilation unit.
34093409
bool InternalLinkage = false;
34103410
bool IsMustTail = CLI.CB && CLI.CB->isMustTailCall();
3411-
if (IsTailCall && !IsMustTail) {
3411+
if (IsTailCall) {
34123412
IsTailCall = isEligibleForTailCallOptimization(
3413-
CCInfo, StackSize, *MF.getInfo<MipsFunctionInfo>());
3414-
if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee)) {
3415-
InternalLinkage = G->getGlobal()->hasInternalLinkage();
3416-
IsTailCall &= (InternalLinkage || G->getGlobal()->hasLocalLinkage() ||
3417-
G->getGlobal()->hasPrivateLinkage() ||
3418-
G->getGlobal()->hasHiddenVisibility() ||
3419-
G->getGlobal()->hasProtectedVisibility());
3413+
CCInfo, StackSize, *MF.getInfo<MipsFunctionInfo>(), IsMustTail);
3414+
if (IsTailCall) {
3415+
if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee)) {
3416+
InternalLinkage = G->getGlobal()->hasInternalLinkage();
3417+
IsTailCall &= (InternalLinkage || G->getGlobal()->hasLocalLinkage() ||
3418+
G->getGlobal()->isDSOLocal() ||
3419+
G->getGlobal()->hasPrivateLinkage() ||
3420+
G->getGlobal()->hasHiddenVisibility() ||
3421+
G->getGlobal()->hasProtectedVisibility());
3422+
}
34203423
}
34213424
}
34223425
if (!IsTailCall && IsMustTail)

llvm/lib/Target/Mips/MipsISelLowering.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,8 @@ class TargetRegisterClass;
598598
virtual bool
599599
isEligibleForTailCallOptimization(const CCState &CCInfo,
600600
unsigned NextStackOffset,
601-
const MipsFunctionInfo &FI) const = 0;
601+
const MipsFunctionInfo &FI,
602+
bool IsMustTail = false) const = 0;
602603

603604
/// copyByValArg - Copy argument registers which were used to pass a byval
604605
/// argument to the stack. Create a stack frame object for the byval

llvm/lib/Target/Mips/MipsSEISelLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,8 +1180,8 @@ MipsSETargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI,
11801180

11811181
bool MipsSETargetLowering::isEligibleForTailCallOptimization(
11821182
const CCState &CCInfo, unsigned NextStackOffset,
1183-
const MipsFunctionInfo &FI) const {
1184-
if (!UseMipsTailCalls)
1183+
const MipsFunctionInfo &FI, bool IsMustTail) const {
1184+
if (!UseMipsTailCalls && !IsMustTail)
11851185
return false;
11861186

11871187
// Exception has to be cleared with eret.

llvm/lib/Target/Mips/MipsSEISelLowering.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ class TargetRegisterClass;
6565
private:
6666
bool isEligibleForTailCallOptimization(
6767
const CCState &CCInfo, unsigned NextStackOffset,
68-
const MipsFunctionInfo &FI) const override;
68+
const MipsFunctionInfo &FI,
69+
bool IsMustTail = false) const override;
6970

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

llvm/test/CodeGen/Mips/musttail.ll

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,10 @@
44

55
; Test musttail support for MIPS
66

7-
declare void @external_func()
8-
9-
; Test basic musttail with external function
10-
define void @test_musttail_external() {
11-
; MIPS32-LABEL: test_musttail_external:
12-
; MIPS32: # %bb.0:
13-
; MIPS32-NEXT: j external_func
14-
; MIPS32-NEXT: nop
15-
;
16-
; MIPS64-LABEL: test_musttail_external:
17-
; MIPS64: # %bb.0:
18-
; MIPS64-NEXT: j external_func
19-
; MIPS64-NEXT: nop
20-
musttail call void @external_func()
21-
ret void
7+
define dso_local i32 @callee_args(i32 %a, i32 %b, i32 %c) {
8+
ret i32 %a;
229
}
2310

24-
declare i32 @callee_args(i32 %a, i32 %b, i32 %c)
25-
2611
define i32 @test_musttail_args(i32 %x, i32 %y, i32 %z) {
2712
; MIPS32-LABEL: test_musttail_args:
2813
; MIPS32: # %bb.0:

0 commit comments

Comments
 (0)