#
846e562d |
| 25-Aug-2021 |
Nick Desaulniers <ndesaulniers@google.com> |
[Clang] add support for error+warning fn attrs
Add support for the GNU C style __attribute__((error(""))) and __attribute__((warning(""))). These attributes are meant to be put on declarations of fu
[Clang] add support for error+warning fn attrs
Add support for the GNU C style __attribute__((error(""))) and __attribute__((warning(""))). These attributes are meant to be put on declarations of functions whom should not be called.
They are frequently used to provide compile time diagnostics similar to _Static_assert, but which may rely on non-ICE conditions (ie. relying on compiler optimizations). This is also similar to diagnose_if function attribute, but can diagnose after optimizations have been run.
While users may instead simply call undefined functions in such cases to get a linkage failure from the linker, these provide a much more ergonomic and actionable diagnostic to users and do so at compile time rather than at link time. Users instead may be able use inline asm .err directives.
These are used throughout the Linux kernel in its implementation of BUILD_BUG and BUILD_BUG_ON macros. These macros generally cannot be converted to use _Static_assert because many of the parameters are not ICEs. The Linux kernel still needs to be modified to make use of these when building with Clang; I have a patch that does so I will send once this feature is landed.
To do so, we create a new IR level Function attribute, "dontcall" (both error and warning boil down to one IR Fn Attr). Then, similar to calls to inline asm, we attach a !srcloc Metadata node to call sites of such attributed callees.
The backend diagnoses these during instruction selection, while we still know that a call is a call (vs say a JMP that's a tail call) in an arch agnostic manner.
The frontend then reconstructs the SourceLocation from that Metadata, and determines whether to emit an error or warning based on the callee's attribute.
Link: https://bugs.llvm.org/show_bug.cgi?id=16428 Link: https://github.com/ClangBuiltLinux/linux/issues/1173
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D106030
show more ...
|
#
ea08c4cd |
| 20-Aug-2021 |
Jonas Hahnfeld <jonas.hahnfeld@cern.ch> |
[CUDA] Fix static device variables with -fgpu-rdc
NVPTX does not allow dots in the identifier, so ptxas errors out with fatal : Parsing error near '.static': syntax error because it parses .sta
[CUDA] Fix static device variables with -fgpu-rdc
NVPTX does not allow dots in the identifier, so ptxas errors out with fatal : Parsing error near '.static': syntax error because it parses .static as a directive. Avoid this problem by using two underscores, similar to what OpenMP does for outlined functions.
Differential Revision: https://reviews.llvm.org/D108456
show more ...
|
#
8da70fed |
| 04-Aug-2021 |
Andy Wingo <wingo@igalia.com> |
[clang][NFC] Tighten up code for GetGlobalVarAddressSpace
The LangAS local is only used in the OpenCL case; move its decl inwards.
Differential Revision: https://reviews.llvm.org/D108449
|
#
d3d4d985 |
| 04-Aug-2021 |
Andy Wingo <wingo@igalia.com> |
[clang][NFC] GetOrCreateLLVMGlobal takes LangAS
Pass a LangAS instead of a target address space to GetOrCreateLLVMGlobal, to remove a place where the frontend assumes that target address space 0 is
[clang][NFC] GetOrCreateLLVMGlobal takes LangAS
Pass a LangAS instead of a target address space to GetOrCreateLLVMGlobal, to remove a place where the frontend assumes that target address space 0 is special.
Differential Revision: https://reviews.llvm.org/D108445
show more ...
|
#
de0ae9e8 |
| 17-Aug-2021 |
Arthur Eubanks <aeubanks@google.com> |
[NFC] Cleanup more AttributeList::addAttribute()
|
#
ad727ab7 |
| 17-Aug-2021 |
Arthur Eubanks <aeubanks@google.com> |
[NFC] Migrate some callers away from Function/AttributeLists methods that take an index
These methods can be confusing.
|
#
46cf8253 |
| 16-Aug-2021 |
Arthur Eubanks <aeubanks@google.com> |
[NFC] Replace Function handling of attributes with less confusing calls
To avoid magic constants and confusing indexes.
|
#
8e9ffa1d |
| 13-Aug-2021 |
Arthur Eubanks <aeubanks@google.com> |
[NFC] Cleanup callers of AttributeList::hasAttributes()
AttributeList::hasAttributes() is confusing, use clearer methods like hasFnAttrs().
|
#
80ea2bb5 |
| 13-Aug-2021 |
Arthur Eubanks <aeubanks@google.com> |
[NFC] Rename AttributeList::getParam/Ret/FnAttributes() -> get*Attributes()
This is more consistent with similar methods.
|
#
6ec36d18 |
| 08-Aug-2021 |
Michael Liao <michael.hliao@gmail.com> |
[cuda] Mark builtin texture/surface reference variable as 'externally_initialized'.
- They need to be preserved even if there's no reference within the device code as the host code may need to ini
[cuda] Mark builtin texture/surface reference variable as 'externally_initialized'.
- They need to be preserved even if there's no reference within the device code as the host code may need to initialize them based on the application logic.
Reviewed By: tra
Differential Revision: https://reviews.llvm.org/D107718
show more ...
|
#
7df405e0 |
| 04-Aug-2021 |
Pavel Asyutchenko <sventeam@yandex.ru> |
Apply -fmacro-prefix-map to __builtin_FILE()
This matches the behavior of GCC. Patch does not change remapping logic itself, so adding one simple smoke test should be enough.
Reviewed By: MaskRay
Apply -fmacro-prefix-map to __builtin_FILE()
This matches the behavior of GCC. Patch does not change remapping logic itself, so adding one simple smoke test should be enough.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D107393
show more ...
|
#
44dbbe61 |
| 19-Jul-2021 |
Yaxun (Sam) Liu <yaxun.liu@amd.com> |
[HIP] Preserve ASAN bitcode library functions
Address sanitizer passes may generate call of ASAN bitcode library functions after bitcode linking in lld, therefore lld cannot add those symbols since
[HIP] Preserve ASAN bitcode library functions
Address sanitizer passes may generate call of ASAN bitcode library functions after bitcode linking in lld, therefore lld cannot add those symbols since it does not know they will be used later.
To solve this issue, clang emits a reference to a bicode library function which calls all ASAN functions which need to be preserved. This basically force all ASAN functions to be linked in.
Reviewed by: Artem Belevich
Differential Revision: https://reviews.llvm.org/D106315
show more ...
|
#
9ce02ea8 |
| 24-Jun-2021 |
Joseph Huber <jhuber6@vols.utk.edu> |
[OpenMP] Add Module metadata for OpenMP compilation
This patch adds a module level metadata flag indicating that the module was compiled with the `-fopenmp` flag. This will make it easier for passes
[OpenMP] Add Module metadata for OpenMP compilation
This patch adds a module level metadata flag indicating that the module was compiled with the `-fopenmp` flag. This will make it easier for passes like OpenMPOpt to determine if it should be run.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D102361
show more ...
|
#
8ace1213 |
| 21-Jun-2021 |
Nick Desaulniers <ndesaulniers@google.com> |
[IR] convert warn-stack-size from module flag to fn attr
Otherwise, this causes issues when building with LTO for object files that use different values.
Link: https://github.com/ClangBuiltLinux/li
[IR] convert warn-stack-size from module flag to fn attr
Otherwise, this causes issues when building with LTO for object files that use different values.
Link: https://github.com/ClangBuiltLinux/linux/issues/1395
Reviewed By: dblaikie, MaskRay
Differential Revision: https://reviews.llvm.org/D104342
show more ...
|
#
61cdaf66 |
| 11-Jun-2021 |
Simon Pilgrim <llvm-dev@redking.me.uk> |
[ADT] Remove APInt/APSInt toString() std::string variants
<string> is currently the highest impact header in a clang+llvm build:
https://commondatastorage.googleapis.com/chromium-browser-clang/llvm
[ADT] Remove APInt/APSInt toString() std::string variants
<string> is currently the highest impact header in a clang+llvm build:
https://commondatastorage.googleapis.com/chromium-browser-clang/llvm-include-analysis.html
One of the most common places this is being included is the APInt.h header, which needs it for an old toString() implementation that returns std::string - an inefficient method compared to the SmallString versions that it actually wraps.
This patch replaces these APInt/APSInt methods with a pair of llvm::toString() helpers inside StringExtras.h, adjusts users accordingly and removes the <string> from APInt.h - I was hoping that more of these users could be converted to use the SmallString methods, but it appears that most end up creating a std::string anyhow. I avoided trying to use the raw_ostream << operators as well as I didn't want to lose having the integer radix explicit in the code.
Differential Revision: https://reviews.llvm.org/D103888
show more ...
|
#
fc018ebb |
| 10-Jun-2021 |
Nick Desaulniers <ndesaulniers@google.com> |
[IR] make -warn-frame-size into a module attr
-Wframe-larger-than= is an interesting warning; we can't know the frame size until PrologueEpilogueInsertion (PEI); very late in the compilation pipelin
[IR] make -warn-frame-size into a module attr
-Wframe-larger-than= is an interesting warning; we can't know the frame size until PrologueEpilogueInsertion (PEI); very late in the compilation pipeline.
-Wframe-larger-than= was propagated through CC1 as an -mllvm flag, then was a cl::opt in LLVM's PEI pass; this meant it was dropped during LTO and needed to be re-specified via -plugin-opt.
Instead, make it part of the IR proper as a module level attribute, similar to D103048. Introduce -fwarn-stack-size CC1 option.
Reviewed By: rsmith, qcolombet
Differential Revision: https://reviews.llvm.org/D103928
show more ...
|
#
b2d0c16e |
| 05-May-2021 |
Nathan Sidwell <nathan@acm.org> |
[clang] p1099 using enum part 2
This implements the 'using enum maybe-qualified-enum-tag ;' part of 1099. It introduces a new 'UsingEnumDecl', subclassed from 'BaseUsingDecl'. Much of the diff is th
[clang] p1099 using enum part 2
This implements the 'using enum maybe-qualified-enum-tag ;' part of 1099. It introduces a new 'UsingEnumDecl', subclassed from 'BaseUsingDecl'. Much of the diff is the boilerplate needed to get the new class set up.
There is one case where we accept ill-formed, but I believe this is merely an extended case of an existing bug, so consider it orthogonal. AFAICT in class-scope the c++20 rule is that no 2 using decls can bring in the same target decl ([namespace.udecl]/8). But we already accept:
struct A { enum { a }; }; struct B : A { using A::a; }; struct C : B { using A::a; using B::a; }; // same enumerator
this patch permits mixtures of 'using enum Bob;' and 'using Bob::member;' in the same way.
Differential Revision: https://reviews.llvm.org/D102241
show more ...
|
#
3787ee45 |
| 08-Jun-2021 |
Nick Desaulniers <ndesaulniers@google.com> |
reland [IR] make -stack-alignment= into a module attr
Relands commit 433c8d950cb3a1fa0977355ce0367e8c763a3f13 with fixes for MIPS.
Similar to D102742, specifying the stack alignment via CodegenOpts
reland [IR] make -stack-alignment= into a module attr
Relands commit 433c8d950cb3a1fa0977355ce0367e8c763a3f13 with fixes for MIPS.
Similar to D102742, specifying the stack alignment via CodegenOpts means that this flag gets dropped during LTO, unless the command line is re-specified as a plugin opt. Instead, encode this information as a module level attribute so that we don't have to expose this llvm internal flag when linking the Linux kernel with LTO.
Looks like external dependencies might need a fix: * https://github.com/llvm-hs/llvm-hs/issues/345 * https://github.com/halide/Halide/issues/6079
Link: https://github.com/ClangBuiltLinux/linux/issues/1377
Reviewed By: tejohnson
Differential Revision: https://reviews.llvm.org/D103048
show more ...
|
#
a596b54d |
| 08-Jun-2021 |
Nick Desaulniers <ndesaulniers@google.com> |
Revert "[IR] make -stack-alignment= into a module attr"
This reverts commit 433c8d950cb3a1fa0977355ce0367e8c763a3f13.
Breaks the MIPS build.
|
#
433c8d95 |
| 08-Jun-2021 |
Nick Desaulniers <ndesaulniers@google.com> |
[IR] make -stack-alignment= into a module attr
Similar to D102742, specifying the stack alignment via CodegenOpts means that this flag gets dropped during LTO, unless the command line is re-specifie
[IR] make -stack-alignment= into a module attr
Similar to D102742, specifying the stack alignment via CodegenOpts means that this flag gets dropped during LTO, unless the command line is re-specified as a plugin opt. Instead, encode this information as a module level attribute so that we don't have to expose this llvm internal flag when linking the Linux kernel with LTO.
Looks like external dependencies might need a fix: * https://github.com/llvm-hs/llvm-hs/issues/345 * https://github.com/halide/Halide/issues/6079
Link: https://github.com/ClangBuiltLinux/linux/issues/1377
Reviewed By: tejohnson
Differential Revision: https://reviews.llvm.org/D103048
show more ...
|
#
b31f41e7 |
| 24-May-2021 |
Andrew Savonichev <andrew.savonichev@gmail.com> |
[Clang] Support a user-defined __dso_handle
This fixes PR49198: Wrong usage of __dso_handle in user code leads to a compiler crash.
When Init is an address of the global itself, we need to track it
[Clang] Support a user-defined __dso_handle
This fixes PR49198: Wrong usage of __dso_handle in user code leads to a compiler crash.
When Init is an address of the global itself, we need to track it across RAUW. Otherwise the initializer can be destroyed if the global is replaced.
Differential Revision: https://reviews.llvm.org/D101156
show more ...
|
#
0e4cf807 |
| 22-May-2021 |
Martin Storsjö <martin@martin.st> |
[clang] [MinGW] Don't mark emutls variables as DSO local
These actually can be automatically imported from another DLL. (This works properly as long as the actual implementation of emutls is linked
[clang] [MinGW] Don't mark emutls variables as DSO local
These actually can be automatically imported from another DLL. (This works properly as long as the actual implementation of emutls is linked dynamically from e.g. libgcc; if the implementation comes from compiler-rt or a statically linked libgcc, it doesn't work as intended.)
This fixes PR50146 and https://github.com/msys2/MINGW-packages/issues/8706 (fixing calling std::call_once in a dynamically linked libstdc++); since f73183958482602c4588b0f4a1c3a096e7542947 the dso_local attribute on the TLS variable affected the actual generated code for accessing the emutls variable.
The dso_local attribute on the emutls variable made those accesses to use 32 bit relative addressing in code, which requires runtime pseudo relocations in the text section, and breaks entirely if the actual other variable ends up loaded too far away in the virtual address space.
Differential Revision: https://reviews.llvm.org/D102970
show more ...
|
#
033138ea |
| 21-May-2021 |
Nick Desaulniers <ndesaulniers@google.com> |
[IR] make stack-protector-guard-* flags into module attrs
D88631 added initial support for:
- -mstack-protector-guard= - -mstack-protector-guard-reg= - -mstack-protector-guard-offset=
flags, and D
[IR] make stack-protector-guard-* flags into module attrs
D88631 added initial support for:
- -mstack-protector-guard= - -mstack-protector-guard-reg= - -mstack-protector-guard-offset=
flags, and D100919 extended these to AArch64. Unfortunately, these flags aren't retained for LTO. Make them module attributes rather than TargetOptions.
Link: https://github.com/ClangBuiltLinux/linux/issues/1378
Reviewed By: tejohnson
Differential Revision: https://reviews.llvm.org/D102742
show more ...
|
#
4cb42564 |
| 19-May-2021 |
Yaxun (Sam) Liu <yaxun.liu@amd.com> |
[CUDA][HIP] Fix device variables used by host
variables emitted on both host and device side with different addresses when ODR-used by host function should not cause device side counter-part to be f
[CUDA][HIP] Fix device variables used by host
variables emitted on both host and device side with different addresses when ODR-used by host function should not cause device side counter-part to be force emitted.
This fixes the regression caused by https://reviews.llvm.org/D102237
Reviewed by: Artem Belevich
Differential Revision: https://reviews.llvm.org/D102801
show more ...
|
#
8f20ac95 |
| 13-May-2021 |
Reid Kleckner <rnk@google.com> |
[PGO] Don't reference functions unless value profiling is enabled
This reduces the size of chrome.dll.pdb built with optimizations, coverage, and line table info from 4,690,210,816 to 2,181,128,192,
[PGO] Don't reference functions unless value profiling is enabled
This reduces the size of chrome.dll.pdb built with optimizations, coverage, and line table info from 4,690,210,816 to 2,181,128,192, which makes it possible to fit under the 4GB limit.
This change can greatly reduce binary size in coverage builds, which do not need value profiling. IR PGO builds are unaffected. There is a minor behavior change for frontend PGO.
PGO and coverage both use InstrProfiling to create profile data with counters. PGO records the address of each function in the __profd_ global. It is used later to map runtime function pointer values back to source-level function names. Coverage does not appear to use this information.
Recording the address of every function with code coverage drastically increases code size. Consider this program:
void foo(); void bar(); inline void inlineMe(int x) { if (x > 0) foo(); else bar(); } int getVal(); int main() { inlineMe(getVal()); }
With code coverage, the InstrProfiling pass runs before inlining, and it captures the address of inlineMe in the __profd_ global. This greatly increases code size, because now the compiler can no longer delete trivial code.
One downside to this approach is that users of frontend PGO must apply the -mllvm -enable-value-profiling flag globally in TUs that enable PGO. Otherwise, some inline virtual method addresses may not be recorded and will not be able to be promoted. My assumption is that this mllvm flag is not popular, and most frontend PGO users don't enable it.
Differential Revision: https://reviews.llvm.org/D102818
show more ...
|