Skip to content

Commit a9754a1

Browse files
committed
[Xtensa] Fix Call ABI for 16 byte alignment.
1 parent 34236f6 commit a9754a1

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

clang/lib/CodeGen/TargetInfo.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11618,9 +11618,8 @@ ABIArgInfo XtensaABIInfo::classifyArgumentType(QualType Ty,
1161811618
if (Size < 32 && Ty->isIntegralOrEnumerationType() && !MustUseStack) {
1161911619
return extendType(Ty);
1162011620
}
11621-
if (Size == 64)
11622-
return ABIArgInfo::getDirect(llvm::IntegerType::get(getVMContext(), 64));
11623-
return ABIArgInfo::getDirect(llvm::IntegerType::get(getVMContext(), 32));
11621+
// Assume that type has 32, 64 or 128 bits
11622+
return ABIArgInfo::getDirect(llvm::IntegerType::get(getVMContext(), Size));
1162411623
}
1162511624

1162611625
// Aggregates which are <= 6*32 will be passed in registers if possible,
@@ -11631,6 +11630,8 @@ ABIArgInfo XtensaABIInfo::classifyArgumentType(QualType Ty,
1163111630
} else if (NeededAlign == (2 * 32)) {
1163211631
return ABIArgInfo::getDirect(llvm::ArrayType::get(
1163311632
llvm::IntegerType::get(getVMContext(), 64), NeededArgGPRs / 2));
11633+
} else if (NeededAlign == (4 * 32)) {
11634+
return ABIArgInfo::getDirect(llvm::IntegerType::get(getVMContext(), 128));
1163411635
} else {
1163511636
return ABIArgInfo::getDirect(llvm::ArrayType::get(
1163611637
llvm::IntegerType::get(getVMContext(), 32), NeededArgGPRs));

clang/test/CodeGen/xtensa-abi.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,17 @@ char *bufalloc ()
1212
}
1313

1414
// CHECK: define dso_local noalias i8* @bufalloc() #0 {
15+
16+
struct S16 { int a[4]; } __attribute__ ((aligned (16)));
17+
18+
void callee_struct_a16b_1(struct S16 a) {}
19+
20+
// CHECK: define dso_local void @callee_struct_a16b_1(i128 %a.coerce)
21+
22+
void callee_struct_a16b_2(struct S16 a, int b) {}
23+
24+
// CHECK: define dso_local void @callee_struct_a16b_2(i128 %a.coerce, i32 noundef %b)
25+
26+
void callee_struct_a16b_3(int a, struct S16 b) {}
27+
28+
// CHECK: define dso_local void @callee_struct_a16b_3(i32 noundef %a, %struct.S16* noundef byval(%struct.S16) align 16 %b)

0 commit comments

Comments
 (0)