llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-arm

Author: None (llvmbot)

<details>
<summary>Changes</summary>

Backport 0921542e3b0557e926af846a414676a6a5d0e43c

Requested by: @<!-- -->statham-arm

---
Full diff: https://github.com/llvm/llvm-project/pull/178197.diff


3 Files Affected:

- (modified) llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp (+5) 
- (modified) llvm/lib/Target/ARM/ARMFrameLowering.cpp (+2) 
- (added) llvm/test/CodeGen/ARM/estimate-size-copy.mir (+37) 


``````````diff
diff --git a/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp 
b/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
index 402a4e30fe3ca..1c8ab6afb9095 100644
--- a/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
@@ -619,6 +619,11 @@ unsigned ARMBaseInstrInfo::getInstSizeInBytes(const 
MachineInstr &MI) const {
     return MCID.getSize();
   case TargetOpcode::BUNDLE:
     return getInstBundleLength(MI);
+  case TargetOpcode::COPY:
+    if (!MF->getInfo<ARMFunctionInfo>()->isThumbFunction())
+      return 4;
+    else
+      return 2;
   case ARM::CONSTPOOL_ENTRY:
   case ARM::JUMPTABLE_INSTS:
   case ARM::JUMPTABLE_ADDRS:
diff --git a/llvm/lib/Target/ARM/ARMFrameLowering.cpp 
b/llvm/lib/Target/ARM/ARMFrameLowering.cpp
index 2fc64894b0d34..a0b975072bd8e 100644
--- a/llvm/lib/Target/ARM/ARMFrameLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMFrameLowering.cpp
@@ -2335,6 +2335,8 @@ static unsigned EstimateFunctionSizeInBytes(const 
MachineFunction &MF,
     for (auto &Table: MF.getJumpTableInfo()->getJumpTables())
       FnSize += Table.MBBs.size() * 4;
   FnSize += MF.getConstantPool()->getConstants().size() * 4;
+  LLVM_DEBUG(dbgs() << "Estimated function size for " << MF.getName() << " = "
+                    << FnSize << " bytes\n");
   return FnSize;
 }
 
diff --git a/llvm/test/CodeGen/ARM/estimate-size-copy.mir 
b/llvm/test/CodeGen/ARM/estimate-size-copy.mir
new file mode 100644
index 0000000000000..154117d1743d1
--- /dev/null
+++ b/llvm/test/CodeGen/ARM/estimate-size-copy.mir
@@ -0,0 +1,37 @@
+# REQUIRES: asserts
+#
+# RUN: llc -mtriple=thumbv6m -start-before=machine-cp -debug -o - %s 2>%t | \
+# RUN:     FileCheck %s --check-prefix=OUTPUT
+# RUN: FileCheck %s --check-prefix=DEBUG < %t
+#
+# DEBUG: Estimated function size for f = 4 bytes
+#
+# OUTPUT:  mov r0, r1
+# OUTPUT:  bx lr
+
+--- |
+  target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
+  target triple = "thumbv6m-unknown-none-eabi"
+
+  define i32 @f(i32 %x, i32 %y) {
+  entry:
+    ret i32 %y
+  }
+ 
+...
+---
+name:            f
+tracksRegLiveness: true
+frameInfo:
+  isFrameAddressTaken: false
+  isReturnAddressTaken: false
+  localFrameSize:  0
+machineFunctionInfo:
+  isLRSpilled:     false
+body:             |
+  bb.0.entry:
+    liveins: $r1
+  
+    renamable $r0 = COPY $r1
+    tBX_RET 14 /* CC::al */, $noreg, implicit $r0
+...

``````````

</details>


https://github.com/llvm/llvm-project/pull/178197
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to