llvm with tablegen backend for capstone disassembler
Go to file
David Sherwood c1cfa1757c
[Clang] Emit TBAA info for enums in C (#73326)
When emitting TBAA information for enums in C code we currently just
treat the data as an 'omnipotent char'. However, with C strict aliasing
this means we fail to optimise certain cases. For example, in the
SPEC2017 xz benchmark there are structs that contain arrays of enums,
and clang pessmistically assumes that accesses to those enums could
alias with other struct members that have a different type.

According to

https://en.cppreference.com/w/c/language/enum

enums should be treated as 'int' types unless explicitly specified (C23)
or if 'int' would not be large enough to hold all the enumerated values.
In the latter case the compiler is free to choose a suitable integer
that would hold all such values.

When compiling C code this patch generates TBAA information for the enum
by using an equivalent integer of the size clang has already chosen for
the enum. I have ignored C++ for now because the rules are more complex.

New test added here:

  clang/test/CodeGen/tbaa.c
2023-12-08 12:58:39 +00:00
.ci [CI] Add check-mlir-python to MLIR pre-merge checks (#72847) 2023-11-25 09:55:32 +00:00
.github [SPIR-V] Add pre-commit CI workflow (#74092) 2023-12-07 09:42:30 -05:00
bolt [BOLT] [Passes] Fix two compile warnings in BOLT (#73086) 2023-12-06 11:19:07 -08:00
clang [Clang] Emit TBAA info for enums in C (#73326) 2023-12-08 12:58:39 +00:00
clang-tools-extra [clang-tidy] Add check hicpp-ignored-remove-result (#73119) 2023-12-07 20:55:17 +01:00
cmake [CMake] Switch the CMP0091 policy (MSVC_RUNTIME_LIBRARY) to the new behaviour 2023-07-17 09:59:05 +03:00
compiler-rt [ORC-RT][ORC][MachO] Fix some issues with executor-side symbol tables. 2023-12-07 14:38:51 -08:00
cross-project-tests [cross-project-tests] Fix struct-dse example so that it fails again (#73566) 2023-11-27 13:14:10 -08:00
flang [flang][CodeGen] add nsw to address calculations (#74709) 2023-12-08 10:51:20 +00:00
libc [libc] fix -Wshift-count-overflow in UInt.h (#74649) 2023-12-07 08:20:46 -08:00
libclc [LIBCLC] Teach prepare-builtins how to handle text based IR (#66993) 2023-10-03 14:28:01 +02:00
libcxx [libc++] tests with picolibc: handle stdin (#74712) 2023-12-07 09:29:00 -05:00
libcxxabi [libc++abi] Fix lpStart adjustment for exceptions table (#72727) 2023-12-06 20:54:21 -08:00
libunwind [libunwind][WebAssembly] Omit unused parts of libunwind.cpp for Wasm (#73196) 2023-11-29 18:03:58 -08:00
lld [AMDGPU][NFC] Improve testing for AMDHSA ABI Version (#74300) 2023-12-08 18:09:45 +05:30
lldb [lldb] Add missing nullptr checks when colouring symbol output 2023-12-08 11:24:07 +00:00
llvm [GlobalISel] Fix comment on buildIsFPClass 2023-12-08 12:41:22 +00:00
llvm-libgcc [llvm-libgcc][CMake] Refactor llvm-libgcc (#65455) 2023-09-18 22:56:03 -07:00
mlir [mlir] Add missing MLIR_ENABLE_EXECUTION_ENGINE option to MLIRConfig.cmake.in 2023-12-08 04:12:47 -08:00
openmp [OpenMP][Fix] Fix test initialization (#74801) 2023-12-07 22:20:32 -05:00
polly [polly][NFC] Refactor reduction detection code for modularity (#72343) 2023-12-07 14:04:52 -08:00
pstl Clear release notes for 18.x 2023-07-25 13:58:49 +02:00
runtimes [CMake] Always define runtimes-test-depends (#73629) 2023-11-28 15:30:52 -08:00
third-party [gtest] Disable new posix::FOpen Windows implementation for now 2023-09-28 21:11:09 +02:00
utils [mlir][SCF] Retire SCF-specific to_memref/to_tensor canonicalization patterns (#74551) 2023-12-07 08:24:17 +09:00
.arcconfig
.arclint
.clang-format
.clang-tidy Add -misc-use-anonymous-namespace to .clang-tidy 2023-05-06 02:33:20 +03:00
.git-blame-ignore-revs [git] Add _LIBCPP_INLINE_VISIBILITY renaming to .git-blame-ignore-revs file 2023-12-04 10:26:52 -05:00
.gitignore Revert accidental .gitignore change from 9b7763821a 2023-09-07 22:42:05 -07:00
.mailmap [mailmap] Add my entry 2023-12-07 10:26:36 +08:00
CODE_OF_CONDUCT.md [llvm] Add CODE_OF_CONDUCT.md (#65816) 2023-09-09 10:55:31 -07:00
CONTRIBUTING.md Update CONTRIBUTING.md to remove the not about not accepting PR 2023-09-10 15:21:06 -07:00
LICENSE.TXT [docs] Add LICENSE.txt to the root of the mono-repo 2022-08-24 09:35:00 +02:00
README.md Add Scorecard Action (#69933) 2023-11-01 11:08:26 -07:00
SECURITY.md

The LLVM Compiler Infrastructure

OpenSSF Scorecard

Welcome to the LLVM project!

This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.

The LLVM project has multiple components. The core of the project is itself called "LLVM". This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.

C-like languages use the Clang frontend. This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM.

Other components include: the libc++ C++ standard library, the LLD linker, and more.

Getting the Source Code and Building LLVM

Consult the Getting Started with LLVM page for information on building and running LLVM.

For information on how to contribute to the LLVM project, please take a look at the Contributing to LLVM guide.

Getting in touch

Join the LLVM Discourse forums, Discord chat, LLVM Office Hours or Regular sync-ups.

The LLVM project has adopted a code of conduct for participants to all modes of communication within the project.