Skip to content

Commit 9a03bb1

Browse files
committed
RuntimeLibcalls: Use array initializers for default values
1 parent 30983d1 commit 9a03bb1

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

llvm/include/llvm/IR/RuntimeLibcalls.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,13 @@ struct RuntimeLibcallsInfo {
103103

104104
private:
105105
/// Stores the name each libcall.
106-
const char *LibcallRoutineNames[RTLIB::UNKNOWN_LIBCALL + 1];
106+
const char *LibcallRoutineNames[RTLIB::UNKNOWN_LIBCALL + 1] = {nullptr};
107+
108+
static_assert(static_cast<int>(CallingConv::C) == 0,
109+
"default calling conv should be encoded as 0");
107110

108111
/// Stores the CallingConv that should be used for each libcall.
109-
CallingConv::ID LibcallCallingConvs[RTLIB::UNKNOWN_LIBCALL];
112+
CallingConv::ID LibcallCallingConvs[RTLIB::UNKNOWN_LIBCALL] = {};
110113

111114
/// The condition type that should be used to test the result of each of the
112115
/// soft floating-point comparison libcall against integer zero.

llvm/lib/IR/RuntimeLibcalls.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ static void setAArch64LibcallNames(RuntimeLibcallsInfo &Info,
3232
}
3333

3434
void RuntimeLibcallsInfo::initSoftFloatCmpLibcallPredicates() {
35-
std::fill(SoftFloatCompareLibcallPredicates,
36-
SoftFloatCompareLibcallPredicates + RTLIB::UNKNOWN_LIBCALL,
37-
CmpInst::BAD_ICMP_PREDICATE);
3835
SoftFloatCompareLibcallPredicates[RTLIB::OEQ_F32] = CmpInst::ICMP_EQ;
3936
SoftFloatCompareLibcallPredicates[RTLIB::OEQ_F64] = CmpInst::ICMP_EQ;
4037
SoftFloatCompareLibcallPredicates[RTLIB::OEQ_F128] = CmpInst::ICMP_EQ;
@@ -68,19 +65,12 @@ void RuntimeLibcallsInfo::initSoftFloatCmpLibcallPredicates() {
6865
/// Set default libcall names. If a target wants to opt-out of a libcall it
6966
/// should be placed here.
7067
void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) {
71-
std::fill(std::begin(LibcallRoutineNames), std::end(LibcallRoutineNames),
72-
nullptr);
73-
7468
initSoftFloatCmpLibcallPredicates();
7569

7670
#define HANDLE_LIBCALL(code, name) setLibcallName(RTLIB::code, name);
7771
#include "llvm/IR/RuntimeLibcalls.def"
7872
#undef HANDLE_LIBCALL
7973

80-
// Initialize calling conventions to their default.
81-
for (int LC = 0; LC < RTLIB::UNKNOWN_LIBCALL; ++LC)
82-
setLibcallCallingConv((RTLIB::Libcall)LC, CallingConv::C);
83-
8474
// Use the f128 variants of math functions on x86
8575
if (TT.isX86() && TT.isGNUEnvironment()) {
8676
setLibcallName(RTLIB::REM_F128, "fmodf128");

0 commit comments

Comments
 (0)