Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-9434] Calling CATransform3DTranslate generates 40 more bytes of TEXT in Swift than ObjC #51898

Open
aroben opened this issue Dec 7, 2018 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. code size compiler The Swift compiler in itself

Comments

@aroben
Copy link

aroben commented Dec 7, 2018

Previous ID SR-9434
Radar rdar://problem/46496976
Original Reporter @aroben
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CodeSize
Assignee None
Priority Medium

md5: 53a78697fff2e21f77b952fc2c262bbc

Issue Description:

Calling CATransform3DTranslate generates 40 more bytes of TEXT in Swift than ObjC.

$ cat test.swift
import QuartzCore

@inline(never)
func blackHole<T>(_ x: T) {
}

let a = CATransform3DMakeRotation(0, 0, 0, 0)
let b = CATransform3DTranslate(a, 0, 0, 0)
let c = CATransform3DTranslate(b, 0, 0, 0)
blackHole(c)

$ cat test.m
#import <QuartzCore/QuartzCore.h>

int main(int argc, const char *argv[]) {
  CATransform3D a = CATransform3DMakeRotation(0, 0, 0, 0);
  CATransform3D b = CATransform3DTranslate(a, 0, 0, 0);
  CATransform3D c = CATransform3DTranslate(b, 0, 0, 0);
  printf("%p\n", &c);
  return 0;
}

$ swiftc -Osize -whole-module-optimization -module-name test -o test test.swift
$ clang -framework QuartzCore -Os -o testobjc test.m

Here’s the generated code for the second CATransform3DTranslate call in each.

ObjC (88 bytes):

0000000100007ed4    ldr q0, [sp, #&#8203;0x1c0]
0000000100007ed8    str q0, [sp, #&#8203;0x40]
0000000100007edc    ldr q0, [sp, #&#8203;0x1b0]
0000000100007ee0    str q0, [sp, #&#8203;0x30]
0000000100007ee4    ldr q0, [sp, #&#8203;0x1a0]
0000000100007ee8    str q0, [sp, #&#8203;0x20]
0000000100007eec    ldr q0, [sp, #&#8203;0x190]
0000000100007ef0    str q0, [sp, #&#8203;0x10]
0000000100007ef4    ldr q0, [sp, #&#8203;0x200]
0000000100007ef8    str q0, [sp, #&#8203;0x80]
0000000100007efc    ldr q0, [sp, #&#8203;0x1f0]
0000000100007f00    str q0, [sp, #&#8203;0x70]
0000000100007f04    ldr q0, [sp, #&#8203;0x1e0]
0000000100007f08    str q0, [sp, #&#8203;0x60]
0000000100007f0c    ldr q0, [sp, #&#8203;0x1d0]
0000000100007f10    str q0, [sp, #&#8203;0x50]
0000000100007f14    add x19, sp, #&#8203;0x90
0000000100007f18    fmov    d0, xzr
0000000100007f1c    fmov    d1, xzr
0000000100007f20    fmov    d2, xzr
0000000100007f24    add x0, sp, #&#8203;0x10
0000000100007f28    add x8, sp, #&#8203;0x90
0000000100007f2c    bl  0x100007f60 ; symbol stub for: _CATransform3DTranslate

Swift (128 bytes):

0000000100007e6c    ldp x9, x8, [sp]
0000000100007e70    ldp x11, x10, [sp, #&#8203;0x10]
0000000100007e74    ldp x13, x12, [sp, #&#8203;0x20]
0000000100007e78    ldp x15, x14, [sp, #&#8203;0x30]
0000000100007e7c    ldp x17, x16, [sp, #&#8203;0x40]
0000000100007e80    ldp x1, x0, [sp, #&#8203;0x50]
0000000100007e84    ldp x3, x2, [sp, #&#8203;0x60]
0000000100007e88    ldp x5, x4, [sp, #&#8203;0x70]
0000000100007e8c    adr x6, #&#8203;0x264
0000000100007e90    nop
0000000100007e94    stp x9, x8, [x6]
0000000100007e98    stp x11, x10, [x6, #&#8203;0x10]
0000000100007e9c    stp x13, x12, [x6, #&#8203;0x20]
0000000100007ea0    stp x15, x14, [x6, #&#8203;0x30]
0000000100007ea4    stp x17, x16, [x6, #&#8203;0x40]
0000000100007ea8    stp x1, x0, [x6, #&#8203;0x50]
0000000100007eac    stp x3, x2, [x6, #&#8203;0x60]
0000000100007eb0    stp x5, x4, [x6, #&#8203;0x70]
0000000100007eb4    stp x8, x11, [sp, #&#8203;0x88]
0000000100007eb8    str x9, [sp, #&#8203;0x80]
0000000100007ebc    stp x10, x13, [sp, #&#8203;0x98]
0000000100007ec0    stp x12, x15, [sp, #&#8203;0xa8]
0000000100007ec4    stp x14, x17, [sp, #&#8203;0xb8]
0000000100007ec8    stp x16, x1, [sp, #&#8203;0xc8]
0000000100007ecc    stp x0, x3, [sp, #&#8203;0xd8]
0000000100007ed0    stp x2, x5, [sp, #&#8203;0xe8]
0000000100007ed4    str x4, [sp, #&#8203;0xf8]
0000000100007ed8    fmov    d0, xzr
0000000100007edc    fmov    d1, xzr
0000000100007ee0    fmov    d2, xzr
0000000100007ee4    add x0, sp, #&#8203;0x80
0000000100007ee8    mov x8, sp
0000000100007eec    bl  0x100007f58 ; symbol stub for: _CATransform3DTranslate
@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. code size compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

1 participant