[llvm] RuntimeLibcalls: Add methods to recognize libcall names (PR #149001)

Alexander Kornienko via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 4 18:46:36 PDT 2025


alexfh wrote:

After 0b7a95a6fd81b31634a3723a0bea6d9d91bbc230 llvm/test/TableGen/RuntimeLibcallEmitter.td started being flaky in our builds. Specifically, the order of `sqrtl_f80` and `sqrtl_f128` changes from run to run in this fragment:
```
enum LibcallImpl : unsigned short {
  Unsupported = 0,
  ___memcpy = 1, // ___memcpy
  ___memset = 2, // ___memset
  __ashlsi3 = 3, // __ashlsi3
  __lshrdi3 = 4, // __lshrdi3
  bzero = 5, // bzero
  calloc = 6, // calloc
  sqrtl_f80 = 7, // sqrtl
  sqrtl_f128 = 8, // sqrtl
  NumLibcallImpls = 9
};
```
i.e. it sometimes looks like this:
```
enum LibcallImpl : unsigned short {
  Unsupported = 0,
  ___memcpy = 1, // ___memcpy
  ___memset = 2, // ___memset
  __ashlsi3 = 3, // __ashlsi3
  __lshrdi3 = 4, // __lshrdi3
  bzero = 5, // bzero
  calloc = 6, // calloc
  sqrtl_f128 = 7, // sqrtl
  sqrtl_f80 = 8, // sqrtl
  NumLibcallImpls = 9
};
```

And in this fragment:
```
const RTLIB::Libcall llvm::RTLIB::RuntimeLibcallsInfo::ImplToLibcall[RTLIB::NumLibcallImpls] = {
  RTLIB::UNKNOWN_LIBCALL, // RTLIB::Unsupported
  RTLIB::MEMCPY, // RTLIB::___memcpy
  RTLIB::MEMSET, // RTLIB::___memset
  RTLIB::SHL_I32, // RTLIB::__ashlsi3
  RTLIB::SRL_I64, // RTLIB::__lshrdi3
  RTLIB::BZERO, // RTLIB::bzero
  RTLIB::CALLOC, // RTLIB::calloc
  RTLIB::SQRT_F80, // RTLIB::sqrtl_f80
  RTLIB::SQRT_F128, // RTLIB::sqrtl_f128
};
```
```
const RTLIB::Libcall llvm::RTLIB::RuntimeLibcallsInfo::ImplToLibcall[RTLIB::NumLibcallImpls] = {
  RTLIB::UNKNOWN_LIBCALL, // RTLIB::Unsupported
  RTLIB::MEMCPY, // RTLIB::___memcpy
  RTLIB::MEMSET, // RTLIB::___memset
  RTLIB::SHL_I32, // RTLIB::__ashlsi3
  RTLIB::SRL_I64, // RTLIB::__lshrdi3
  RTLIB::BZERO, // RTLIB::bzero
  RTLIB::CALLOC, // RTLIB::calloc
  RTLIB::SQRT_F128, // RTLIB::sqrtl_f128
  RTLIB::SQRT_F80, // RTLIB::sqrtl_f80
};
```

I haven't figured out, which particular combination of options affects this behavior (I only see this in some configurations).

https://github.com/llvm/llvm-project/pull/149001


More information about the llvm-commits mailing list