Skip to content

TableGen: Generate enum for runtime libcall implementations #144973

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

Merged

Conversation

arsenm
Copy link
Contributor

@arsenm arsenm commented Jun 20, 2025

Work towards separating the ABI existence of libcalls vs. the
lowering selection. Set libcall selection through enums, rather
than through raw string names.

Copy link
Contributor Author

arsenm commented Jun 20, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@arsenm arsenm force-pushed the users/arsenm/tablegen/generate-runtime-libcall-impl-enum branch from d0d6a5b to d5ea33f Compare June 27, 2025 07:31
@arsenm arsenm force-pushed the users/arsenm/tablegen/add-runtime-libcall-backend branch from f394b9d to 098b3ea Compare June 27, 2025 07:31
Copy link
Contributor Author

arsenm commented Jun 27, 2025

Merge activity

  • Jun 27, 8:33 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jun 27, 8:37 AM UTC: Graphite rebased this pull request as part of a merge.
  • Jun 27, 8:40 AM UTC: @arsenm merged this pull request with Graphite.

@arsenm arsenm force-pushed the users/arsenm/tablegen/add-runtime-libcall-backend branch from 098b3ea to 2100301 Compare June 27, 2025 08:34
Base automatically changed from users/arsenm/tablegen/add-runtime-libcall-backend to main June 27, 2025 08:37
Work towards separating the ABI existence of libcalls vs. the
lowering selection. Set libcall selection through enums, rather
than through raw string names.
@arsenm arsenm force-pushed the users/arsenm/tablegen/generate-runtime-libcall-impl-enum branch from d5ea33f to 460bf5d Compare June 27, 2025 08:37
@arsenm arsenm merged commit b88e1f6 into main Jun 27, 2025
5 of 7 checks passed
@arsenm arsenm deleted the users/arsenm/tablegen/generate-runtime-libcall-impl-enum branch June 27, 2025 08:40
rlavaee pushed a commit to rlavaee/llvm-project that referenced this pull request Jul 1, 2025
)

Work towards separating the ABI existence of libcalls vs. the
lowering selection. Set libcall selection through enums, rather
than through raw string names.
@sbc100
Copy link
Collaborator

sbc100 commented Jul 8, 2025

This change somehow broke some of the LTO tests on the emscripten waterfall.

It seems to be related to the list of symbols that lld uses to determine the list of all libcall names. This comes from lto::LTO::getRuntimeLibcallSymbols and uses in lld/wasm/Driver.cpp.

I added some logging an compared the results of this function before and after this change. It seems that acosf is not longer part of this list for some reason... could be related to the fact that acosf is the very first libs call and has 0 as its enum value?

@sbc100
Copy link
Collaborator

sbc100 commented Jul 8, 2025

i.e. in the generated include/llvm/IR/RuntimeLibcalls.inc file I see:

enum Libcall : unsigned short {                                                       
  ACOS_F32 = 0,                                                                       
  ACOS_F64 = 1,                                                                       
  ACOS_F80 = 2,                                                                       
  ACOS_F128 = 3,                                                                      
  ACOS_PPCF128 = 4,   

@arsenm
Copy link
Contributor Author

arsenm commented Jul 8, 2025

I added some logging an compared the results of this function before and after this change. It seems that acosf is not longer part of this list for some reason... could be related to the fact that acosf is the very first libs call and has 0 as its enum value?

Yes, I'm guessing this drop_front no longer applies

@sbc100
Copy link
Collaborator

sbc100 commented Jul 8, 2025

Yup this patch fixes it:

--- a/llvm/include/llvm/IR/RuntimeLibcalls.h
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.h
@@ -90,8 +90,7 @@ struct RuntimeLibcallsInfo {
   }
 
   ArrayRef<RTLIB::LibcallImpl> getLibcallImpls() const {
-    // Trim Unsupported from the start
-    return ArrayRef(LibcallImpls).drop_front();
+    return LibcallImpls;
   }
 
   /// Get the comparison predicate that's to be used to test the result of the

@arsenm
Copy link
Contributor Author

arsenm commented Jul 8, 2025

Actually this one should be drop_back until the RTLIB::Libcall enum is swapped to use 0 as invalid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants