5652 Commits

Author SHA1 Message Date
Joseph Huber
cb2f340850 [CUDA] Disable registering surfaces and textures with the new driver
Summary:
These runtime calls don't seem to be supported anymore, disable them for
now.
2024-01-18 10:56:33 -06:00
Joseph Huber
2b804f8755 [LinkerWrapper][Obvious] Fix move on temporary object
Summary:
This causes warnings because it is already a temporary and does not need
to be moved.
2024-01-18 10:42:13 -06:00
Joseph Huber
12c90bd612
[LinkerWrapper] Handle AMDGPU Target-IDs correctly when linking (#78359)
Summary:
The linker wrapper's job is to sort various embedded inputs into a list
of files that participate in a single link job. So far, this has been
completely 1-to-1, that is, each input file participates in exactly one
link job. However, support for AMD's target-id requires that one input
file may participate in multiple link jobs. For example, if given a
`gfx90a` static library and a `gfx90a:xnack+` object file input, we
should link the gfx90a` target into the `gfx90a:xnack+` job. These are
considered separate CPUs that can be mutually linked more or less.

This patch adds the necessary logic to make this happen. It primarily
reworks the logic to copy relevant input files into a separate list. So,
it moves construction of the final list of link jobs into the extraction
phase. We also need to copy the files in the case that it is needed more
than once, as the entire workflow expects ownership of said file.
2024-01-18 09:44:56 -06:00
cor3ntin
e90e43fb9c
[Clang][NFC] Rename CXXMethodDecl::isPure -> is VirtualPure (#78463)
To avoid any possible confusion with the notion of pure function and the
gnu::pure attribute.
2024-01-18 15:30:58 +01:00
Alexandre Ganea
2ce430ab2f [clang][tools] Silence const cast warning when building with Clang ToT
This fixes:
```
[4960/7446] Building C object tools\clang\tools\c-index-test\CMakeFiles\c-index-test.dir\c-index-test.c.obj
C:\git\llvm-project\clang\tools\c-index-test\c-index-test.c(49,19): warning: cast from 'const char *' to 'char *' drops const qualifier [-Wcast-qual]
   49 |     return((char*)path);
      |                   ^
C:\git\llvm-project\clang\tools\c-index-test\c-index-test.c(239,18): warning: cast from 'const char *' to 'char *' drops const qualifier [-Wcast-qual]
  239 |     free((char *)unsaved_files[i].Filename);
      |                  ^
C:\git\llvm-project\clang\tools\c-index-test\c-index-test.c(240,18): warning: cast from 'const char *' to 'char *' drops const qualifier [-Wcast-qual]
  240 |     free((char *)unsaved_files[i].Contents);
      |                  ^
```
2024-01-17 07:23:57 -05:00
Fabian Mora
9fa9d9a7e1
[llvm][frontend][offloading] Move clang-linker-wrapper/OffloadWrapper.* to llvm/Frontend/Offloading (#78057)
This patch moves `clang/tools/clang-linker-wrapper/OffloadWrapper.*` to
`llvm/Frontend/Offloading` allowing them to be re-utilized by other
projects.

Additionally, it makes minor modifications to the API to make it more
flexible.
Concretely:
 - The `wrap*` methods now have additional arguments `EntryArray`, 
`Suffix` and `EmitSurfacesAndTextures` to specify some additional options.
- The `EntryArray` is now constructed by the caller. This change is needed to
enable JIT compilation, as ORC doesn't fully support `__start_` and `__stop_` 
symbols. Thus, to JIT the code, the `EntryArray` has to be constructed explicitly in the IR.
- The `Suffix` field is used when emitting the descriptor, registration
methods, etc, to make them more readable. It is empty by default.
- The `EmitSurfacesAndTextures` field controls whether to emit surface
and texture registration code, as those functions were removed from `CUDART`
in CUDA 12. It is true by default.
- The function `getOffloadingEntryInitializer` was added to help create
the `EntryArray`, as it returns the constant initializer and not a global
variable.
2024-01-15 16:30:07 -05:00
Jie Fu (傅杰)
7851670709
[clang] SyntaxWarning: invalid escape sequence '\s' with Python3.12 (#78036)
llvm-project/clang/tools/libclang/linker-script-to-export-list.py:9: SyntaxWarning: invalid escape sequence '\s'
  m = re.search("^\s+(clang_[^;]+)", line)

Co-authored-by: cor3ntin <corentinjabot@gmail.com>
2024-01-14 18:13:54 +08:00
Kazu Hirata
eccd279979 [clang] Use SmallString::operator std::string() (NFC) 2024-01-12 18:39:49 -08:00
Alexandre Ganea
3c6f47d6b8
[llvm-driver] Fix usage of InitLLVM on Windows (#76306)
Previously, some tools such as `clang` or `lld` which require strict
order for certain command-line options, such as `clang -cc1` or `lld
-flavor`, would not longer work on Windows, when these tools were linked
as part of `llvm-driver`. This was caused by `InitLLVM` which was part
of the `*_main()` function of these tools, which in turn calls
`windows::GetCommandLineArguments`. That function completly replaces
argc/argv by new UTF-8 contents, so any ajustements to argc/argv made by
`llvm-driver` prior to calling these tools was reset.

`InitLLVM` is now called by the `llvm-driver`. Any tool that
participates in (or is part of) the `llvm-driver` doesn't call
`InitLLVM` anymore.
2024-01-11 19:08:28 -05:00
darkfeline
5b4abae763
[emacs] Fix Emacs library formatting (#76110)
This makes it easier to ship/install these using the builtin Emacs
package format (in particular, a Version is required).
2024-01-10 13:14:21 +01:00
Owen Pan
c69ec700ad [clang-format][NFC] Don't use clang-format style in config files
The current CI doesn't use the latest clang-format and fails most
clang-format patches on the code formatting check. This patch
temporarily removes the clang-format style from the .clang-format
files.
2024-01-10 00:58:35 -08:00
Owen Pan
b53628a52d Reland "[clang-format] Optimize processing .clang-format-ignore files"
(42ec976184ac was reverted by 26993f61673e due to a use-after-scope bug.)

Reuse the patterns governing the previous input file being formatted if
the current input file is from the same directory.
2024-01-09 21:34:21 -08:00
Brad Smith
49c35f69ac
[CMake] Add support for building on illumos (#74930)
illumos has an older version of the Solaris linker that does not
support the GNU version script compat nor version scripts and does
not support -Bsymbolic-functions. Treat illumos linker separately.

The libclang/CMakeLists part lifted from NetBSD's pkgsrc.

Build tested on Solaris 11.4 and OpenIndiana 2023.10.

/usr/bin/ld --version

ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.3260

ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.1790 (illumos)
2024-01-08 23:28:04 -05:00
Joseph Huber
5121e2cffd
[OpenMP] Change __tgt_device_image to point to the image (#77003)
Summary:
We use the OffloadBinary to contain bundled offloading objects used to
support many images / targets at the same time. The `__tgt_device_info`
struct used to contain a pointer to this underlying binary format, which
contains information about the triple and architecture. We used to parse
this in the runtime to do image verification.

Recent changes removed the need for this to be used internally, as we
just parse it out of the ELF directly. This patch sets the pointers up
so they point to the ELF without requiring any further parsing.
2024-01-05 14:29:34 -06:00
Mitch Phillips
26993f6167 Revert "[clang-format] Optimize processing .clang-format-ignore files (#76733)"
This reverts commit 42ec976184acd40436acd7104ad715c60ca3e7ed.

Reason: Broke the sanitizer buildbots. See more information on the
github comment thread at
42ec976184
2024-01-04 10:47:51 +01:00
Owen Pan
42ec976184
[clang-format] Optimize processing .clang-format-ignore files (#76733)
Reuse the patterns governing the previous input file being formatted if
the current input file is from the same directory.
2024-01-03 21:12:28 -08:00
Owen Pan
09308122c6
[clang-format] Add .clang-format-ignore for ignoring files (#76327)
Closes #52975.
2023-12-29 19:40:44 -08:00
Abhina Sree
d430c145ba
[CMake] Move check for dlfcn.h and dladdr to clang (#76163)
This patch checks for the presence of dlfcn.h and dladdr in clang to be used in clang/tools/libclang/CIndexer.cpp
2023-12-22 08:12:19 -05:00
Abhina Sree
e86a02ce89
Use llvm-config.h in CIndexer.cpp instead of private header (#75928)
Use llvm-config.h in CIndexer.cpp instead of private header
2023-12-20 08:44:40 -05:00
Fred Fu
35b366ace7
[ClangRepl] Reland Semanic Code Completion (#75556)
This patch contains changes from
002d471a4a3cd8b429e4ca7c84fd54a642e50e4c, in
addition to a bug fix that added a virtual destructor to
`CompletionContextHandler`

The original changes in the orginal commit piggybacks on clang's
semantic modules to enable semantic completion.  In particular, we use
`CodeCompletionContext` to differentiate two types of code completion.
We also
extract the relevant type information from it.
2023-12-19 22:53:02 +02:00
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