[llvm] 8dbf5a9 - [PowerPC] Remove extra nop after notoc call

Stefan Pintilie via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 5 04:49:16 PDT 2020


Author: Stefan Pintilie
Date: 2020-06-05T06:47:44-05:00
New Revision: 8dbf5a95014f6b52c37ffc50c06cc6a3d13479f6

URL: https://github.com/llvm/llvm-project/commit/8dbf5a95014f6b52c37ffc50c06cc6a3d13479f6
DIFF: https://github.com/llvm/llvm-project/commit/8dbf5a95014f6b52c37ffc50c06cc6a3d13479f6.diff

LOG: [PowerPC] Remove extra nop after notoc call

Calls that are marked as @notoc do not require the extra nop after the call
for the TOC restore.

Differential Revision: https://reviews.llvm.org/D81081

Added: 
    

Modified: 
    llvm/lib/Target/PowerPC/PPCInstr64Bit.td
    llvm/test/CodeGen/PowerPC/pcrel-call-linkage-simple.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/PowerPC/PPCInstr64Bit.td b/llvm/lib/Target/PowerPC/PPCInstr64Bit.td
index 03580d1f4c5e..53fabb484265 100644
--- a/llvm/lib/Target/PowerPC/PPCInstr64Bit.td
+++ b/llvm/lib/Target/PowerPC/PPCInstr64Bit.td
@@ -145,9 +145,9 @@ let isCall = 1, PPC970_Unit = 7, Defs = [LR8] in {
       // it does use R2 then it is just a caller saved register. Therefore it is
       // safe to emit only the bl and not the nop for this instruction. The
       // linker will not try to restore R2 after the call.
-      def BL8_NOTOC : IForm_and_DForm_4_zero<18, 0, 1, 24, (outs),
-                                             (ins calltarget:$func),
-                                             "bl $func", IIC_BrB, []>;
+      def BL8_NOTOC : IForm<18, 0, 1, (outs),
+                            (ins calltarget:$func),
+                            "bl $func", IIC_BrB, []>;
     }
   }
   let Uses = [CTR8, RM] in {

diff  --git a/llvm/test/CodeGen/PowerPC/pcrel-call-linkage-simple.ll b/llvm/test/CodeGen/PowerPC/pcrel-call-linkage-simple.ll
index 957a2d5e48f2..649aecf8f720 100644
--- a/llvm/test/CodeGen/PowerPC/pcrel-call-linkage-simple.ll
+++ b/llvm/test/CodeGen/PowerPC/pcrel-call-linkage-simple.ll
@@ -36,3 +36,27 @@ entry:
 
 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg)
 
+
+; CHECK-S-LABEL: callerNoTail
+; CHECK-S:     bl callee at notoc
+; CHECK-S-NOT: nop
+; CHECK-S:     bl callee at notoc
+; CHECK-S-NOT: nop
+; CHECK-S:     blr
+
+; CHECK-O-LABEL: callerNoTail
+; CHECK-O:      bl
+; CHECK-O-NEXT: R_PPC64_REL24_NOTOC callee
+; CHECK-O-NOT:  nop
+; CHECK-O:      bl
+; CHECK-O-NEXT: R_PPC64_REL24_NOTOC callee
+; CHECK-O-NOT:  nop
+; CHECK-O:      blr
+define dso_local signext i32 @callerNoTail() local_unnamed_addr {
+entry:
+  %call1 = tail call signext i32 bitcast (i32 (...)* @callee to i32 ()*)()
+  %call2 = tail call signext i32 bitcast (i32 (...)* @callee to i32 ()*)()
+  %add = add i32 %call1, %call2
+  ret i32 %add
+}
+


        


More information about the llvm-commits mailing list