llvm-project/clang/test/CodeGen/sparcv9-class-return.cpp
Koakuma c2fba6df94
[clang][SPARC] Treat empty structs as if it's a one-bit type in the CC (#90338)
Make sure that empty structs are treated as if it has a size of one bit
in function parameters and return types so that it occupies a full
argument and/or return register slot.

This fixes crashes and miscompilations when passing and/or returning
empty structs.

Reviewed by: @s-barannikov
2024-05-15 20:49:28 +07:00

25 lines
439 B
C++

// RUN: %clang_cc1 -triple sparcv9-unknown-unknown -emit-llvm %s -o - | FileCheck %s
class Empty {
};
class Long : public Empty {
public:
long l;
};
// CHECK: define{{.*}} i64 @_Z4foo15Empty(i64 %e.coerce)
Empty foo1(Empty e) {
return e;
}
// CHECK: define{{.*}} %class.Long @_Z4foo24Long(i64 %l.coerce)
Long foo2(Long l) {
return l;
}
// CHECK: define{{.*}} i64 @_Z4foo34Long(i64 %l.coerce)
long foo3(Long l) {
return l.l;
}