-
Notifications
You must be signed in to change notification settings - Fork 14k
RuntimeLibcalls: Use array initializers for default values #143082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RuntimeLibcalls: Use array initializers for default values #143082
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
@llvm/pr-subscribers-llvm-ir Author: Matt Arsenault (arsenm) ChangesFull diff: https://github.com/llvm/llvm-project/pull/143082.diff 2 Files Affected:
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.h b/llvm/include/llvm/IR/RuntimeLibcalls.h
index d2704d5aa2616..d67430968edf1 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.h
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.h
@@ -90,10 +90,11 @@ struct RuntimeLibcallsInfo {
private:
/// Stores the name each libcall.
- const char *LibcallRoutineNames[RTLIB::UNKNOWN_LIBCALL + 1];
+ const char *LibcallRoutineNames[RTLIB::UNKNOWN_LIBCALL + 1] = {nullptr};
/// Stores the CallingConv that should be used for each libcall.
- CallingConv::ID LibcallCallingConvs[RTLIB::UNKNOWN_LIBCALL];
+ CallingConv::ID LibcallCallingConvs[RTLIB::UNKNOWN_LIBCALL] = {
+ CallingConv::C};
/// The condition type that should be used to test the result of each of the
/// soft floating-point comparison libcall against integer zero.
@@ -101,7 +102,8 @@ struct RuntimeLibcallsInfo {
// FIXME: This is only relevant for the handful of floating-point comparison
// runtime calls; it's excessive to have a table entry for every single
// opcode.
- CmpInst::Predicate SoftFloatCompareLibcallPredicates[RTLIB::UNKNOWN_LIBCALL];
+ CmpInst::Predicate SoftFloatCompareLibcallPredicates[RTLIB::UNKNOWN_LIBCALL] =
+ {CmpInst::BAD_ICMP_PREDICATE};
static bool darwinHasSinCosStret(const Triple &TT) {
assert(TT.isOSDarwin() && "should be called with darwin triple");
diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp
index a6fda0cfeadd2..01978b7ae39e3 100644
--- a/llvm/lib/IR/RuntimeLibcalls.cpp
+++ b/llvm/lib/IR/RuntimeLibcalls.cpp
@@ -12,9 +12,6 @@ using namespace llvm;
using namespace RTLIB;
void RuntimeLibcallsInfo::initSoftFloatCmpLibcallPredicates() {
- std::fill(SoftFloatCompareLibcallPredicates,
- SoftFloatCompareLibcallPredicates + RTLIB::UNKNOWN_LIBCALL,
- CmpInst::BAD_ICMP_PREDICATE);
SoftFloatCompareLibcallPredicates[RTLIB::OEQ_F32] = CmpInst::ICMP_EQ;
SoftFloatCompareLibcallPredicates[RTLIB::OEQ_F64] = CmpInst::ICMP_EQ;
SoftFloatCompareLibcallPredicates[RTLIB::OEQ_F128] = CmpInst::ICMP_EQ;
@@ -48,19 +45,12 @@ void RuntimeLibcallsInfo::initSoftFloatCmpLibcallPredicates() {
/// Set default libcall names. If a target wants to opt-out of a libcall it
/// should be placed here.
void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) {
- std::fill(std::begin(LibcallRoutineNames), std::end(LibcallRoutineNames),
- nullptr);
-
initSoftFloatCmpLibcallPredicates();
#define HANDLE_LIBCALL(code, name) setLibcallName(RTLIB::code, name);
#include "llvm/IR/RuntimeLibcalls.def"
#undef HANDLE_LIBCALL
- // Initialize calling conventions to their default.
- for (int LC = 0; LC < RTLIB::UNKNOWN_LIBCALL; ++LC)
- setLibcallCallingConv((RTLIB::Libcall)LC, CallingConv::C);
-
// Use the f128 variants of math functions on x86
if (TT.isX86() && TT.isGNUEnvironment()) {
setLibcallName(RTLIB::REM_F128, "fmodf128");
|
ee79ca1
to
65cb831
Compare
8aa7850
to
0e8bba5
Compare
|
||
/// The condition type that should be used to test the result of each of the | ||
/// soft floating-point comparison libcall against integer zero. | ||
/// | ||
// FIXME: This is only relevant for the handful of floating-point comparison | ||
// runtime calls; it's excessive to have a table entry for every single | ||
// opcode. | ||
CmpInst::Predicate SoftFloatCompareLibcallPredicates[RTLIB::UNKNOWN_LIBCALL]; | ||
CmpInst::Predicate SoftFloatCompareLibcallPredicates[RTLIB::UNKNOWN_LIBCALL] = | ||
{CmpInst::BAD_ICMP_PREDICATE}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CmpInst::BAD_ICMP_PREDICATE is not zero (42) so only the first element of the array will be initialized to CmpInst::BAD_ICMP_PREDICATE
rest will be zero.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no actual reason to initialize this, the only fields that are used are explicitly initialized separately. We should shrink the array as the FIXME says
0e8bba5
to
f991879
Compare
65cb831
to
6e17ae5
Compare
|
||
/// Stores the CallingConv that should be used for each libcall. | ||
CallingConv::ID LibcallCallingConvs[RTLIB::UNKNOWN_LIBCALL]; | ||
CallingConv::ID LibcallCallingConvs[RTLIB::UNKNOWN_LIBCALL] = { | ||
CallingConv::C}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explicitly writing "CallingConv::C" here is confusing; either just use {}
, or use something like SmallVector that actually has a constructor which fills an arbitrary value.
6e17ae5
to
30983d1
Compare
540bdad
to
9a03bb1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
30983d1
to
fbfc09b
Compare
9a03bb1
to
4cf8c0f
Compare
Work towards making RuntimeLibcalls the centralized location for all libcall information. This requires changing the encoding from tracking the ISD::CondCode to using CmpInst::Predicate.
The darwinHasSinCos wasn't actually used for sincos, only the stret variant. Rename this to reflect that, and introduce a new one for enabling sincos.
fbfc09b
to
fc327d3
Compare
4cf8c0f
to
3a86744
Compare
Merge activity
|
fc327d3
to
c85d667
Compare
No description provided.