5432 Commits

Author SHA1 Message Date
Joseph Huber
8e2cc19e2e
[LinkerWrapper] Forward more arguments to the CPU offloading linker (#75757)
Summary:
The CPU target currently inherits all the libraries from the normal link
job to ensure that it has access to the same envrionment that the host
does. However, this previously was not respecting argument libraries
that are passed by name rather than `-l` as well as the whole archive
flags. This patch fixes this to allow the CPU linker to correctly pick
up the libraries associated with things like address sanitizers.

Fixes: https://github.com/llvm/llvm-project/issues/75651
2023-12-18 11:16:49 -06:00
Abhina Sree
8a233d8cfd
[SystemZ][z/OS] Add guard for dl_info and dladdr (#75637)
This patch fixes the following build error on z/OS `error: unknown type name 'Dl_info'` by adding a guard to check if we have dladdr.
2023-12-18 10:33:23 -05:00
fel-cab
b522675816
Revert "[LinkerWrapper] Add 'Freestanding' config to the LTO pass" (#75528)
This reverts commit 47d9fbc04b91fb03b6da294e82c2fb4bca6b6343.

It creates a segmentation falt on SPEChpc soma on Frontier on a GPU for
the kernel generate_new_beads

Co-authored-by: fel-cab <fel-cab@github.com>
2023-12-15 08:25:14 -06:00
Owen Pan
c3fa4b788f
[clang-format] Fix a bug in git-clang-format.bat (#75268)
Pass the fully-qualified path name (less the file extension) of
git-clang-format.bat to py so that it can be run from anywhere.

Fixes #75265.
2023-12-13 14:00:06 -08:00
Kazu Hirata
f3dcc2351c
[clang] Use StringRef::{starts,ends}_with (NFC) (#75149)
This patch replaces uses of StringRef::{starts,ends}with with
StringRef::{starts,ends}_with for consistency with
std::{string,string_view}::{starts,ends}_with in C++20.

I'm planning to deprecate and eventually remove
StringRef::{starts,ends}with.
2023-12-13 08:54:13 -08:00
Abhina Sree
ab380c287a
[SystemZ][z/OS] Complete EBCDIC I/O support (#75212)
This patch completes the support for EBCDIC I/O support on z/OS using the autoconversion functions.
2023-12-13 07:46:02 -05:00
Joseph Huber
ef23bba6e5 [Linkerwrapper] Make -Xoffload-linker pass directly to clang
Summary:
We provide `-Xoffload-linker` to pass arguments directly to the link
step. Currently this uses `-Wl,` implicitly which prevents us from using
clang options that we otherwise could make use of. This patch removes
that implicit behavior as users can just as easiliy pass
`-Xoffload-linker -Wl,-foo` if needed.
2023-12-11 07:56:19 -06:00
Jan Svoboda
0cb0a48cde
[clang] NFC: Remove OptionalFileEntryRefDegradesToFileEntryPtr (#74899) 2023-12-08 18:22:41 -08:00
Owen Pan
3791b3fca6
[clang-format][NFC] Clean up the driver and getStyle() in Format.cpp (#74794) 2023-12-08 15:23:01 -08:00
Joseph Huber
bfd41c3f8c [LinkerWrapper][Obvious] Fix missing use of texture data type
Summary:
This was accidentally linked to the wrong pointer, causing unused
variable warnings and registering the wrong thing.
2023-12-07 16:55:14 -06:00
Joseph Huber
97f3be2c5a
[CUDA][HIP] Improve variable registration with the new driver (#73177)
Summary:
This patch adds support for registering texture / surface variables from
CUDA / HIP. Additionally, we now properly track the `extern` and `const`
flags that are also used in these runtime functions.

This does not implement the `managed` variables yet as those seem to
require some extra handling I'm not familiar with. The issue is that the
current offload entry isn't large enough to carry size and alignment
information along with an extra global.
2023-12-07 15:44:23 -06:00
Aiden Grossman
aeaae5311b
[clang-format] Add "three dot" diff option to git-clang-format (#74230)
This patch adds in the ability to do a "three dot" git-clang-format
between two commits. This looks at the diff between the second commit
and the common merge base rather than comparing at the point of the
specified commits. This is needed to improve the reliability of the LLVM
code formatting CI action which currently breaks in some cases where
files have been modified in the upstream tree and when the person
created their branch, leaving phantom formatting diffs that weren't
touched by the PR author.

Part of a fix for #73873
2023-12-05 19:19:21 -08:00
Owen Pan
900bb318b5
[clang-format][NFC] Use prog in clang-format-diff.py (#74399)
This is a minor improvement to #73491.
2023-12-05 10:36:14 +00:00
Owen Pan
78940a4e1f
[clang-format] Fix a bug in git-clang-format --binary (#74293)
This is a rework of #74176, which erroneously changed the default
clang-format filename (`clang-format`, `clang-format.exe`, etc.) to an
absolute pathname. Instead, we should do that only if the name is a
pathname, e.g. `./clang-format`,
`llvm-project/build/bin/clang-format.exe`, etc. See also
https://github.com/llvm/llvm-project/pull/74176#issuecomment-1837921351.
2023-12-04 13:49:23 -08:00
Owen Pan
2a3f1195d6
[clang-format] Fix a bug in git-clang-format --binary (#74176)
Fixed #74165.
2023-12-03 02:07:07 -08:00
Brad Smith
37da4e3d80
[clang-fuzzer] Remove GCC 4.x pre GCC 4.9 workaround to silence warning (#73974)
The minimum GCC version was bumped up from 4.8 to 5.1 and then even newer
awhile ago so garbage collect the pre 4.9 workaround.

https://reviews.llvm.org/D66188
2023-12-02 05:15:30 -05:00
Owen Pan
5c60e2ce78 [clang-format][NFC] Reformat source code with clang-format style 2023-11-30 20:19:30 -08:00
Jacob Lambert
3cf190974a
[clang-offload-bundler] Add support for -check-input-archive (#73709)
In this patch, we add support for checking a heterogeneous archive. We
also significantly improve the clang-offload-bundler documentation.
2023-11-29 18:39:17 -08:00
Juergen Ributzka
21361bb860
[clang] Remove unused argument. NFC. (#73594) 2023-11-28 09:19:39 -08:00
serge-sans-paille
ced0f28a35
Improve clang-format-diff help output (#73491)
It is quite common to symlink clang-format-diff.py to clang-format-diff,
and in that case the help output still refers to the .py version.
Compute it instead to work in both setup.
2023-11-28 13:46:37 +00:00
Sunil Kuravinakop
d033f51a0a [OpenMP] atomic compare fail : Parser & AST support
Diff Revision: https://reviews.llvm.org/D123235
2023-11-26 13:34:34 -06:00
Youngsuk Kim
bc85284273
[clang-linker-wrapper] Re-use type returned from 'PointerType::getUnqual(C)' (NFC) (#73374)
Multiple calls to `PointerType::getUnqual(C)`, and calls to
`Type::getPointerTo(AddrSpace=0)` on them all result in the same type.

Clean them up to re-use the same `PtrTy` variable within function
`createRegisterGlobalsFunction()`.
2023-11-24 19:22:02 -05:00
Sebastian Poeplau
7091ca1ae3
[clang] Add missing LinkageSpec case to getCursorKindForDecl (#72401)
The LinkageSpec case was omitted, and there is a declared CXCursor_Kind
for it. Adapt the testsuite drivers to print mangled names for
declarations with extern linkage. Also update the test baseline for the
recursive-cxx-member-calls.cpp test.

Co-authored-by: Matthieu Eyraud <eyraud@adacore.com>
2023-11-24 21:41:17 +05:30
Fred Fu
9ebe6e28cd
Revert "[ClangRepl] Type Directed Code Completion" (#73259)
Reverts llvm/llvm-project#67349

There are some issues with the sanitizers. We will reland once that's fixed.
2023-11-23 21:07:51 +02:00
Fred Fu
002d471a4a
[ClangRepl] Type Directed Code Completion (#67349)
Differential Revision: https://reviews.llvm.org/D159128
2023-11-23 19:56:35 +02:00
Joseph Huber
b16f765d6f
[LinkerWrapper] Accept some needed lld-link linker arguments for COFF targets (#72889)
Summary:
The linker wrapper is a utility used to create offloading programs from
single-source offloading languages such as OpenMP or CUDA. This is done
by embedding device code into the host object, then feeding it into the
linker wrapper which extracts the accelerator object files, links them,
then wraps them in registration code for the target  runtime. This
previously has only worked in Linux / ELF platforms.

This patch attempts to hand Windows / COFF inputs by also accepting COFF
forms of certain linker arguments we use internally. The important
arguments are library search paths, so we can identify libraries which
may contain device code, libraries themselves, and the output name used
for intermediate output.

I am not intimately familiar with the semantics here for the semantics
in how a `lib` file is earched. I am simply treating `foo.lib` as the
GNU equivalent `-l:foo.lib` in the search logic. Similarly, I am
assuming that static libraries will be llvm-ar style libraries. I will
need to investigate the actual deficiencies later, but this should be a
good starting point along with
https://github.com/llvm/llvm-project/pull/72697
2023-11-22 20:23:23 -06:00
Krzysztof Parzyszek
ddfed815c9 Revert "[OpenMP] atomic compare fail : Parser & AST support"
This reverts commit edd675ac283909397880f85ba68d0d5f99dc1be2.

This breaks clang build where every component is a shared library.

The file clang/lib/Basic/OpenMPKinds.cpp, which is a part of
libclangBasic.so, uses `getOpenMPClauseName` which isn't:

/usr/bin/ld: CMakeFiles/obj.clangBasic.dir/OpenMPKinds.cpp.o: in functio
n `clang ::getOpenMPSimpleClauseTypeName(llvm::omp::Clause, unsigned int
)':
OpenMPKinds.cpp:(.text._ZN5clang29getOpenMPSimpleClauseTypeNameEN4llvm3o
mp6ClauseEj+0x9b): undefined reference to `llvm::omp::getOpenMPClauseNam
e(llvm::omp::Clause)'
2023-11-20 10:48:06 -06:00
Sunil Kuravinakop
edd675ac28 [OpenMP] atomic compare fail : Parser & AST support
Diff Revision: https://reviews.llvm.org/D123235
2023-11-20 03:05:31 -06:00
Joseph Huber
9c0e64999b
[Offloading][NFC] Refactor handling of offloading entries (#72544)
Summary:
This patch is a simple refactoring of code out of the linker wrapper
into a common location. The main motivation behind this change is to
make it easier to change the handling in the future to accept a triple
to be used to emit entries that function on that target.
2023-11-17 08:26:20 -06:00
Michael Spencer
731152e18f
[clang][DependencyScanner] Remove all warning flags when suppressing warnings (#71612)
Since system modules don't emit most warnings, remove the warning flags
to increase module reuse.
2023-11-13 16:45:38 -08:00
Conrad Donahue
68d618f908
[clang-format] Add ability for clang-format-diff to exit with non-0 status (#70883)
This patch adds the ability for the clang-format-diff script to exit
with a non-zero status if it detects that formatting changes are
necessary. This makes it easier to use clang-format-diff as part of a
DevOps pipeline, since you could add a stage to run clang-format-diff
and fail if the formatting needs to be fixed.
2023-11-08 18:13:03 -08:00
Mitch Phillips
a141a9fa97 Revert "[OpenMP] atomic compare fail : Parser & AST support"
This reverts commit 086b65340cca2648a2a91a0a47d28c7d9bafd1e5.

Reason: Broke under -Werror. More details in
https://reviews.llvm.org/D123235
2023-11-08 11:20:17 +01:00
Michael Spencer
fb07d9cc09
[clang][DepScan] Make OptimizeArgs a bit mask enum and enable by default (#71588)
Make it easier to control which optimizations are enabled by making
OptimizeArgs a bit masked enum. There's currently only one such
optimization, but more will be added in followup commits.
2023-11-07 16:06:59 -08:00
Sunil Kuravinakop
086b65340c [OpenMP] atomic compare fail : Parser & AST support
This is a support for " #pragma omp atomic compare fail ". It has Parser & AST support for now.

Reviewed By: tianshilei1992, ABataev

Differential Revision: https://reviews.llvm.org/D123235
2023-11-07 16:57:50 -06:00
Paulo Matos
7b9d73c2f9
[NFC] Remove Type::getInt8PtrTy (#71029)
Replace this with PointerType::getUnqual().
Followup to the opaque pointer transition. Fixes an in-code TODO item.
2023-11-07 17:26:26 +01:00
Vlad Serebrennikov
f2d8a0ac1d [clang][NFC] Refactor ParamCommandComment::PassDirection
This patch converts `ParamCommandComment::PassDirection` to a scoped enum at namespace scope, making it eligible for forward declaring. This is useful for e.g. annotating bit-fields with `preferred_type`.
2023-11-06 22:55:51 +03:00
Vlad Serebrennikov
565e21b3e0 [clang][NFC] Refactor InlineCommandComment::RenderKind
This patch converts `InlineCommandComment::RenderKind` to a scoped enum at namespace scope, making it eligible for forward declaring. This is useful for e.g. annotating bit-fields with `preferred_type`.
2023-11-06 22:39:26 +03:00
Vlad Serebrennikov
60f7fa123d [clang][NFC] Refactor Comment::CommentKind
This patch converts `Comment::CommentKind` into a scoped enum at namespace scope, making it eligible for forward declaring. This is useful for e.g. annotating bit-fields with `preferred_type`.
2023-11-06 22:17:03 +03:00
Vlad Serebrennikov
edd690b02e
[clang][NFC] Refactor TagTypeKind (#71160)
This patch converts TagTypeKind into scoped enum. Among other benefits,
this allows us to forward-declare it where necessary.
2023-11-03 21:45:39 +04:00
Vlad Serebrennikov
8775947633
[clang][NFC] Refactor clang::Linkage (#71049)
This patch introduces a new enumerator `Invalid = 0`, shifting other enumerators by +1. Contrary to how it might sound, this actually affirms status quo of how this enum is stored in `clang::Decl`:
```
  /// If 0, we have not computed the linkage of this declaration.
  /// Otherwise, it is the linkage + 1.
  mutable unsigned CacheValidAndLinkage : 3;
```
This patch makes debuggers to not be mistaken about enumerator stored in this bit-field. It also converts `clang::Linkage` to a scoped enum.
2023-11-02 20:57:29 +04:00
Joseph Huber
47d9fbc04b [LinkerWrapper] Add 'Freestanding' config to the LTO pass
Summary:
These GPU images are expected to be freestanding, so we should disable
emission of builtins for whatever target we are offloading to.
2023-11-01 07:47:25 -05:00
Vlad Serebrennikov
aaba3761db [clang][NFC] Refactor ObjCMethodDecl::ImplementationControl
This patch moves `ObjCMethodDecl::ImplementationControl` to a DeclBase.h so that it's complete at the point where corresponsing bit-field is declared. This patch also converts it to a scoped enum `clang::ObjCImplementationControl`.
2023-11-01 13:40:11 +03:00
Joseph Huber
9bdeab1e7b [LinkerWrapper][Obvious] Fix dangling stringref on Xcuda-ptxas options
Summary:
This accidentally was a dangling reference and caused issues when
actually used. Make sure that the memory is saved before the job is
created.
2023-10-25 10:42:34 -05:00
Chris B
7d7e4d20b0
[Windows] Add git-clang-format wrapper bat file (#69228)
This allows git-clang-format to be used on a Windows terminal without
manually needing to find the path and invoke the python interpreter. We
have a similar script for `scan-build`.

Fixes #69643
2023-10-21 08:14:29 -05:00
conversy
b081da5fab
clang-linker-wrapper/LinkerWrapperOpts.td: "--sysroot" => "--sysroot=" (#65313)
"--sysroot"
should be 
"--sysroot="

since it's related to
OPT_sysroot_EQ
and not a
OPT_sysroot
2023-10-20 22:31:58 +05:30
Min-Yih Hsu
fd4f96290a [Clang][M68k] Add Clang support for the new M68k_RTD CC
This patch adds `CC_M68kRTD`, which will be used on function if either
`__attribute__((m68k_rtd))` is presented or `-mrtd` flag is given.

Differential Revision: https://reviews.llvm.org/D149867
2023-10-15 16:13:43 -07:00
Kazu Hirata
ece5dd101c [clang] Stop including llvm/ADT/StringMap.h (NFC)
These source files do not use StringMap.h.
2023-10-13 21:34:23 -07:00
Krystian Stasiowski
3a3b84b180
[clang] remove ClassScopeFunctionSpecializationDecl (#66636)
This removes the `ClassScopeFunctionSpecializationDecl` `Decl` node, and
instead uses `DependentFunctionTemplateSpecializationInfo` to handle
such declarations. `DependentFunctionTemplateSpecializationInfo` is also
changed to store a `const ASTTemplateArgumentListInfo*` to be more in
line with `FunctionTemplateSpecializationInfo`.

This also changes `FunctionDecl::isFunctionTemplateSpecialization` to
return `true` for dependent specializations, and
`FunctionDecl::getTemplateSpecializationKind`/`FunctionDecl::getTemplateSpecializationKindForInstantiation`
to return `TSK_ExplicitSpecialization` for non-friend dependent
specializations (the same behavior as dependent class scope
`ClassTemplateSepcializationDecl` & `VarTemplateSepcializationDecl`).
2023-10-07 10:55:31 +04:00
Shilei Tian
d6254e1b2e Introduce the initial support for OpenMP kernel language (#66844)
This patch starts the support for OpenMP kernel language, basically to write
OpenMP target region in SIMT style, similar to kernel languages such as CUDA.
What included in this first patch is the `ompx_bare` clause for `target teams`
directive. When `ompx_bare` exists, globalization is disabled such that local
variables will not be globalized. The runtime init/deinit function calls will
not be emitted. That being said, almost all OpenMP executable directives are
not supported in the region, such as parallel, task. This patch doesn't include
the Sema checks for that, so the use of them is UB. Simple directives, such as
atomic, can be used. We provide a set of APIs (for C, they are prefix with
`ompx_`; for C++, they are in `ompx` namespace) to get thread id, block id, etc.
Please refer to
https://tianshilei.me/wp-content/uploads/llvm-hpc-2023.pdf for more details.
2023-10-05 17:38:06 -04:00
Yaxun (Sam) Liu
7e2823438e Reland "[HIP] Support compressing device binary"
Original PR: https://github.com/llvm/llvm-project/pull/67162

The commit was reverted due to UB detected by santizer:

https://lab.llvm.org/buildbot/#/builders/238/builds/5955

clang/lib/Driver/OffloadBundler.cpp:1012:25: runtime error:
 load of misaligned address 0xaaaae2d90e7c for type
 'const uint64_t' (aka 'const unsigned long'), which
 requires 8 byte alignment

It was fixed by using memcpy instead of dereferencing int*
casted from unaligned char*.
2023-10-05 11:20:46 -04:00