[llvm-branch-commits] [clang] 7e17e15 - clang: Introduce -fexperimental-max-bitint-width

2022-06-08 Thread Matthias Gehre via llvm-branch-commits

Author: Matthias Gehre
Date: 2022-06-09T07:15:03+01:00
New Revision: 7e17e15c9f01a04283524c6a6735d639aac39fe6

URL: 
https://github.com/llvm/llvm-project/commit/7e17e15c9f01a04283524c6a6735d639aac39fe6
DIFF: 
https://github.com/llvm/llvm-project/commit/7e17e15c9f01a04283524c6a6735d639aac39fe6.diff

LOG: clang: Introduce -fexperimental-max-bitint-width

This splits of the introduction of -fexperimental-max-bitint-width
from https://reviews.llvm.org/D122234
because that PR is still blocked on discussions on the backend side.

I was asked [0] to upstream at least the flag.

[0] 
https://github.com/llvm/llvm-project/commit/09854f2af3b914b616f29cb640bede3a27cf7c4e#commitcomment-75116619

Differential Revision: https://reviews.llvm.org/D127287

Added: 
clang/test/Sema/large-bit-int.c

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/Driver/Options.td
clang/lib/Basic/TargetInfo.cpp
clang/lib/Serialization/ASTReader.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1b1649ac09c87..1ead55633a093 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -291,6 +291,11 @@ New Compiler Flags
   ``-mfix-cortex-a72-aes-1655431``. The pass is enabled when using either of
   these cpus with ``-mcpu=`` and can be disabled using
   ``-mno-fix-cortex-a57-aes-1742098`` or ``-mno-fix-cortex-a72-aes-1655431``.
