aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic
AgeCommit message (Collapse)AuthorFilesLines
3 days[WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (#150201)Hood Chatham2-0/+17
Tests if the runtime type of the function pointer matches the static type. If this returns false, calling the function pointer will trap. Uses `@llvm.wasm.ref.test.func` added in #147486. Also adds a "gc" wasm feature to gate the use of the ref.test instruction.
3 daysRevert "fix: replace report_fatal_error with Diags and exit" (#150662)Aaron Ballman3-15/+19
Reverts llvm/llvm-project#147959
3 daysfix: replace report_fatal_error with Diags and exit (#147959)woruyu3-19/+15
report_fatal_error is not a good way to report diagnostics to the users, so this switches to using actual diagnostic reporting mechanisms instead. Fixes #147187
5 days[NFC][Clang][FMV] Make FMV priority data type future proof. (#150079)Alexandros Lamprineas6-12/+14
FMV priority is the returned value of a polymorphic function. On RISC-V and X86 targets a 32-bit value is enough. On AArch64 we currently need 64 bits and we will soon exceed that. APInt seems to be a suitable replacement for uint64_t, presumably with minimal compile time overhead. It allows bit manipulation, comparison and variable bit width.
5 days[clang] Set correct CXXABI for UEFI (#150115)Prabhu Rajasekaran1-1/+1
The target triple x86_64-uefi must be assumed to have Microsft ABI by default. Fixes: https://github.com/llvm/llvm-project/issues/150113
6 daysAdding Loongarch64 to OpenBSD parts (#149737)Slava "nerfur" Voronzoff2-0/+4
Adding Loongarch64 to OpenBSD parts
6 days[Clang][ARM] Fix __ARM_FEATURE_LDREX on Armv8-M (#149538)Simon Tatham1-1/+3
The Armv8-M architecture doesn't have the LDREXD and STREXD instructions, for exclusive load/store of a 64-bit quantity split across two registers. But the `__ARM_FEATURE_LDREX` macro was set to a value that claims it does, because the case for Armv8 was missing a check for M profile. The Armv7 case got it right, so I've just made the two cases the same.
7 days[Mips] Correctly define IntPtrType (#145158)Hervé Poussineau1-3/+3
Mips was the only architecture having PtrDiffType = SignedInt and IntPtrType = SignedLong This fixes a problem on mipsel-windows-gnu triple, where uintptr_t was wrongly defined as unsigned long instead of unsigned int, leading to problems in compiler-rt. compiler-rt/lib/interception/interception_type_test.cpp:24:17: error: static assertion failed due to requirement '__sanitizer::is_same<unsigned long, unsigned int>::value': 24 | COMPILER_CHECK((__sanitizer::is_same<__sanitizer::uptr, ::uintptr_t>::value)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compiler-rt/lib/interception/../sanitizer_common/sanitizer_internal_defs.h:369:44: note: expanded from macro 'COMPILER_CHECK' 369 | #define COMPILER_CHECK(pred) static_assert(pred, "") | ^~~~ compiler-rt/lib/interception/interception_type_test.cpp:25:17: error: static assertion failed due to requirement '__sanitizer::is_same<long, int>::value': 25 | COMPILER_CHECK((__sanitizer::is_same<__sanitizer::sptr, ::intptr_t>::value)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compiler-rt/lib/interception/../sanitizer_common/sanitizer_internal_defs.h:369:44: note: expanded from macro 'COMPILER_CHECK' 369 | #define COMPILER_CHECK(pred) static_assert(pred, "") | ^~~~ compiler-rt/lib/interception/interception_type_test.cpp:27:17: error: static assertion failed due to requirement '__sanitizer::is_same<long, int>::value': 27 | COMPILER_CHECK((__sanitizer::is_same<::PTRDIFF_T, ::ptrdiff_t>::value)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compiler-rt/lib/interception/../sanitizer_common/sanitizer_internal_defs.h:369:44: note: expanded from macro 'COMPILER_CHECK' 369 | #define COMPILER_CHECK(pred) static_assert(pred, "")
11 days[SPIR] Set MaxAtomicInlineWidth minimum size to 32 for spir32 and 64 for ↵Wenju He1-0/+6
spir64 (#148997) Set MaxAtomicInlineWidth the same way as SPIR-V targets in 3cfd0c0d3697. This PR fixes build warning in scoped atomic built-in in #146814: `warning: large atomic operation may incur significant performance penalty; ; the access size (2 bytes) exceeds the max lock-free size (0 bytes) [-Watomic-alignment]`
13 days[clang][NFC] Updated incorrect llvm-unreachable message in ↵David Pagan1-1/+1
getOpenMPSimpleClauseType() (#148056)
13 days[clang][modules] Serialize `CodeGenOptions` (#146422)Jan Svoboda1-3/+3
Some `LangOptions` duplicate their `CodeGenOptions` counterparts. My understanding is that this was done solely because some infrastructure (like preprocessor initialization, serialization, module compatibility checks, etc.) were only possible/convenient for `LangOptions`. This PR implements the missing support for `CodeGenOptions`, which makes it possible to remove some duplicate `LangOptions` fields and simplify the logic. Motivated by https://github.com/llvm/llvm-project/pull/146342.
13 daysRemove Native Client support (#133661)Brad Smith6-182/+0
Remove the Native Client support now that it has finally reached end of life.
2025-07-12Revert "[Clang] [Diagnostics] Simplify filenames that contain '..'" (#148367)Sirraide1-72/+0
Revert llvm/llvm-project#143520 for now since it’s causing issues for people who are using symlinks and prefer to preserve the original path (i.e. looks like we’ll have to make this configurable after all; I just need to figure out how to pass `-no-canonical-prefixes` down through the driver); I’m planning to refactor this a bit and reland it in a few days.
2025-07-09[Clang] Respect MS layout attributes during CUDA/HIP device compilation ↵Yaxun (Sam) Liu10-23/+41
(#146620) This patch fixes an issue where Microsoft-specific layout attributes, such as __declspec(empty_bases), were ignored during CUDA/HIP device compilation on a Windows host. This caused a critical memory layout mismatch between host and device objects, breaking libraries that rely on these attributes for ABI compatibility. The fix introduces a centralized hasMicrosoftRecordLayout() check within the TargetInfo class. This check is aware of the auxiliary (host) target and is set during TargetInfo::adjust if the host uses a Microsoft ABI. The empty_bases, layout_version, and msvc::no_unique_address attributes now use this centralized flag, ensuring device code respects them and maintains layout consistency with the host. Fixes: https://github.com/llvm/llvm-project/issues/146047
2025-07-08[AMDGPU][Clang] Support bfloat16 arithmetic. (#147541)Ivan Kosarev1-0/+1
Co-authored-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2025-07-08[Clang] include attribute scope in diagnostics (#144619)Oleksandr T.1-0/+1
This patch updates diagnostics to print fully qualified attribute names, including scope when present.
2025-07-08[Clang][Wasm] Set __float128 alignment to 64 for emscripten (#146494)Nikita Popov1-0/+1
https://reviews.llvm.org/D104808 set the alignment of long double to 64 bits. This is also the alignment specified in the LLVM data layout. However, the alignment of __float128 was left at 128 bits. I assume that this was just an oversight, rather than an intentional divergence. The C ABI document currently does not make any statement about `__float128`: https://github.com/WebAssembly/tool-conventions/blob/main/BasicCABI.md
2025-07-08[Clang] [Diagnostics] Simplify filenames that contain '..' (#143520)Sirraide1-0/+72
This can significantly shorten file paths to standard library headers, e.g. on my system, `<ranges>` is currently printed as ```console /usr/lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/ranges ``` but with this change, we instead print ```console /usr/include/c++/15/ranges ``` This is of course just a heuristic; there are paths that would get longer as a result of this, so we use whichever path ends up being shorter. @AaronBallman pointed out that this might be problematic for network file systems since path resolution might take a while, so this is enabled only for paths that are part of a local filesystem—though not on Windows since there we noticed that the check itself is slow. The file names are cached in `SourceManager`.
2025-07-07[clang] Refactor `CodeGenOptions` to specify compatibility as X macro arg ↵Jan Svoboda1-26/+22
(#146910) This is the `CodeGenOptions` counterpart to https://github.com/llvm/llvm-project/pull/146766.
2025-07-07[clang] Refactor `LangOptions` to specify compatibility as X macro arg (#146766)Jan Svoboda1-6/+9
This removes the `{BENIGN,COMPATIBLE}{,_ENUM,_VALUE}_LANGOPT` X macros controlling `LangOptions`. These are permutations of the base `LANGOPT`, `ENUM_LANGOPT` and `VALUE_LANGOPT` X macros that also carry the information of their effect on AST (and therefore module compatibility). Their functionality is now implemented by passing `Benign`, `Compatible` or `NotCompatible` argument to the base X macros and using C++17 `if constexpr` in the clients to achieve the same codegen. This PR solves this FIXME: ``` // FIXME: Clients should be able to more easily select whether they want // different levels of compatibility versus how to handle different kinds // of option. ``` The base X macros are preserved, since they are used in `LangOptions.h` to generate different kinds of field and function declarations for flags, values and enums, which can't be achieved with `if constexpr`. The new syntax also forces developers to think about compatibility when adding new language option, hopefully reducing the number of new options that are affecting by default even though they are benign or compatible. Note that the `BENIGN_` macros used to forward to their `COMPATIBLE_` counterparts. I don't think this ever kicked in, since there are no clients of the `.def` file that define `COMPATIBLE_` without also defining `BENIGN_`. However, this might be something downstream forks need to take care of by doing `if constexpr (CK::Compatibility == CK::Benign || CK::Compatibility == CK::Compatible)` in place of `#define COMPATIBLE_`.
2025-07-07NFC, use structured binding to simplify the code in SourceManager.cpp.Haojian Wu1-6/+3
2025-07-07[clang] NFC, use LocalLocOffsetTable in getFIleIDLocal.Haojian Wu1-6/+6
2025-07-07[clang] Speedup getFileIDLocal with a separate offset table. (#146604)Haojian Wu1-7/+9
The `SLocEntry` structure is 24 bytes, and the binary search only needs the offset. Loading an entry's offset might pull the entire SLocEntry object into the CPU cache. To make the binary search much more cache-efficient, we use a separate offset table. See https://llvm-compile-time-tracker.com/compare.php?from=650d0151c623c123e4e9736fe50421624a329260&to=6af564c0d75aff28a2784a8554448c0679877792&stat=instructions:u.
2025-07-04[clang] SourceManager: Cache offsets for LastFileIDLookup to speed up ↵Haojian Wu1-9/+18
getFileID (#146782) `getFileID` is a hot method. By caching the offset range in `LastFileIDLookup`, we can more quickly check whether a given offset falls within it, avoiding calling `isOffsetInFileID`. https://llvm-compile-time-tracker.com/compare.php?from=0588e8188c647460b641b09467fe6b13a8d510d5&to=64843a500f0191b79a8109da9acd7e80d961c7a3&stat=instructions:u
2025-07-03[AArch64] Add option -msve-streaming-vector-bits= . (#144611)Eli Friedman4-8/+28
This is similar to -msve-vector-bits, but for streaming mode: it constrains the legal values of "vscale", allowing optimizations based on that constraint. This also fixes conversions between SVE vectors and fixed-width vectors in streaming functions with -msve-vector-bits and -msve-streaming-vector-bits. This rejects any use of arm_sve_vector_bits types in streaming functions; if it becomes relevant, we could add arm_sve_streaming_vector_bits types in the future. This doesn't touch the __ARM_FEATURE_SVE_BITS define.
2025-07-03[Sema][ObjC] Treat unknown selector messages as unrecoverable errors under ↵Akira Hatanaka1-2/+6
ARC (#146803) Fixes a CodeGen crash observed when C++ auto variable types remained non-deduced due to a message being sent with an unknown selector under ARC. By treating these instances as an unrecoverable error, we prevent the compiler from proceeding to CodeGen with fundamentally incorrect code. rdar://144394403
2025-07-02Remove helper function and use target agnostic needConversion function (#146680)Abhina Sree1-13/+4
This patch adds back the needed AutoConvert.h header and removes the unneeded include guard of MVS to prevent this header from being removed in the future
2025-07-01[clang] Improve getFileIDLocal binary search. (#146510)Haojian Wu1-25/+16
Avoid reading the `LocalSLocEntryTable` twice per loop iteration. NFC. https://llvm-compile-time-tracker.com/compare.php?from=0b6ddb02efdcbdac9426e8d857499ea0580303cd&to=1aa335ccfb07ba96177b89b1933aa6b980fa14f6&stat=instructions:u
2025-07-01[Clang] Remove AArch64TargetInfo::setArchFeatures (#146107)Sander de Smalen2-76/+0
When compiling with `-march=armv9-a+nosve` we found that Clang still defines the `__ARM_FEATURE_SVE2` macro, which is explicitly set in `setArchFeatures` when compiling for armv9-a. After some experimenting, I found out that the list of features passed into `AArch64TargetInfo::handleTargetFeatures` has already been expanded and takes into account `+no[feature]` and has already expanded features like `armv9-a`. From that I conclude that `setArchFeatures` is no longer required.
2025-07-01[Clang] Partially fix m68k alignments (#144740)Nikita Popov1-0/+1
As the data layout a few lines further up specifies, the int, long and pointer alignment should be 16 instead of the default of 32. The long long alignment is also incorrect, but that would require a change to the data layout as well. Comparison with GCC, which consistently uses 2 byte alignment: https://gcc.godbolt.org/z/K3x6a7dEf At least based on some spot checks, the changes to bit field layout also make use match GCC now. This was found by https://github.com/llvm/llvm-project/pull/144720.
2025-07-01[Clang][LoongArch] Fixed incorrect _BitInt(N>64) alignment (#145297)Ami-zhang1-0/+1
This patch makes determining alignment and width of BitInt to be target ABI specific and makes it consistent with [Procedure Call Standard for the LoongArch™ Architecture] for LoongArch target (https://github.com/loongson/la-abi-specs/blob/release/lapcs.adoc).
2025-06-28[clang] Remove unused includes (NFC) (#146254)Kazu Hirata1-1/+0
These are identified by misc-include-cleaner. I've filtered out those that break builds. Also, I'm staying away from llvm-config.h, config.h, and Compiler.h, which likely cause platform- or compiler-specific build failures.
2025-06-28[Clang][LoongArch] Match GCC behaviour when parsing FPRs in asm clobbers ↵Yao Zi1-32/+40
(#138391) There're four possible formats to refer a register in inline assembly, 1. Numeric name without dollar sign ("f0") 2. Numeric name with dollar sign ("$f0") 3. ABI name without dollar sign ("fa0") 4. ABI name with dollar sign ("$fa0") LoongArch GCC accepts 1 and 2 for FPRs before r15-8284[1] and all these formats after the chagne. But Clang supports only 2 and 4 for FPRs. The inconsistency has caused compatibility issues, such as QEMU's case[2]. This patch follows 0bbf3ddf5fea ("[Clang][LoongArch] Add GPR alias handling without `$` prefix") and accepts FPRs without dollar sign prefixes as well to keep aligned with GCC, avoiding future compatibility problems. Link: https://gcc.gnu.org/cgit/gcc/commit/?id=d0110185eb78f14a8e485f410bee237c9c71548d [1] Link: https://lore.kernel.org/qemu-devel/20250314033150.53268-3-ziyao@disroot.org/ [2]
2025-06-27[Basic] Use StringRef::drop_back (NFC) (#146195)Kazu Hirata1-1/+1
2025-06-27Revert "[Hexagon] NFC: Reduce the amount of version-specific code" (#146193)Brian Cain2-18/+28
Reverts llvm/llvm-project#145812
2025-06-27[Hexagon] NFC: Reduce the amount of version-specific code (#145812)Alexey Karyakin2-28/+18
There is a lot of redundant code that needs to be modified when new Hexagon versions are added. Reduce the amount of this redundancy. - compute ELF flags and attributes based on version feature names; - simplify EnableHVX option handling by using arch features instead of arch version enums; - simplify completeHVXFeatures() by using features; - delete several unused or redundant functions and constants: isCPUValid, getCpu, getHexagonCPUSuffix; - do not set HexagonArchVersion in initializeSubtargetDependencies, it is set in ParseSubtargetFeatures; Signed-off-by: Alexey Karyakin <akaryaki@quicinc.com>
2025-06-26[SystemZ][zOS] disable _Float16 support on z/OS (#145532)Sean Perry1-2/+2
The new half float type (aka _Float16 ) isn't supported on z/OS.
2025-06-26[sanitizers] do not accept out of bounds -fsanitize-skip-hot-cutoff (#145806)Florian Mayer1-2/+1
If the user gives an out of bounds value, it is best to fail and let the user decide what to do.
2025-06-26[clang] Use llvm::is_contained instead of llvm::all_of (NFC) (#145843)Kazu Hirata1-4/+2
llvm::is_contained is shorter than llvm::all_of plus a lambda.
2025-06-26[clang] NFC: Add alias for std::pair<FileID, unsigned> used in ↵Haojian Wu4-40/+34
SourceLocation (#145711) Introduce a type alias for the commonly used `std::pair<FileID, unsigned>` to improve code readability, and make it easier for future updates (64-bit source locations).
2025-06-25[PowerPC] Support for Packed BCD conversion builtins (#142723)Himadhith1-0/+6
Support the following packed BCD builtins for PowerPC. ``` __builtin_national2packed - Conversion of National format to Packed decimal format. __builtin_packed2national - Conversion of Packed decimal format to national format. __builtin_packed2zoned - Conversion of Packed decimal format to Zoned decimal format. __builtin_zoned2packed - Conversion of Zoned decimal format to Packed decimal format. ``` ### Prototypes: `vector unsigned char __builtin_national2packed(vector unsigned char a, unsigned char b);` `vector unsigned char __builtin_packed2zoned(vector unsigned char, unsigned char);` `vector unsigned char __builtin_zoned2packed(vector unsigned char, unsigned char);` The condition for the 2nd parameter is consistent over all the 3 prototypes (0 or 1 only). `vector unsigned char __builtin_packed2national(vector unsigned char);` Co-authored-by: himadhith <himadhith.v@ibm.com> Co-authored-by: Tony Varghese <tonypalampalliyil@gmail.com>
2025-06-24[OpenMP][clang] 6.0: parsing/sema for num_threads 'strict' modifier (#145490)Robert Imschweiler1-2/+19
Implement parsing and semantic analysis support for the optional 'strict' modifier of the num_threads clause. This modifier has been introduced in OpenMP 6.0, section 12.1.2. Note: this is basically 1:1 https://reviews.llvm.org/D138328.
2025-06-20[clang] Add managarm support (#144791)no922-0/+39
This is a repost of the quickly reverted #139271. The failing buildbot tests have been fixed and pass on my machine now.
2025-06-19[clang] Migrate away from ArrayRef(std::nullopt) (NFC) (#144982)Kazu Hirata1-1/+1
ArrayRef has a constructor that accepts std::nullopt. This constructor dates back to the days when we still had llvm::Optional. Since the use of std::nullopt outside the context of std::optional is kind of abuse and not intuitive to new comers, I would like to move away from the constructor and eventually remove it. This patch takes care of the clang side of the migration.
2025-06-19[AMDGPU] Initial support for gfx1250 target. (#144965)Stanislav Mekhanoshin2-0/+2
This is just a stub for now.
2025-06-19[Reland] [PowerPC] frontend get target feature from backend with cpu name ↵zhijian lin1-141/+7
(#144594) 1. The PR proceeds with a backend target hook to allow front-ends to determine what target features are available in a compilation based on the CPU name. 2. Fix a backend target feature bug that supports HTM for Power8/9/10/11. However, HTM is only supported on Power8/9 according to the ISA. 3. All target features that are hardcoded in PPC.cpp can be retrieved from the backend target feature. I have double-checked that the hardcoded logic for inferring target features from the CPU in the frontend(PPC.cpp) is the same as in PPC.td. The reland patch addressed the comment https://github.com/llvm/llvm-project/pull/137670#discussion_r2143541120
2025-06-17Revert "[clang] Add managarm support" (#144514)Aaron Ballman2-39/+0
Reverts llvm/llvm-project#139271 There are multiple failing build bots: https://lab.llvm.org/buildbot/#/builders/10/builds/7482 https://lab.llvm.org/buildbot/#/builders/11/builds/17473
2025-06-17[clang] Add managarm support (#139271)no922-0/+39
This PR is part of a series to upstream managarm support, as laid out in the [RFC](https://discourse.llvm.org/t/rfc-new-proposed-managarm-support-for-llvm-and-clang-87845/85884/1). This PR is a follow-up to #87845 and #138854.
2025-06-15[clang] Remove unused includes (NFC) (#144285)Kazu Hirata1-1/+0
These are identified by misc-include-cleaner. I've filtered out those that break builds. Also, I'm staying away from llvm-config.h, config.h, and Compiler.h, which likely cause platform- or compiler-specific build failures.
2025-06-15[clang] Use StringRef in range-based for loops (NFC) (#144242)Kazu Hirata1-2/+1
When we iterate over std::vector<std::string>, we can directly assign each element to StringRef. We do not need to go through separate statements.