1; RUN: llc -verify-machineinstrs -O0 -mcpu=ppc64 -mtriple=powerpc64-unknown-linux-gnu -fast-isel=false < %s | FileCheck %s 2 3; Test case for PR 14779: anonymous aggregates are not handled correctly. 4; Darwin bug report PR 15821 is similar. 5; The bug is triggered by passing a byval structure after an anonymous 6; aggregate. 7 8%tarray = type { i64, i8* } 9 10define i8* @func1({ i64, i8* } %array, i8* %ptr) { 11entry: 12 %array_ptr = extractvalue {i64, i8* } %array, 1 13 %cond = icmp eq i8* %array_ptr, %ptr 14 br i1 %cond, label %equal, label %unequal 15equal: 16 ret i8* %array_ptr 17unequal: 18 ret i8* %ptr 19} 20 21; CHECK-LABEL: func1: 22; CHECK-DAG: std 3, -[[OFFSET1:[0-9]+]] 23; CHECK-DAG: std 5, -[[OFFSET2:[0-9]+]] 24; CHECK: cmpld {{([0-9]+,)?}}4, 5 25; CHECK: ld 3, -[[OFFSET1]](1) 26; CHECK: ld 3, -[[OFFSET2]](1) 27 28define i8* @func2({ i64, i8* } %array1, %tarray* byval(%tarray) %array2) { 29entry: 30 %array1_ptr = extractvalue {i64, i8* } %array1, 1 31 %tmp = getelementptr inbounds %tarray, %tarray* %array2, i32 0, i32 1 32 %array2_ptr = load i8*, i8** %tmp 33 %cond = icmp eq i8* %array1_ptr, %array2_ptr 34 br i1 %cond, label %equal, label %unequal 35equal: 36 ret i8* %array1_ptr 37unequal: 38 ret i8* %array2_ptr 39} 40; CHECK-LABEL: func2: 41; CHECK-DAG: cmpld {{([0-9]+,)?}}4, 3 42; CHECK-DAG: std 6, 72(1) 43; CHECK-DAG: std 5, 64(1) 44; CHECK-DAG: std 3, -[[OFFSET1:[0-9]+]] 45; CHECK-DAG: std 3, -[[OFFSET2:[0-9]+]] 46; CHECK: ld 3, -[[OFFSET1]](1) 47; CHECK: ld 3, -[[OFFSET2]](1) 48 49define i8* @func3({ i64, i8* }* byval({ i64, i8* }) %array1, %tarray* byval(%tarray) %array2) { 50entry: 51 %tmp1 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %array1, i32 0, i32 1 52 %array1_ptr = load i8*, i8** %tmp1 53 %tmp2 = getelementptr inbounds %tarray, %tarray* %array2, i32 0, i32 1 54 %array2_ptr = load i8*, i8** %tmp2 55 %cond = icmp eq i8* %array1_ptr, %array2_ptr 56 br i1 %cond, label %equal, label %unequal 57equal: 58 ret i8* %array1_ptr 59unequal: 60 ret i8* %array2_ptr 61} 62 63; CHECK-LABEL: func3: 64; CHECK-DAG: cmpld {{([0-9]+,)?}}3, 4 65; CHECK-DAG: std 3, -[[OFFSET2:[0-9]+]](1) 66; CHECK-DAG: std 4, -[[OFFSET1:[0-9]+]](1) 67; CHECK: ld 3, -[[OFFSET2]](1) 68; CHECK: ld 3, -[[OFFSET1]](1) 69 70define i8* @func4(i64 %p1, i64 %p2, i64 %p3, i64 %p4, 71 i64 %p5, i64 %p6, i64 %p7, i64 %p8, 72 { i64, i8* } %array1, %tarray* byval(%tarray) %array2) { 73entry: 74 %array1_ptr = extractvalue {i64, i8* } %array1, 1 75 %tmp = getelementptr inbounds %tarray, %tarray* %array2, i32 0, i32 1 76 %array2_ptr = load i8*, i8** %tmp 77 %cond = icmp eq i8* %array1_ptr, %array2_ptr 78 br i1 %cond, label %equal, label %unequal 79equal: 80 ret i8* %array1_ptr 81unequal: 82 ret i8* %array2_ptr 83} 84 85; CHECK-LABEL: func4: 86; CHECK-DAG: ld [[REG2:[0-9]+]], 120(1) 87; CHECK-DAG: ld [[REG3:[0-9]+]], 136(1) 88; CHECK-DAG: std [[REG2]], -[[OFFSET1:[0-9]+]](1) 89; CHECK: std [[REG3]], -[[OFFSET2:[0-9]+]](1) 90; CHECK: cmpld {{([0-9]+,)?}}[[REG2]], [[REG3]] 91; CHECK: ld 3, -[[OFFSET1]](1) 92; CHECK: ld 3, -[[OFFSET2]](1) 93 94