Skip to content

Commit b81a992

Browse files
authored
[lldb][TypeSystem] Remove count parameter from TypeSystem::IsFloatingPointType (llvm#165707)
Similar motivation to llvm#165702. It was unused in all callsites and inconsistent with other APIs like `IsIntegerType` (which doesn't take a `count` parameter). If we ever need a "how many elements does this type represent", we can implement one with a new TypeSystem API that does exactly that. Some callsites checked for `count == 1` previously, but I suspect what they intended to do is check for whether it's a vector type or complex type, before reading the FP register. I'm somewhat confident that's the case because the `TypeSystemClang::GetTypeInfo` currently incorrectly sets the integer and floating point bits for complex and vector types (will fix separately). But some architectures might choose to pass single-element vectors in scalar registers. I should probably changes these to check the vector element size. All the `count == 2 && is_complex` were redundant because `count == 2` iff `is_complex == true`. So I just removed the count check there.
1 parent ef2a05d commit b81a992

File tree

18 files changed

+42
-67
lines changed

18 files changed

+42
-67
lines changed

lldb/include/lldb/Symbol/CompilerType.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class CompilerType {
144144

145145
bool IsDefined() const;
146146

147-
bool IsFloatingPointType(uint32_t &count, bool &is_complex) const;
147+
bool IsFloatingPointType(bool &is_complex) const;
148148

149149
bool IsFunctionType() const;
150150

lldb/include/lldb/Symbol/TypeSystem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class TypeSystem : public PluginInterface,
163163
virtual bool IsDefined(lldb::opaque_compiler_type_t type) = 0;
164164

165165
virtual bool IsFloatingPointType(lldb::opaque_compiler_type_t type,
166-
uint32_t &count, bool &is_complex) = 0;
166+
bool &is_complex) = 0;
167167

168168
virtual bool IsFunctionType(lldb::opaque_compiler_type_t type) = 0;
169169

lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,7 +1695,6 @@ Status ABIMacOSX_arm::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
16951695
Thread *thread = frame_sp->GetThread().get();
16961696

16971697
bool is_signed;
1698-
uint32_t count;
16991698
bool is_complex;
17001699

17011700
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
@@ -1767,7 +1766,7 @@ Status ABIMacOSX_arm::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
17671766
"We don't support returning longer than 64 bit "
17681767
"integer values at present.");
17691768
}
1770-
} else if (compiler_type.IsFloatingPointType(count, is_complex)) {
1769+
} else if (compiler_type.IsFloatingPointType(is_complex)) {
17711770
if (is_complex)
17721771
error = Status::FromErrorString(
17731772
"We don't support returning complex values at present");

lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,7 +1550,6 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
15501550

15511551
bool is_signed;
15521552
bool is_complex;
1553-
uint32_t float_count;
15541553
bool is_vfp_candidate = false;
15551554
uint8_t vfp_count = 0;
15561555
uint8_t vfp_byte_size = 0;
@@ -1634,8 +1633,9 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
16341633
if (!GetReturnValuePassedInMemory(thread, reg_ctx, *byte_size, value))
16351634
return return_valobj_sp;
16361635
}
1637-
} else if (compiler_type.IsFloatingPointType(float_count, is_complex)) {
1638-
if (float_count == 1 && !is_complex) {
1636+
} else if (compiler_type.IsFloatingPointType(is_complex)) {
1637+
// Vector types are handled above.
1638+
if (!is_complex) {
16391639
switch (*bit_width) {
16401640
default:
16411641
return return_valobj_sp;
@@ -1681,7 +1681,7 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
16811681
break;
16821682
}
16831683
}
1684-
} else if (is_complex && float_count == 2) {
1684+
} else if (is_complex) {
16851685
if (IsArmHardFloat(thread)) {
16861686
is_vfp_candidate = true;
16871687
vfp_byte_size = *byte_size / 2;
@@ -1709,8 +1709,9 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
17091709
vfp_count = (*base_byte_size == 8 ? homogeneous_count
17101710
: homogeneous_count * 2);
17111711
}
1712-
} else if (base_type.IsFloatingPointType(float_count, is_complex)) {
1713-
if (float_count == 1 && !is_complex) {
1712+
} else if (base_type.IsFloatingPointType(is_complex)) {
1713+
// Vector types are handled above.
1714+
if (!is_complex) {
17141715
is_vfp_candidate = true;
17151716
if (base_byte_size)
17161717
vfp_byte_size = *base_byte_size;
@@ -1727,10 +1728,10 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
17271728
base_type = compiler_type.GetFieldAtIndex(index, name, nullptr,
17281729
nullptr, nullptr);
17291730

1730-
if (base_type.IsFloatingPointType(float_count, is_complex)) {
1731+
if (base_type.IsFloatingPointType(is_complex)) {
17311732
std::optional<uint64_t> base_byte_size =
17321733
llvm::expectedToOptional(base_type.GetByteSize(&thread));
1733-
if (float_count == 2 && is_complex) {
1734+
if (is_complex) {
17341735
if (index != 0 && base_byte_size &&
17351736
vfp_byte_size != *base_byte_size)
17361737
break;
@@ -1841,7 +1842,6 @@ Status ABISysV_arm::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
18411842
Thread *thread = frame_sp->GetThread().get();
18421843

18431844
bool is_signed;
1844-
uint32_t count;
18451845
bool is_complex;
18461846

18471847
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
@@ -1884,7 +1884,7 @@ Status ABISysV_arm::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
18841884
"We don't support returning longer than 64 bit "
18851885
"integer values at present.");
18861886
}
1887-
} else if (compiler_type.IsFloatingPointType(count, is_complex)) {
1887+
} else if (compiler_type.IsFloatingPointType(is_complex)) {
18881888
if (is_complex)
18891889
error = Status::FromErrorString(
18901890
"We don't support returning complex values at present");

lldb/source/Plugins/ABI/LoongArch/ABISysV_loongarch.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,11 +510,10 @@ ValueObjectSP ABISysV_loongarch::GetReturnValueObjectSimple(
510510
value, ConstString(""));
511511
}
512512
if (type_flags & eTypeIsFloat) {
513-
uint32_t float_count = 0;
514513
bool is_complex = false;
515514

516-
if (compiler_type.IsFloatingPointType(float_count, is_complex) &&
517-
float_count == 1 && !is_complex) {
515+
if (compiler_type.IsFloatingPointType(is_complex) &&
516+
!(type_flags & eTypeIsVector) && !is_complex) {
518517
return_valobj_sp =
519518
GetValObjFromFPRegs(thread, reg_ctx, machine, type_flags, byte_size);
520519
return return_valobj_sp;

lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,6 @@ Status ABISysV_mips::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
708708
Thread *thread = frame_sp->GetThread().get();
709709

710710
bool is_signed;
711-
uint32_t count;
712711
bool is_complex;
713712

714713
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
@@ -750,7 +749,7 @@ Status ABISysV_mips::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
750749
"We don't support returning longer than 64 bit "
751750
"integer values at present.");
752751
}
753-
} else if (compiler_type.IsFloatingPointType(count, is_complex)) {
752+
} else if (compiler_type.IsFloatingPointType(is_complex)) {
754753
if (is_complex)
755754
error = Status::FromErrorString(
756755
"We don't support returning complex values at present");
@@ -797,7 +796,6 @@ ValueObjectSP ABISysV_mips::GetReturnValueObjectImpl(
797796

798797
bool is_signed = false;
799798
bool is_complex = false;
800-
uint32_t count = 0;
801799

802800
// In MIPS register "r2" (v0) holds the integer function return values
803801
const RegisterInfo *r2_reg_info = reg_ctx->GetRegisterInfoByName("r2", 0);
@@ -860,10 +858,10 @@ ValueObjectSP ABISysV_mips::GetReturnValueObjectImpl(
860858
return_valobj_sp = ValueObjectMemory::Create(
861859
&thread, "", Address(mem_address, nullptr), return_compiler_type);
862860
return return_valobj_sp;
863-
} else if (return_compiler_type.IsFloatingPointType(count, is_complex)) {
861+
} else if (return_compiler_type.IsFloatingPointType(is_complex)) {
864862
if (IsSoftFloat(fp_flag)) {
865863
uint64_t raw_value = reg_ctx->ReadRegisterAsUnsigned(r2_reg_info, 0);
866-
if (count != 1 && is_complex)
864+
if (is_complex)
867865
return return_valobj_sp;
868866
switch (*bit_width) {
869867
default:
@@ -896,7 +894,7 @@ ValueObjectSP ABISysV_mips::GetReturnValueObjectImpl(
896894
f0_value.GetData(f0_data);
897895
lldb::offset_t offset = 0;
898896

899-
if (count == 1 && !is_complex) {
897+
if (!return_compiler_type.IsVectorType() && !is_complex) {
900898
switch (*bit_width) {
901899
default:
902900
return return_valobj_sp;

lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,6 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
923923
bool sucess = false;
924924
std::string name;
925925
bool is_complex;
926-
uint32_t count;
927926
const uint32_t num_children = return_compiler_type.GetNumFields();
928927

929928
// A structure consisting of one or two FP values (and nothing else) will
@@ -937,7 +936,7 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
937936
return_compiler_type.GetFieldAtIndex(idx, name, &field_bit_offset,
938937
nullptr, nullptr);
939938

940-
if (field_compiler_type.IsFloatingPointType(count, is_complex))
939+
if (field_compiler_type.IsFloatingPointType(is_complex))
941940
use_fp_regs = true;
942941
else
943942
found_non_fp_field = true;
@@ -1044,7 +1043,7 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
10441043

10451044
if (field_compiler_type.IsIntegerOrEnumerationType(is_signed) ||
10461045
field_compiler_type.IsPointerType() ||
1047-
field_compiler_type.IsFloatingPointType(count, is_complex)) {
1046+
field_compiler_type.IsFloatingPointType(is_complex)) {
10481047
padding = field_byte_offset - integer_bytes;
10491048

10501049
if (integer_bytes < 8) {

lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,6 @@ Status ABISysV_ppc::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
426426
Thread *thread = frame_sp->GetThread().get();
427427

428428
bool is_signed;
429-
uint32_t count;
430429
bool is_complex;
431430

432431
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
@@ -454,7 +453,7 @@ Status ABISysV_ppc::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
454453
"We don't support returning longer than 64 bit "
455454
"integer values at present.");
456455
}
457-
} else if (compiler_type.IsFloatingPointType(count, is_complex)) {
456+
} else if (compiler_type.IsFloatingPointType(is_complex)) {
458457
if (is_complex)
459458
error = Status::FromErrorString(
460459
"We don't support returning complex values at present");
@@ -695,7 +694,6 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectImpl(
695694
uint64_t field_bit_offset = 0;
696695
bool is_signed;
697696
bool is_complex;
698-
uint32_t count;
699697

700698
CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex(
701699
idx, name, &field_bit_offset, nullptr, nullptr);
@@ -741,7 +739,7 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectImpl(
741739
// return a nullptr return value object.
742740
return return_valobj_sp;
743741
}
744-
} else if (field_compiler_type.IsFloatingPointType(count, is_complex)) {
742+
} else if (field_compiler_type.IsFloatingPointType(is_complex)) {
745743
// Structs with long doubles are always passed in memory.
746744
if (*field_bit_width == 128) {
747745
is_memory = true;

lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ Status ABISysV_ppc64::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
309309
Thread *thread = frame_sp->GetThread().get();
310310

311311
bool is_signed;
312-
uint32_t count;
313312
bool is_complex;
314313

315314
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
@@ -339,7 +338,7 @@ Status ABISysV_ppc64::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
339338
"We don't support returning longer than 64 bit "
340339
"integer values at present.");
341340
}
342-
} else if (compiler_type.IsFloatingPointType(count, is_complex)) {
341+
} else if (compiler_type.IsFloatingPointType(is_complex)) {
343342
if (is_complex)
344343
error = Status::FromErrorString(
345344
"We don't support returning complex values at present");

lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -643,11 +643,10 @@ ABISysV_riscv::GetReturnValueObjectSimple(Thread &thread,
643643
}
644644
// Floating point return type.
645645
else if (type_flags & eTypeIsFloat) {
646-
uint32_t float_count = 0;
647646
bool is_complex = false;
648647

649-
if (compiler_type.IsFloatingPointType(float_count, is_complex) &&
650-
float_count == 1 && !is_complex) {
648+
if (compiler_type.IsFloatingPointType(is_complex) &&
649+
!(type_flags & eTypeIsVector) && !is_complex) {
651650
const uint32_t arch_fp_flags =
652651
arch.GetFlags() & ArchSpec::eRISCV_float_abi_mask;
653652
return_valobj_sp = GetValObjFromFPRegs(

0 commit comments

Comments
 (0)