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

[Xtensa] Default to unsigned char #115967

Merged

Conversation

arichardson
Copy link
Member

@arichardson arichardson commented Nov 13, 2024

This matches GCC.

Partially addresses #115964

Created using spr 1.3.6-beta.1
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Nov 13, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 13, 2024

@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: Alexander Richardson (arichardson)

Changes

This matches GCC.

Partially fixes #115964


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

2 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/Clang.cpp (+1)
  • (added) clang/test/Driver/xtensa-char.c (+4)
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 0952262c360185..29954bfbc560c1 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1347,6 +1347,7 @@ static bool isSignedCharDefault(const llvm::Triple &Triple) {
   case llvm::Triple::riscv64:
   case llvm::Triple::systemz:
   case llvm::Triple::xcore:
+  case llvm::Triple::xtensa:
     return false;
   }
 }
diff --git a/clang/test/Driver/xtensa-char.c b/clang/test/Driver/xtensa-char.c
new file mode 100644
index 00000000000000..13f8f67727e75d
--- /dev/null
+++ b/clang/test/Driver/xtensa-char.c
@@ -0,0 +1,4 @@
+/// Check that char is unsigned by default.
+// RUN: %clang -### %s --target=xtensa -c 2>&1 | FileCheck %s
+// CHECK: "-cc1" "-triple" "xtensa"
+// CHECK-SAME: "-fno-signed-char"

@brad0
Copy link
Contributor

brad0 commented Nov 27, 2024

cc @andreisfr

@gerekon
Copy link
Contributor

gerekon commented Nov 28, 2024

Looks like it is related to #118008

@gerekon
Copy link
Contributor

gerekon commented Nov 28, 2024

Hi @arichardson.

Thanks for this change. Acc to the doc which I have The char type is unsigned by default for Xtensa processors. Our GCC Xtensa toolchain also interprets char type as unsigned by default.

@arichardson
Copy link
Member Author

Hi @arichardson.

Thanks for this change. Acc to the doc which I have The char type is unsigned by default for Xtensa processors. Our GCC Xtensa toolchain also interprets char type as unsigned by default.

Thanks, do you believe we need a backwards compatibility flag for the ABI to be consistent with older clang or is this safe to land?

@gerekon
Copy link
Contributor

gerekon commented Dec 2, 2024

Thanks, do you believe we need a backwards compatibility flag for the ABI to be consistent with older clang or is this safe to land?

I think as far as we can control behavior with -fsigned-char we do not need another option for this.

@MabezDev WDYT? Will it be critical for Rust builds? After that Xtensa behavior will be in sync with RISCV.

@arichardson
Copy link
Member Author

Looking at #118008 it sounds like we don't yet have complete codegen support for XTensa in Clang, so it sounds like this is safe without a flag.

@gerekon
Copy link
Contributor

gerekon commented Dec 2, 2024

Looking at #118008 it sounds like we don't yet have complete codegen support for XTensa in Clang, so it sounds like this is safe without a flag.

Yes, it is not upstreamed yet. We are working on it. But after rebasing on the LLVM 20 we might get this fix in our repo, so that will influence our Clang toolchain and Rust, Swift ones. So I asked @MabezDev if he sees any potential problems with this.

Sorry my bad. This is related to Clang only. Neither Rust nor Swift will be influenced.

Created using spr 1.3.6-beta.1
@arichardson arichardson merged commit b36f1c8 into main Dec 2, 2024
6 of 7 checks passed
@arichardson arichardson deleted the users/arichardson/spr/xtensa-default-to-unsigned-char branch December 2, 2024 19:53
arichardson added a commit to arichardson/rust that referenced this pull request Dec 10, 2024
Expcept for L4RE and Xtensa these were obtained from rust-lang#131319

I could not find an open link to the Xtensa documentation, but the
signedness was confirmed by on of the Xtensa developers in
llvm/llvm-project#115967 (comment)

Co-authored-by: Taiki Endo <te316e89@gmail.com>
TIFitis pushed a commit to TIFitis/llvm-project that referenced this pull request Dec 18, 2024
This matches GCC.

Partially addresses llvm#115964

Pull Request: llvm#115967
espressif-bot pushed a commit to espressif/llvm-project that referenced this pull request Dec 24, 2024
This matches GCC.

Partially addresses llvm#115964

Pull Request: llvm#115967
espressif-bot pushed a commit to espressif/llvm-project that referenced this pull request Jan 17, 2025
This matches GCC.

Partially addresses llvm#115964

Pull Request: llvm#115967
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants