Skip to content

Commit ee88119

Browse files
committed
[BPF] fix indirect call assembly code
Currently, for indirect call, the assembly code printed out as callx <imm> This is not right, it should be callx <reg> Fixed the issue with proper format. Differential Revision: https://reviews.llvm.org/D69229 llvm-svn: 375386
1 parent 9d5ad5e commit ee88119

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

llvm/lib/Target/BPF/BPFInstrInfo.td

+1-1
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ class CALL<string OpcodeStr>
473473
class CALLX<string OpcodeStr>
474474
: TYPE_ALU_JMP<BPF_CALL.Value, BPF_X.Value,
475475
(outs),
476-
(ins calltarget:$BrDst),
476+
(ins GPR:$BrDst),
477477
!strconcat(OpcodeStr, " $BrDst"),
478478
[]> {
479479
bits<32> BrDst;

llvm/test/CodeGen/BPF/callx.ll

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
; RUN: llc < %s -march=bpfel | FileCheck %s
2+
; source:
3+
; int test(int (*f)(void)) { return f(); }
4+
5+
; Function Attrs: nounwind
6+
define dso_local i32 @test(i32 ()* nocapture %f) local_unnamed_addr #0 {
7+
entry:
8+
%call = tail call i32 %f() #1
9+
; CHECK: callx r{{[0-9]+}}
10+
ret i32 %call
11+
}
12+
13+
attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
14+
attributes #1 = { nounwind }
15+
16+
!llvm.module.flags = !{!0}
17+
!llvm.ident = !{!1}
18+
19+
!0 = !{i32 1, !"wchar_size", i32 4}
20+
!1 = !{!"clang version 10.0.0 (https://github.com/llvm/llvm-project.git 7015a5c54b53d8d2297a3aa38bc32aab167bdcfc)"}

0 commit comments

Comments
 (0)