+- Added the ``-fexperimental-max-bitint-width=`` option to increase the maximum
+  allowed bit width of ``_BitInt`` types beyond the default of 128 bits. Some
+  operations, such as division or float-to-integer conversion, on ``_BitInt``
+  types with more than 128 bits currently crash clang. This option will be
+  removed in the future once clang supports all such operations.
 
 Deprecated Compiler Flags
 -

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 9c4d639178145..af6ff6292256e 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -446,6 +446,11 @@ ENUM_LANGOPT(ExtendIntArgs, ExtendArgsKind, 1, 
ExtendArgsKind::ExtendTo32,
 
 VALUE_LANGOPT(FuchsiaAPILevel, 32, 0, "Fuchsia API level")
 
+// This option will be removed in the future once the backend
+// supports all operations (like division or float-to-integer conversion)
+// on large _BitInts.
+BENIGN_VALUE_LANGOPT(MaxBitIntWidth, 32, 128, "Maximum width of a _BitInt")
+
 #undef LANGOPT
 #undef COMPATIBLE_LANGOPT
 #undef BENIGN_LANGOPT

diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index e4b5f0b751c48..5877123dab249 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -31,6 +31,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/Frontend/OpenMP/OMPGridValues.h"
+#include "llvm/IR/DerivedTypes.h"
 #include "llvm/Support/DataTypes.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/VersionTuple.h"
@@ -235,6 +236,8 @@ class TargetInfo : public virtual TransferrableTargetInfo,
 
   unsigned MaxOpenCLWorkGroupSize;
 
+  Optional MaxBitIntWidth;
+
   Optional DarwinTargetVariantTriple;
 
   // TargetInfo Constructor.  Default initializes all fields.
@@ -595,11 +598,16 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   // Different targets may support a 
diff erent maximum width for the _BitInt
   // type, depending on what operations are supported.
   virtual size_t getMaxBitIntWidth() const {
+// Consider -fexperimental-max-bitint-width= first.
+if (MaxBitIntWidth)
+  return std::min(*MaxBitIntWidth, 
llvm::IntegerType::MAX_INT_BITS);
+
 // FIXME: this value should be llvm::IntegerType::MAX_INT_BITS, which is
 // maximum bit width that LLVM claims its IR can support. However, most
-// backends currently have a bug where they only support division
-// operations on types that are <= 128 bits and crash otherwise. We're
-// setting the max supported value to 128 to be conservative.
+// backends currently have a bug where they only support float to int
+// conversion (and vice versa) on types that are <= 128 bits and crash
+// otherwise. We're setting the max supported value to 128 to be
+// conservative.
 return 128;
   }
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index de3cd2ded8bef..6707714f170b3 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6093,6 +6093,12 @@ def fobjc_gc_only : Flag<["-"], "fobjc-gc-only">, 
Group,
 def fobjc_gc : Flag<["-"], "fobjc-gc">, Group,
   HelpText<"Enable Objective-C garbage collection">;
 
+def fexperimental_max_bitint_width_EQ:
+  Joined<["

[llvm-branch-commits] [llvm] d4cb47d - Move ExpandLargeDivRem to llvm/test/CodeGen/X86 because they need a triple

2022-09-13 Thread Matthias Gehre via llvm-branch-commits

Author: Matthias Gehre
Date: 2022-09-13T08:29:24+01:00
New Revision: d4cb47d2ab8d030c4313bbdbcf995b8faa279c28

URL: 
https://github.com/llvm/llvm-project/commit/d4cb47d2ab8d030c4313bbdbcf995b8faa279c28
DIFF: 
https://github.com/llvm/llvm-project/commit/d4cb47d2ab8d030c4313bbdbcf995b8faa279c28.diff

LOG: Move ExpandLargeDivRem to llvm/test/CodeGen/X86 because they need a triple

Added: 
llvm/test/CodeGen/X86/expand-large-div-rem-sdiv129.ll
llvm/test/CodeGen/X86/expand-large-div-rem-srem129.ll
llvm/test/CodeGen/X86/expand-large-div-rem-udiv129.ll
llvm/test/CodeGen/X86/expand-large-div-rem-urem129.ll

Modified: 


Removed: 
llvm/test/Transforms/ExpandLargeDivRem/sdiv129.ll
llvm/test/Transforms/ExpandLargeDivRem/srem129.ll
llvm/test/Transforms/ExpandLargeDivRem/udiv129.ll
llvm/test/Transforms/ExpandLargeDivRem/urem129.ll



diff  --git a/llvm/test/Transforms/ExpandLargeDivRem/sdiv129.ll 
b/llvm/test/CodeGen/X86/expand-large-div-rem-sdiv129.ll
similarity index 100%
rename from llvm/test/Transforms/ExpandLargeDivRem/sdiv129.ll
rename to llvm/test/CodeGen/X86/expand-large-div-rem-sdiv129.ll

diff  --git a/llvm/test/Transforms/ExpandLargeDivRem/srem129.ll 
b/llvm/test/CodeGen/X86/expand-large-div-rem-srem129.ll
similarity index 100%
rename from llvm/test/Transforms/ExpandLargeDivRem/srem129.ll
rename to llvm/test/CodeGen/X86/expand-large-div-rem-srem129.ll

diff  --git a/llvm/test/Transforms/ExpandLargeDivRem/udiv129.ll 
b/llvm/test/CodeGen/X86/expand-large-div-rem-udiv129.ll
similarity index 100%
rename from llvm/test/Transforms/ExpandLargeDivRem/udiv129.ll
rename to llvm/test/CodeGen/X86/expand-large-div-rem-udiv129.ll

diff  --git a/llvm/test/Transforms/ExpandLargeDivRem/urem129.ll 
b/llvm/test/CodeGen/X86/expand-large-div-rem-urem129.ll
similarity index 100%
rename from llvm/test/Transforms/ExpandLargeDivRem/urem129.ll
rename to llvm/test/CodeGen/X86/expand-large-div-rem-urem129.ll



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 79060d2 - [LifetimeAnalysis] Add [[gsl::Pointer]] to llvm::StringRef

2020-04-15 Thread Matthias Gehre via llvm-branch-commits

Author: Matthias Gehre
Date: 2020-04-16T00:08:41+02:00
New Revision: 79060d2ea122a28f595e719432fbafa18f3b9eb9

URL: 
https://github.com/llvm/llvm-project/commit/79060d2ea122a28f595e719432fbafa18f3b9eb9
DIFF: 
https://github.com/llvm/llvm-project/commit/79060d2ea122a28f595e719432fbafa18f3b9eb9.diff

LOG: [LifetimeAnalysis] Add [[gsl::Pointer]] to llvm::StringRef

Summary:
This detected the bugs fixed in
  https://reviews.llvm.org/D66442
and
  https://reviews.llvm.org/D66440

The warning itself was implemented in
  https://reviews.llvm.org/D63954
  https://reviews.llvm.org/D64256
  https://reviews.llvm.org/D65120
  https://reviews.llvm.org/D65127
  https://reviews.llvm.org/D66152

Reviewers: zturner, mehdi_amini, gribozavr

Subscribers: dexonsmith, Szelethus, xazax.hun, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D66443

Added: 


Modified: 
llvm/include/llvm/ADT/StringRef.h

Removed: 




diff  --git a/llvm/include/llvm/ADT/StringRef.h 
b/llvm/include/llvm/ADT/StringRef.h
index ad31517a1ea7..337efd641135 100644
--- a/llvm/include/llvm/ADT/StringRef.h
+++ b/llvm/include/llvm/ADT/StringRef.h
@@ -54,7 +54,7 @@ namespace llvm {
   /// situations where the character data resides in some other buffer, whose
   /// lifetime extends past that of the StringRef. For this reason, it is not 
in
   /// general safe to store a StringRef.
-  class StringRef {
+  class [[gsl::Pointer]] StringRef {
   public:
 static const size_t npos = ~size_t(0);
 



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits