Skip to content

Commit d5e4cf8

Browse files
author
Michael Skvortsov
committed
Optimize function return
1 parent bd9790e commit d5e4cf8

File tree

6 files changed

+8
-14
lines changed

6 files changed

+8
-14
lines changed

llvm/lib/Target/TVM/TVMAsmPrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ void TVMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
117117
case TVM::FROM_BUILDER_COPY_S:
118118
case TVM::FROM_CELL_COPY_S:
119119
break;
120-
case TVM::FALLTHROUGH_RETURN:
120+
case TVM::RETURN_N_S:
121121
if (isVerbose()) {
122-
OutStreamer->AddComment("fallthrough return");
122+
OutStreamer->AddComment("implicit return");
123123
OutStreamer->AddBlankLine();
124124
}
125125
break;

llvm/lib/Target/TVM/TVMControlFlowInstrInfo.td

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,8 @@
1919
//===----------------------------------------------------------------------===//
2020

2121
let isTerminator = 1, hasCtrlDep = 1 in {
22-
let isReturn = 1, isBarrier = 1 in {
23-
defm RETURN_N : NRI<(outs), (ins variable_ops), [(TVMreturn)],
24-
"RET", 0xdb30>;
25-
let isCodeGenOnly = 1 in
26-
defm FALLTHROUGH_RETURN : SI<(ins)>;
27-
} // isReturn = 1, isBarrier = 1
22+
let isReturn = 1, isBarrier = 1 in
23+
defm RETURN_N : NRI<(outs), (ins variable_ops), [(TVMreturn)]>;
2824

2925
let isBranch = 1 in {
3026
// The condition operand is a boolean value which TVM represents as i257.

llvm/test/CodeGen/TVM/cfg.ll

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ entry:
1111
; CHECK-NEXT: }
1212
; CHECK-NEXT: PUSHCONT {
1313
; CHECK-NEXT: PUSHINT 42
14-
; CHECK-NEXT: RET
1514
; CHECK-NEXT: }
1615
; CHECK-NEXT: PUSHCONT {
1716
; CHECK-NEXT: PUSHINT 77
18-
; CHECK-NEXT: RET
1917
; CHECK-NEXT: }
2018
; CHECK-NEXT: BLKSWAP 1, 3
2119
; CHECK-NEXT: PUSH s3
@@ -51,7 +49,6 @@ entry:
5149
; CHECK-NEXT: JMPX
5250
; CHECK-NEXT: }
5351
; CHECK-NEXT: PUSHCONT {
54-
; CHECK-NEXT: RET
5552
; CHECK-NEXT: }
5653
; CHECK-NEXT: BLKSWAP 1, 4
5754
; CHECK-NEXT: PUSH s4
@@ -108,7 +105,6 @@ entry:
108105
; CHECK-NEXT: JMPX
109106
; CHECK-NEXT: }
110107
; CHECK-NEXT: PUSHCONT {
111-
; CHECK-NEXT: RET
112108
; CHECK-NEXT: }
113109
; CHECK-NEXT: BLKSWAP 2, 4
114110
; CHECK-NEXT: PUSH s5

llvm/test/CodeGen/TVM/loops.ll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ target triple = "tvm"
3939
; CHECK-NEXT: PUSHCONT {
4040
; CHECK-NEXT: XCHG s0, s2
4141
; CHECK-NEXT: BLKDROP 2
42-
; CHECK-NEXT: RET
4342
; CHECK-NEXT: }
4443
; CHECK-NEXT: BLKSWAP 1, 4
4544
; CHECK-NEXT: PUSH s4
@@ -101,7 +100,6 @@ for.body:
101100
; CHECK-NEXT: PUSHCONT {
102101
; CHECK-NEXT: XCHG s0, s2
103102
; CHECK-NEXT: BLKDROP 2
104-
; CHECK-NEXT: RET
105103
; CHECK-NEXT: }
106104
; CHECK-NEXT: BLKSWAP 1, 4
107105
; CHECK-NEXT: PUSH s4

llvm/tools/tvm-build/tvm-build++.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ def get_path(opt, optname, varname, default):
143143
else:
144144
opt_flags = ['-O3']
145145

146+
opt_flags += ['-simplifycfg-dup-ret=1']
147+
146148
_, bitcode_opt = tempfile.mkstemp()
147149
execute([os.path.join(tvm_llvm_bin, 'opt')] + opt_flags + [bitcode_int, '-o',
148150
bitcode_opt], args.verbose)

llvm/tools/tvm-build/tvm-build.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ def get_path(opt, optname, varname, default):
152152
else:
153153
opt_flags = ['-O3']
154154

155+
opt_flags += ['-simplifycfg-dup-ret=1']
156+
155157
_, bitcode_opt = tempfile.mkstemp()
156158
execute([os.path.join(tvm_llvm_bin, 'opt')] + opt_flags + [bitcode_int, '-o',
157159
bitcode_opt], args.verbose)

0 commit comments

Comments
 (0)