Skip to content
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

[clang] Define SwiftInfo for RISCVTargetCodeGenInfo #82152

Merged
merged 1 commit into from
Mar 14, 2024

Conversation

kubamracek
Copy link
Member

For Embedded Swift, let's unblock building for RISC-V boards (e.g. ESP32-C6). This isn't trying to add full RISC-V support to Swift / Embedded Swift, it's just fixing the immediate blocker (not having SwiftInfo defined blocks all compilations).

@llvmbot llvmbot added clang Clang issues not falling into any other category backend:RISC-V clang:codegen labels Feb 18, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Feb 18, 2024

@llvm/pr-subscribers-clang
@llvm/pr-subscribers-backend-risc-v

@llvm/pr-subscribers-clang-codegen

Author: Kuba (Brecka) Mracek (kubamracek)

Changes

For Embedded Swift, let's unblock building for RISC-V boards (e.g. ESP32-C6). This isn't trying to add full RISC-V support to Swift / Embedded Swift, it's just fixing the immediate blocker (not having SwiftInfo defined blocks all compilations).


Full diff: https://github.com/llvm/llvm-project/pull/82152.diff

1 Files Affected:

  • (modified) clang/lib/CodeGen/Targets/RISCV.cpp (+4-1)
diff --git a/clang/lib/CodeGen/Targets/RISCV.cpp b/clang/lib/CodeGen/Targets/RISCV.cpp
index dec6540230a60f..9a79424c4612ce 100644
--- a/clang/lib/CodeGen/Targets/RISCV.cpp
+++ b/clang/lib/CodeGen/Targets/RISCV.cpp
@@ -529,7 +529,10 @@ class RISCVTargetCodeGenInfo : public TargetCodeGenInfo {
   RISCVTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, unsigned XLen,
                          unsigned FLen, bool EABI)
       : TargetCodeGenInfo(
-            std::make_unique<RISCVABIInfo>(CGT, XLen, FLen, EABI)) {}
+            std::make_unique<RISCVABIInfo>(CGT, XLen, FLen, EABI)) {
+    SwiftInfo =
+        std::make_unique<SwiftABIInfo>(CGT, /*SwiftErrorInRegister=*/false);
+  }
 
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
                            CodeGen::CodeGenModule &CGM) const override {

@wangpc-pp
Copy link
Contributor

Can this be tested? I don't know what the affects are.

@jroelofs
Copy link
Contributor

Can this be tested? I don't know what the affects are.

Might be as simple as adding another RUN: line to clang/test/CodeGenCXX/arm-swiftcall.{c,cpp} with a riscv triple.

@asb
Copy link
Contributor

asb commented Feb 19, 2024

Yes, please add a trivial test if at all possible.

Copy link
Contributor

@wangpc-pp wangpc-pp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@kubamracek kubamracek merged commit b84ce99 into llvm:main Mar 14, 2024
4 checks passed
kubamracek added a commit to kubamracek/llvm-project that referenced this pull request Mar 14, 2024
For Embedded Swift, let's unblock building for RISC-V boards (e.g.
ESP32-C6). This isn't trying to add full RISC-V support to Swift /
Embedded Swift, it's just fixing the immediate blocker (not having
SwiftInfo defined blocks all compilations).
@jrtc27
Copy link
Collaborator

jrtc27 commented Mar 14, 2024

What purpose does this serve if swiftcall doesn't work? Given the tests only test that you can produce IR from Clang, that suggests that it doesn't actually do anything useful?.. (And if it does do something useful, that should be being tested)

kubamracek added a commit to apple/llvm-project that referenced this pull request Mar 15, 2024
For Embedded Swift, let's unblock building for RISC-V boards (e.g.
ESP32-C6). This isn't trying to add full RISC-V support to Swift /
Embedded Swift, it's just fixing the immediate blocker (not having
SwiftInfo defined blocks all compilations).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:RISC-V clang:codegen clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants