[AArch64][Windows] Check sret attribute also for inreg attribute
authorchenglin.bi <chenglin.bi@cixcomputing.com>
Wed, 12 Oct 2022 01:57:35 +0000 (09:57 +0800)
committerchenglin.bi <chenglin.bi@cixcomputing.com>
Wed, 12 Oct 2022 01:58:50 +0000 (09:58 +0800)
Fix the issue: #57684

Reviewed By: efriedma

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

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/test/CodeGen/AArch64/arm64-windows-calls.ll

index b3db12e..e9a181a 100644 (file)
@@ -6313,7 +6313,7 @@ SDValue AArch64TargetLowering::LowerFormalArguments(
   // epilogue.
   if (IsWin64) {
     for (unsigned I = 0, E = Ins.size(); I != E; ++I) {
-      if (Ins[I].Flags.isInReg()) {
+      if (Ins[I].Flags.isInReg() && Ins[I].Flags.isSRet()) {
         assert(!FuncInfo->getSRetReturnReg());
 
         MVT PtrTy = getPointerTy(DAG.getDataLayout());
index 0162633..e12e2c9 100644 (file)
@@ -176,3 +176,15 @@ define void @call_copy_notpod() {
   ; CHECK: bl copy_notpod
   ; CHECK-NEXT: stp x0, x1, [{{.*}}]
 }
+
+; We shouldn't return the argument
+; when it has only inreg attribute
+define i64 @foobar(i64* inreg %0) {
+; CHECK-LABEL: foobar:
+; CHECK:       // %bb.0: // %entry
+; CHECK-NEXT:    ldr x0, [x0]
+; CHECK-NEXT:    ret
+entry:
+  %1 = load i64, i64* %0
+  ret i64 %1
+}