[llvm] r375386 - [BPF] fix indirect call assembly code

Yonghong Song via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 20 20:22:04 PDT 2019


Author: yhs
Date: Sun Oct 20 20:22:03 2019
New Revision: 375386

URL: http://llvm.org/viewvc/llvm-project?rev=375386&view=rev
Log:
[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

Added:
    llvm/trunk/test/CodeGen/BPF/callx.ll
Modified:
    llvm/trunk/lib/Target/BPF/BPFInstrInfo.td

Modified: llvm/trunk/lib/Target/BPF/BPFInstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/BPF/BPFInstrInfo.td?rev=375386&r1=375385&r2=375386&view=diff
==============================================================================
--- llvm/trunk/lib/Target/BPF/BPFInstrInfo.td (original)
+++ llvm/trunk/lib/Target/BPF/BPFInstrInfo.td Sun Oct 20 20:22:03 2019
@@ -473,7 +473,7 @@ class CALL<string OpcodeStr>
 class CALLX<string OpcodeStr>
     : TYPE_ALU_JMP<BPF_CALL.Value, BPF_X.Value,
                    (outs),
-                   (ins calltarget:$BrDst),
+                   (ins GPR:$BrDst),
                    !strconcat(OpcodeStr, " $BrDst"),
                    []> {
   bits<32> BrDst;

Added: llvm/trunk/test/CodeGen/BPF/callx.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/BPF/callx.ll?rev=375386&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/BPF/callx.ll (added)
+++ llvm/trunk/test/CodeGen/BPF/callx.ll Sun Oct 20 20:22:03 2019
@@ -0,0 +1,20 @@
+; RUN: llc < %s -march=bpfel | FileCheck %s
+; source:
+;   int test(int (*f)(void)) { return f(); }
+
+; Function Attrs: nounwind
+define dso_local i32 @test(i32 ()* nocapture %f) local_unnamed_addr #0 {
+entry:
+  %call = tail call i32 %f() #1
+; CHECK: callx r{{[0-9]+}}
+  ret i32 %call
+}
+
+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" }
+attributes #1 = { nounwind }
+
+!llvm.module.flags = !{!0}
+!llvm.ident = !{!1}
+
+!0 = !{i32 1, !"wchar_size", i32 4}
+!1 = !{!"clang version 10.0.0 (https://github.com/llvm/llvm-project.git 7015a5c54b53d8d2297a3aa38bc32aab167bdcfc)"}




More information about the llvm-commits mailing list