[PATCH] D134441: [ObjC][ARC] Don't use operand bundle "clang.arc.attachedcall" in codegen for Windows
Stefan Gränitz via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 26 05:23:34 PDT 2022
sgraenitz updated this revision to Diff 462871.
sgraenitz added a comment.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
Follow Reid's advice from https://github.com/llvm/llvm-project/issues/56952#issuecomment-1255552565
and fix the instruction sequence expanded from CALL_RVMARKER on Windows (use RCX as target
register and not RDI). This way we stay as close as possible to Apple's ABI and GNUstep has the
option to implement detection of optimized callers for autorelease optimizations in the future.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134441/new/
https://reviews.llvm.org/D134441
Files:
llvm/lib/Target/X86/X86ExpandPseudo.cpp
llvm/test/CodeGen/X86/call-rv-marker.ll
Index: llvm/test/CodeGen/X86/call-rv-marker.ll
===================================================================
--- llvm/test/CodeGen/X86/call-rv-marker.ll
+++ llvm/test/CodeGen/X86/call-rv-marker.ll
@@ -1,4 +1,5 @@
; RUN: llc -mtriple=x86_64-apple-macosx -verify-machineinstrs -o - %s | FileCheck --check-prefix=CHECK %s
+; RUN: llc -mtriple=x86_64-windows-msvc -verify-machineinstrs -o - %s | FileCheck --check-prefix=WINABI %s
; TODO: support marker generation with GlobalISel
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
@@ -33,6 +34,12 @@
; CHECK-NEXT: popq %rcx
; CHECK-NEXT: retq
;
+; WINABI-LABEL: rv_marker_1_retain:
+; WINABI: callq foo1
+; WINABI-NEXT: movq %rax, %rcx
+; WINABI-NEXT: callq objc_retainAutoreleasedReturnValue
+; WINABI-NEXT: nop
+;
entry:
%call = call ptr @foo1() [ "clang.arc.attachedcall"(ptr @objc_retainAutoreleasedReturnValue) ]
ret ptr %call
Index: llvm/lib/Target/X86/X86ExpandPseudo.cpp
===================================================================
--- llvm/lib/Target/X86/X86ExpandPseudo.cpp
+++ llvm/lib/Target/X86/X86ExpandPseudo.cpp
@@ -224,9 +224,11 @@
// Emit marker "movq %rax, %rdi". %rdi is not callee-saved, so it cannot be
// live across the earlier call. The call to the ObjC runtime function returns
// the first argument, so the value of %rax is unchanged after the ObjC
- // runtime call.
+ // runtime call. On Windows targets, the runtime call follows the regular
+ // x64 calling convention and expects the first argument in %rcx.
+ auto TargetReg = STI->getTargetTriple().isOSWindows() ? X86::RCX : X86::RDI;
auto *Marker = BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(X86::MOV64rr))
- .addReg(X86::RDI, RegState::Define)
+ .addReg(TargetReg, RegState::Define)
.addReg(X86::RAX)
.getInstr();
if (MI.shouldUpdateCallSiteInfo())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134441.462871.patch
Type: text/x-patch
Size: 1968 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220926/832adcc2/attachment.bin>
More information about the cfe-commits
mailing list