File: gh3692.d

package info (click to toggle)
ldc 1%3A1.40.0-5
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 63,308 kB
  • sloc: cpp: 85,368; ansic: 21,877; makefile: 1,705; sh: 1,018; asm: 584; objc: 135; exp: 48; python: 12
file content (44 lines) | stat: -rw-r--r-- 1,695 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// https://github.com/ldc-developers/ldc/issues/3692

// REQUIRES: target_X86
// RUN: %ldc -mtriple=x86_64-linux-gnu -output-ll -of=%t.ll %s
// RUN: FileCheck %s < %t.ll


// D `int[3]` rewritten to LL `{ i64, i32 }` for SysV ABI - mismatching size and alignment
// CHECK-LABEL: define void @_D6gh36924takeFG3iZv({ i64, i32 } %a_arg)
void take(int[3] a)
{
    // the `{ i64, i32 }` size is 16 bytes, so we need a padded alloca (with 8-bytes alignment)
    // CHECK-NEXT: = alloca { i64, i32 }, align 8
}

// CHECK-LABEL: define void @_D6gh36924passFZv()
void pass()
{
    // CHECK-NEXT: %arrayliteral = alloca [3 x i32], align 4
    // we need an extra padded alloca with proper alignment
    // CHECK-NEXT: %.BaseBitcastABIRewrite_padded_arg_storage = alloca { i64, i32 }, align 8
    // CHECK:      %.BaseBitcastABIRewrite_arg = load { i64, i32 }, ptr %.BaseBitcastABIRewrite_padded_arg_storage
    take([1, 2, 3]);
}


// D `int[4]` rewritten to LL `{ i64, i64 }` for SysV ABI - mismatching alignment only
// CHECK-LABEL: define void @_D6gh36925take4FG4iZv({ i64, i64 } %a_arg)
void take4(int[4] a)
{
    // the alloca should have 8-bytes alignment, even though a.alignof == 4
    // CHECK-NEXT: %a = alloca [4 x i32], align 8
    // CHECK: store { i64, i64 } %a_arg, ptr %
}

// CHECK-LABEL: define void @_D6gh36925pass4FZv()
void pass4()
{
    // CHECK-NEXT: %arrayliteral = alloca [4 x i32], align 4
    // we need an extra alloca with 8-bytes alignment
    // CHECK-NEXT: %.BaseBitcastABIRewrite_padded_arg_storage = alloca { i64, i64 }, align 8
    // CHECK:      %.BaseBitcastABIRewrite_arg = load { i64, i64 }, ptr %.BaseBitcastABIRewrite_padded_arg_storage
    take4([1, 2, 3, 4]);
}