Michal Paszkowski [Wed, 18 Jan 2023 21:23:11 +0000 (22:23 +0100)]
[SPIR-V] Emit OpExecutionMode ContractionOff for no FP_CONTRACT metadata
This change makes the AsmPrinter emit OpExecutionMode ContractionOff
when both opencl.enable.FP_CONTRACT and spirv.ExecutionMode
metadata are not present.
Differential Revision: https://reviews.llvm.org/D141734
Nikita Popov [Thu, 19 Jan 2023 14:23:48 +0000 (15:23 +0100)]
[InstCombine] Add tests for freeze with !range and !align metadata (NFC)
These are currently being miscompiled, see PR59888.
Alex Brachet [Thu, 19 Jan 2023 14:10:31 +0000 (14:10 +0000)]
[X86] Add register definitions for cfi directives
Add {e,r}flags, {g,f}s.base registers so they can be referenced in cfi
directives,. They are not otherwise useable in any instructions,
but can be implicitly pushed to the stack like with pushf for
{e,r}flags.
Differential Revision: https://reviews.llvm.org/D141879
Nico Weber [Thu, 19 Jan 2023 14:01:29 +0000 (09:01 -0500)]
[gn] port
939dce12f9f3 (clangd uses include-cleaner) more
Nico Weber [Thu, 19 Jan 2023 13:45:56 +0000 (08:45 -0500)]
[gn] port
939dce12f9f3 (clangd uses include-cleaner)
Haojian Wu [Mon, 2 Jan 2023 21:10:11 +0000 (22:10 +0100)]
[clangd] Implement unused include warnings with include-cleaner library.
A prototype of using include-cleaner library in clangd:
- (re)implement clangd's "unused include" warnings with the library
- the new implementation is hidden under a flag `Config::UnusedIncludesPolicy::Experiment`
Differential Revision: https://reviews.llvm.org/D140875
Christian Ulmann [Thu, 19 Jan 2023 11:04:53 +0000 (12:04 +0100)]
[llvm][ir] Purge MD_prof custom accessors
This commit purges direct accesses to MD_prof metadata and replaces them
with the accessors provided from the utility file wherever possible.
This commit can be seen as the first step towards switching the branch weights to 64 bits.
See post here: https://discourse.llvm.org/t/extend-md-prof-branch-weights-metadata-from-32-to-64-bits/67492
Reviewed By: davidxl, paulkirth
Differential Revision: https://reviews.llvm.org/D141393
Amaury Séchet [Tue, 17 Jan 2023 02:17:18 +0000 (02:17 +0000)]
[DAG] Peek through ZEXT/TRUNC in foldAddSubMasked1
Fix a regression in D141883
Depends on D141883
Reviewed By: lebedev.ri
Differential Revision: https://reviews.llvm.org/D141884
Haojian Wu [Tue, 3 Jan 2023 14:08:42 +0000 (15:08 +0100)]
[clang] Build UsingType for elaborated type specifiers.
Support building UsingType for elaborated type specifiers:
```
namespace ns { class Foo {}; }
using ns::Foo;
// The TypeLoc of `Foo` below should be a ElaboratedTypeLoc with an
// inner UsingTypeLoc rather than the underlying `CXXRecordTypeLoc`
class Foo foo;
```
Differential Revision: https://reviews.llvm.org/D141280
Jean Perier [Thu, 19 Jan 2023 13:18:08 +0000 (14:18 +0100)]
[flang][hlfir] Enable lowering and passing of allocatables and pointers.
Adds support for:
- referencing a whole allocatable/pointer symbol
- passing allocatable/pointer in a call
This required update in HLFIRTools.cpp helpers so that the
raw address, extents, lower bounds, and type parameters of a
fir.box/fir.class can be extracted.
This is required because in hlfir lowering, dereferencing a
pointer/alloc is only doing the fir.load fir.box part, and the
helpers have to be able to reason about that fir.box without the
help of a "fir::FortranVariableOpInterface".
Missing:
- referencing part of allocatable/pointer (will need to update
Designator lowering to dereference the pointer/alloc). Same
for whole allocatable and pointer components.
- allocate/deallocate/pointer assignment statements.
- Whole allocatable assignment.
- Lower inquires.
Differential Revision: https://reviews.llvm.org/D142043
serge-sans-paille [Wed, 18 Jan 2023 15:43:56 +0000 (16:43 +0100)]
Optimize OptTable::findNearest implementation and usage
When used to find an exact match, some extra context can be used to
totally cut some computations.
This saves 1% of the instruction count when pre processing sqlite3.c
through
valgrind --tool=callgrind ./bin/clang -E sqlite3.c -o/dev/null
Differential Revision: https://reviews.llvm.org/D142026
Groverkss [Thu, 19 Jan 2023 13:01:56 +0000 (18:31 +0530)]
[MLIR][Presburger] Support divisions in union of two PWMAFunction
This patch adds support for divisions in the union of two PWMAFunction. This is
now possible because of previous patches, which made divisions explicitly
stored in MultiAffineFunction (MAF). This patch also refactors the previous
implementation, moving the implementation for obtaining a set of points where a
MAF is lexicographically "better" than the other to MAF.
Reviewed By: arjunp
Differential Revision: https://reviews.llvm.org/D138118
Michal Paszkowski [Wed, 18 Jan 2023 23:05:37 +0000 (00:05 +0100)]
[SPIR-V] Add -opaque-pointers=0 to some LIT tests
Differential Revision: https://reviews.llvm.org/D142061
Timm Bäder [Thu, 19 Jan 2023 12:52:05 +0000 (13:52 +0100)]
Revert "[clang][Interp] Unify visiting variable declarations"
This reverts commit
5b54cf1a2892767fe949826a32d7820732028a38.
This breaks a builder: https://lab.llvm.org/buildbot/#/builders/5/builds/30854
Timm Bäder [Thu, 19 Jan 2023 12:51:26 +0000 (13:51 +0100)]
Revert "[clang][Interp] Implement missing compound assign operators"
This reverts commit
490e8214fca48824beda8b508d6d6bbbf3d8d9a7.
This breaks a builder: https://lab.llvm.org/buildbot/#/builders/214/builds/5415
Timm Bäder [Thu, 19 Jan 2023 12:24:40 +0000 (13:24 +0100)]
[clang][Interp][NFC] Remove shift error checking code duplication
Amaury Séchet [Sun, 1 May 2022 15:58:32 +0000 (15:58 +0000)]
[DAG] Do not combine any_ext when we combine and into zext.
This transofrm loses information that can be useful for other transforms.
Reviewed By: lebedev.ri
Differential Revision: https://reviews.llvm.org/D141883
Evan Smal [Thu, 19 Jan 2023 12:11:07 +0000 (13:11 +0100)]
[clang] Improve diagnostic for "initializer-string for char array is too long"
This patch improves the diagnostic message "initializer-string for
char array is too long" by specifying an expected array length and by
indicating that the initializer string implicitly includes the
null terminator.
Fixes #58829
Differential Revision: https://reviews.llvm.org/D141283
Florian Hahn [Thu, 19 Jan 2023 12:07:27 +0000 (12:07 +0000)]
[VPlan] Add vp_depth_first_shallow + graph traits for wrapper(NFC)
This patch adds a new VPBlockShallowTraversalWrapper struct to
provide graph traits specialization that do not traverse through
VPRegionBlocks. This matches the behavior of the existing traits for
plain VPBlockBase and is a step before moving the graph traits for
VPBlockBase to traverse through VPRegionBlocks to enable cross region
support in VPDominatorTree.
Depends on D140511.
Reviewed By: Ayal
Differential Revision: https://reviews.llvm.org/D140512
Mariusz Sikora [Wed, 18 Jan 2023 14:30:38 +0000 (15:30 +0100)]
[AMDGPU] Add feature predicate for v_fmac_f64 instruction
Introducing feature predicate VFmacF64Inst for targets which
supports v_fmac_f64 instructions.
Differential Revision: https://reviews.llvm.org/D142017
Timm Bäder [Thu, 19 Jan 2023 12:03:20 +0000 (13:03 +0100)]
Revert "[clang][Interp][NFC] Remove shift error checking code duplication"
This reverts commit
fddf6418e8492a544c9bfdb42a4dbc949d9dc2ee.
Apparently this also breaks some builders:
/usr/bin/ld: EvalEmitter.cpp:(.text._ZN5clang6interp11EvalEmitter7emitShlENS0_8PrimTypeES2_RKNS0_10SourceInfoE+0x1f54): undefined reference to `bool clang::interp::CheckShift<clang::interp::Integral<16u, true> >(clang::interp::InterpState&, clang::interp::CodePtr, clang::interp::Integral<16u, true> const&, unsigned int)'
/usr/bin/ld: EvalEmitter.cpp:(.text._ZN5clang6interp11EvalEmitter7emitShlENS0_8PrimTypeES2_RKNS0_10SourceInfoE+0x1fd4): undefined reference to `bool clang::interp::CheckShift<clang::interp::Integral<32u, true> >(clang::interp::InterpState&, clang::interp::CodePtr, clang::interp::Integral<32u, true> const&, unsigned int)'
/usr/bin/ld: EvalEmitter.cpp:(.text._ZN5clang6interp11EvalEmitter7emitShlENS0_8PrimTypeES2_RKNS0_10SourceInfoE+0x2058): undefined reference to `bool clang::interp::CheckShift<clang::interp::Integral<32u, true> >(clang::interp::InterpState&, clang::interp::CodePtr, clang::interp::Integral<32u, true> const&, unsigned int)'
(etc)
Dominik Adamski [Thu, 22 Dec 2022 12:26:47 +0000 (06:26 -0600)]
[mlir][OpenMP] Add nontemporal clause definition to simd construct
simd nontemporal construct is represented as a list of variables
which have low locality accross simd iterations
Added verifier of nontemporal clause. MLIR tests were updated to test
correctness of MLIR definition of nontemporal clause.
Differential Revision: https://reviews.llvm.org/D140553
Reviewed By: kiranchandramohan
Jordan Rupprecht [Thu, 19 Jan 2023 11:40:59 +0000 (03:40 -0800)]
[NFC][bazel] Enable layering_check for mlir/unittests
Timm Bäder [Thu, 19 Jan 2023 11:37:20 +0000 (12:37 +0100)]
Revert "[clang][Interp][NFC] Move CheckDivRem() implementation into Interp.cpp"
This reverts commit
9ee0d7494eb35f5addefcb730cdf5c002ddeacd2.
Timm Bäder [Mon, 31 Oct 2022 11:44:38 +0000 (12:44 +0100)]
[clang][Interp] Implement missing compound assign operators
Implement mul, div, rem, etc. compound assign operators.
Differential Revision: https://reviews.llvm.org/D137071
Timm Bäder [Sun, 30 Oct 2022 09:21:58 +0000 (10:21 +0100)]
[clang][Interp][NFC] Move CheckDivRem() implementation into Interp.cpp
Just like we do with all the other Check* functions.
Timm Bäder [Sun, 30 Oct 2022 09:20:04 +0000 (10:20 +0100)]
[clang][Interp][NFC] Remove shift error checking code duplication
Timm Bäder [Sun, 30 Oct 2022 06:28:17 +0000 (07:28 +0100)]
[clang][Interp][NFCI] Pull IsConstantContext into State
This way we can check for this flag in the new interpreter as well.
Quentin Colombet [Tue, 17 Jan 2023 11:54:40 +0000 (11:54 +0000)]
[mlir][vector] Add a custom builder for LowerVectorsOp
The `lower_vectors` operation of the transform dialect takes a lot of
arguments to build.
In order to make C++ code easier to work with when using this
instruction, introduce a new structure, named `LowerVectorsOptions`, that
aggregates all the options that are used to build this instruction.
This allows to use patterns like:
```
LowerVectorsOptions opts;
opts.setOptZ(...)
.setOptY(...)...;
builder.create<LowerVectorsOp>(target, opts);
```
Instead of having to pass all N options directly to the builder and set
them in the right order.
NFC
Differential Revision: https://reviews.llvm.org/D141923
Christian Ulmann [Thu, 12 Jan 2023 15:48:19 +0000 (16:48 +0100)]
[mlir][LLVM] Replace readnone with memory effects
This commit introduces LLVM's `MemoryEffects` attribute and replaces the
deprecated usage of `llvm.readnone` in the LLVM dialect.
The absence of the attribute on a `LLVMFuncOp` implies that it might
access all kinds of memory. This semantic corresponds to `llvm::Function`'s
behaviour.
Depends on D142002
Differential Revision: https://reviews.llvm.org/D142013
Alex Zinenko [Thu, 19 Jan 2023 10:32:42 +0000 (10:32 +0000)]
[mlir] fix mlir integration tests
Alex Zinenko [Mon, 9 Jan 2023 18:06:09 +0000 (18:06 +0000)]
[mlir] simpler transform dialect silenceable failures
Simplify the handling of silenceable failures in the transform dialect.
Previously, the logic of `TransformEachOpTrait` required that
`applyToEach` returned a list of null pointers when a silenceable
failure was emitted. This was not done consistently and also crept into
ops without this trait although they did not require it. Handle this
case earlier in the interpreter and homogeneously associated preivously
unset transform dialect values (both handles and parameters) with empty
lists of the matching kind. Ignore the results of `applyToEach` for the
targets for which it produced a silenceable failure. As a result, one
never needs to set results to lists containing nulls. Furthermore, the
objects associated with transform dialect values must never be null.
Depends On D140980
Reviewed By: nicolasvasilache
Differential Revision: https://reviews.llvm.org/D141305
Alex Zinenko [Wed, 4 Jan 2023 14:04:53 +0000 (14:04 +0000)]
[mlir] make multi-size tiling use transform parameters
Use the recently introduced transform dialect parameter mechanism to
perform controllable multi-size tiling with sizes computed at the
transformation time rather than at runtime.
This requires to generalize tile and split structured transform
operations to work with any transform dialect handle types, which is
desirable in itself to avoid unchecked overuse of PDL OperationType.
Reviewed By: shabalin
Differential Revision: https://reviews.llvm.org/D140980
Nikita Popov [Thu, 19 Jan 2023 09:04:03 +0000 (10:04 +0100)]
[Regex] Avoid NFA machinery for fixed prefix chars (NFC)
Similarly to what backref() does, add an "easy path" to slow()
that can handle some non-branching cases, in particular simple
character matches.
This has the dual effect of reducing the number of characters we
need to match, and the number of states in the NFA.
This reduces FileCheck runtime on vloxseg.c from 17s to 12s on
my machine.
Timm Bäder [Thu, 27 Oct 2022 09:37:11 +0000 (11:37 +0200)]
[clang][Interp] Diagnose uninitialized array record fields
Just like we do for record members, diagnose uninitialized array record
fields.
Differential Revision: https://reviews.llvm.org/D136828
Haojian Wu [Thu, 19 Jan 2023 09:46:53 +0000 (10:46 +0100)]
[clangd] Simplify some tests in IncludeCleanerTests, NFC
They were pointed out in the review of https://reviews.llvm.org/D140875
Timm Bäder [Thu, 27 Oct 2022 04:16:01 +0000 (06:16 +0200)]
[clang][Interp] Unify visiting variable declarations
We often visit the same variable multiple times, e.g. once when checking
its initializer and later when compiling the function. Unify both of
those in visitVarDecl() and do the returning of the value in
visitDecl().
Differential Revision: https://reviews.llvm.org/D136815
David Sherwood [Tue, 17 Jan 2023 15:16:25 +0000 (15:16 +0000)]
[AArch64][SVE2p1] Add SVE2.1 while (predicate-pair) intrinsics
Adds intrinsics for the following instructions:
* WHILEGE (predicate pair)
* WHILEGT (predicate pair)
* WHILEHI (predicate pair)
* WHILEHS (predicate pair)
* WHILELE (predicate pair)
* WHILELO (predicate pair)
* WHILELS (predicate pair)
* WHILELT (predicate pair)
I've added an opcode selector called SelectOpcodeFromVT to
AArch64ISelDAGToDAG.cpp that we will extend in future to
select opcodes from different MVTs. For now, the only use is
for selecting predicate types.
NOTE: These intrinsics are still in development and are subject
to future changes.
Differential Revision: https://reviews.llvm.org/D141936
Christian Ulmann [Thu, 19 Jan 2023 09:02:39 +0000 (10:02 +0100)]
[mlir][FuncToLLVM] Drop llvm.linkage attribute
This commit ensures that all functions produced by `FuncToLLVM` drop the
llvm.linkage attribute. Furthermore, it adds a small test that checks if
the readnone attribute is preserved.
Reviewed By: gysit
Differential Revision: https://reviews.llvm.org/D142002
Quentin Colombet [Thu, 19 Jan 2023 09:22:37 +0000 (10:22 +0100)]
[test][InstCombine] Remove out-of-date comment
NFC
Quentin Colombet [Wed, 18 Jan 2023 15:01:43 +0000 (16:01 +0100)]
[InstCombine] Don't optimize idempotent `atomicrmw <op>, 0` into `load atomic`
Turning idempotent `atomicrmw`s into `load atomic` is perfectly legal
with respect to how the loading happens, but it may not be legal for the
whole program semantic.
Indeed, this optimization removes a store that may have some effects on
the legality of other optimizations.
Essentially, we lose some information and depending on the backend
it may or may not produce incorrect code, so don't do it!
This fixes llvm.org/PR56450.
Differential Revision: https://reviews.llvm.org/D141277
Johannes de Fine Licht [Thu, 19 Jan 2023 08:52:08 +0000 (09:52 +0100)]
[MLIR][LLVM] Don't use void return type in `getCallableResults`.
In the LLVM IR dialect, `LLVMVoidType` is used to model the return type
of LLVM IR functions with no return value. This is inconsistent with
MLIR APIs, which expect a function with no return value to have an
empty return type. Handle this special case in `LLVMFuncOp` to avoid
mismatches between the number of return values and return types between
caller and callee.
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D141676
Alex Zinenko [Thu, 19 Jan 2023 08:58:34 +0000 (08:58 +0000)]
[mlir] fix python test
It was using an incorrect attribute type, but the test was still passing
because of the value being present in the output.
Timm Bäder [Tue, 25 Oct 2022 15:34:31 +0000 (17:34 +0200)]
[clang][Interp] Check Field initialization after constructor call
Differential Revision: https://reviews.llvm.org/D136694
wanglei [Thu, 19 Jan 2023 08:29:14 +0000 (16:29 +0800)]
[LoongArch] Add an option for MCInstPrinter to print numeric reg names
`-loongarch-numeric-reg` for llvm-mc and llc.
`-M numeric` (which matches GNU objdump) for llvm-objdump and llvm-mc.
Reviewed By: SixWeining
Differential Revision: https://reviews.llvm.org/D141743
Yingchi Long [Thu, 19 Jan 2023 08:22:49 +0000 (16:22 +0800)]
[InstCombine] regenerete icmp-logical tests (NFC)
These pattern names are inconsistent with current update_checks.py.
Timm Bäder [Wed, 18 Jan 2023 14:10:40 +0000 (15:10 +0100)]
[clang][Interp][NFC] Initialize constants as ~0u
Timm Bäder [Fri, 2 Dec 2022 07:19:14 +0000 (08:19 +0100)]
[clang][Interp] Use placement new to construct opcode args into vector
Differential Revision: https://reviews.llvm.org/D139185
Timm Bäder [Tue, 17 Jan 2023 08:07:48 +0000 (09:07 +0100)]
[clang][Interp][NFC] Remove unused functions
icedrocket [Thu, 19 Jan 2023 06:35:13 +0000 (22:35 -0800)]
[X86] Avoid converting u64 to f32 using x87 on Windows
The code below currently prints less accurate values only on Windows 32-bit. On Windows, the default precision control on x87 is only 53-bit, and FADD triggers rounding with that precision, so the final result may be less accurate. This revision avoids less accurate conversions by using library calls instead.
```
int main() {
int64_t n = 0b0000000000111111111111111111111111011111111111111111111111111111;
printf("%lld, %.0f, %.0f", n, (float)n, (float)(uint64_t)n);
return 0;
}
```
Reviewed By: craig.topper, lebedev.ri
Differential Revision: https://reviews.llvm.org/D141074
Kazu Hirata [Thu, 19 Jan 2023 03:58:44 +0000 (19:58 -0800)]
Drop the ZeroBehavior parameter from countLeadingZeros and the like (NFC)
This patch drops the ZeroBehavior parameter from bit counting
functions like countLeadingZeros. ZeroBehavior specifies the behavior
when the input to count{Leading,Trailing}Zeros is zero and when the
input to count{Leading,Trailing}Ones is all ones.
ZeroBehavior was first introduced on May 24, 2013 in commit
eb91eac9fb866ab1243366d2e238b9961895612d. While that patch did not
state the intention, I would guess ZeroBehavior was for performance
reasons. The x86 machines around that time required a conditional
branch to implement countLeadingZero<uint32_t> that returns the 32 on
zero:
test edi, edi
je .LBB0_2
bsr eax, edi
xor eax, 31
.LBB1_2:
mov eax, 32
That is, we can remove the conditional branch if we don't care about
the behavior on zero.
IIUC, Intel's Haswell architecture, launched on June 4, 2013,
introduced several bit manipulation instructions, including lzcnt and
tzcnt, which eliminated the need for the conditional branch.
I think it's time to retire ZeroBehavior as its utility is very
limited. If you care about compilation speed, you should build LLVM
with an appropriate -march= to take advantage of lzcnt and tzcnt.
Even if not, modern host compilers should be able to optimize away
quite a few conditional branches because the input is often known to
be nonzero from dominating conditional branches.
Differential Revision: https://reviews.llvm.org/D141798
Slava Zakharin [Thu, 19 Jan 2023 02:10:09 +0000 (18:10 -0800)]
[flang] Fixed unittest build issue with older gcc.
I am getting this error with `check-flang`:
```
ld.lld: error: undefined symbol: mlir::SuccessorRange::SuccessorRange(mlir::Operation*)
>>> referenced by Operation.h:549 (/llvm-project/llvm/../mlir/include/mlir/IR/Operation.h:549)
>>> CMakeFiles/FlangRuntimeTests.dir/Allocatable.cpp.o:(mlir::Operation::getSuccessors())
```
The buildbots are okay, so I guess it has something to do with
gcc-9 that I am using.
Differential Revision: https://reviews.llvm.org/D142069
River Riddle [Fri, 16 Dec 2022 10:33:53 +0000 (02:33 -0800)]
[mlir] Make FunctionOpInterface inherit SymbolOpInterface
This lets users of FunctionOpInterface finally have the
name/visibility accessors from SymbolOpInterface. This also
lets us remove the clunky "getName" method from FunctionOpInterface.
Differential Revision: https://reviews.llvm.org/D140199
River Riddle [Thu, 12 Jan 2023 21:35:15 +0000 (13:35 -0800)]
[mlir] Add support for interface inheritance
This allows for interfaces to define a set of "base classes",
which are interfaces whose methods/extra class decls/etc.
should be inherited by the derived interface. This more
easily enables combining interfaces and their dependencies,
without lots of awkard casting. Additional implicit conversion
operators also greatly simplify the conversion process.
One other aspect of this "inheritance" is that we also implicitly
add the base interfaces to the attr/op/type. The user can still
add them manually if desired, but this should help remove some
of the boiler plate when an interface has dependencies.
See https://discourse.llvm.org/t/interface-inheritance-and-dependencies-interface-method-visibility-interface-composition
Differential Revision: https://reviews.llvm.org/D140198
River Riddle [Fri, 16 Dec 2022 09:16:15 +0000 (01:16 -0800)]
[mlir] Move SymbolOpInterfaces "classof" check to a proper "extraClassOf" interface field
SymbolOpInterface overrides the base classof to provide support
for optionally implementing the interface. This is currently placed
in the extraClassDeclarations, but that is kind of awkard given that
it requires underlying knowledge of how the base classof is implemented.
This commit adds a proper "extraClassOf" field to allow interfaces to
implement this, which abstracts away the default classof logic.
Differential Revision: https://reviews.llvm.org/D140197
River Riddle [Thu, 15 Dec 2022 22:02:06 +0000 (14:02 -0800)]
[mlir] Limit Interface generation to the top-level input file
There are very few instances in which we use multiple files
for interface definitions (none upstream), and this allows
for including interfaces that shouldn't be generated (for
interface inheritance, dependencies, etc.)
Differential Revision: https://reviews.llvm.org/D140196
Jan Korous [Thu, 19 Jan 2023 02:54:48 +0000 (18:54 -0800)]
[-Wunsafe-buffer-usage][NFC] Fix Fixables filtering
We have WIP Fixables for local variables and this central part of the machinery
was dropping Fixables attached to local variables instead of keeping those and
dropping everything else.
We are in the process of rewriting our patches for emitting fixits after we
discovered a conceptual problem in our design.
That is why there's currently no tests that would've detected the issue but
that will change very shortly.
Chuanqi Xu [Thu, 19 Jan 2023 02:37:48 +0000 (10:37 +0800)]
Revert "[NFC] [Serialization] Add static assert for the size of the decls to"
This reverts commit
c79635cce845d66897970cd7f8d7c77b0a3c0286. Since I
forgot the case for 32-bit machine.
LLVM GN Syncbot [Thu, 19 Jan 2023 02:25:05 +0000 (02:25 +0000)]
[gn build] Port
557a5bc336ff
Chuanqi Xu [Wed, 18 Jan 2023 07:50:04 +0000 (15:50 +0800)]
[NFC] [Serialization] Add static assert for the size of the decls to
mention developers to remember to touch the serializer after them
modified the field of decls
It is easy for the developers to forget to touch the serializer after
they add new field to decls. Then if the existing tests fail to catch
such cases, it may be a bug report from users some day. And it is
time-consuming to solve such bugs.
To mitigate the problem, I add the static_asserts in the serializer. So
that the developers can understand they need to modify the serializer
after they saw the static assertion failure. Although this can't solve
all the problems, I feel the current status can be much better.
Reviewed By: erichkeane
Differential Revision: https://reviews.llvm.org/D141992
Nico Weber [Thu, 19 Jan 2023 02:16:51 +0000 (21:16 -0500)]
[gn] port
a033dbbe5c43 (clang-stat-cache)
Paul Kirth [Fri, 13 Jan 2023 23:20:56 +0000 (23:20 +0000)]
[codegen] Add StackFrameLayoutAnalysisPass
Issue #58168 describes the difficulty diagnosing stack size issues
identified by -Wframe-larger-than. For simple code, its easy to
understand the stack layout and where space is being allocated, but in
more complex programs, where code may be heavily inlined, unrolled, and
have duplicated code paths, it is no longer easy to manually inspect the
source program and understand where stack space can be attributed.
This patch implements a machine function pass that emits remarks with a
textual representation of stack slots, and also outputs any available
debug information to map source variables to those slots.
The new behavior can be used by adding `-Rpass-analysis=stack-frame-layout`
to the compiler invocation. Like other remarks the diagnostic
information can be saved to a file in a machine readable format by
adding -fsave-optimzation-record.
Fixes: #58168
Reviewed By: nickdesaulniers, thegameg
Differential Revision: https://reviews.llvm.org/D135488
Kirill Stoimenov [Wed, 21 Dec 2022 22:31:40 +0000 (22:31 +0000)]
[HWASAN] Init lsan and install at_exit hook
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D141146
Lang Hames [Thu, 19 Jan 2023 01:33:50 +0000 (17:33 -0800)]
[ORC-RT] Specialize non-coalescing-IntervalMap to allow non-comparable values.
In non-coalescing IntervalMaps the value type should not be requried to be
equality-comparable.
Vitaly Buka [Thu, 19 Jan 2023 01:24:10 +0000 (17:24 -0800)]
[NFC][sanitizers] Add COMPILER_RT_HAS_WTHREAD_SAFETY_*_FLAG
Shilei Tian [Thu, 19 Jan 2023 01:08:59 +0000 (20:08 -0500)]
[OpenMP][OMPT] Expect failure from tool_available_search.c on macOS
D91464 introduced verbose tool loading, but the test check only considers Linux.
On macOS, the outputs are totally different, causing the regression afterwards.
This patch simply sets the test to XFAIL on macOS.
Fix #56833.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D142045
Shilei Tian [Thu, 19 Jan 2023 01:08:10 +0000 (20:08 -0500)]
[OpenMP][AMDGPU] Get rid of redundant macro def
The next gen plugin adds the def of `DEBUG_PREFIX` in CMake, causing
compiler warning that `DEBUG_PREFIX` is defined multiple times. This patch simply
guards the macro def.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D142064
Jonas Paulsson [Thu, 15 Sep 2022 06:54:36 +0000 (08:54 +0200)]
Add parameter extension attributes in various instrumentation passes.
For the targets that have in their ABI the requirement that arguments and
return values are extended to the full register bitwidth, it is important
that calls when built also take care of this detail.
The OMPIRBuilder, AddressSanitizer, GCOVProfiling, MemorySanitizer and
ThreadSanitizer passes are with this patch hopefully now doing this properly.
Reviewed By: Eli Friedman, Ulrich Weigand, Johannes Doerfert
Differential Revision: https://reviews.llvm.org/D133949
Joseph Huber [Thu, 15 Dec 2022 20:49:09 +0000 (14:49 -0600)]
[CUDA] Allow targeting NVPTX directly without a host toolchain
Currently, the NVPTX compilation toolchain can only be invoked either
through CUDA or OpenMP via `--offload-device-only`. This is because we
cannot build a CUDA toolchain without an accompanying host toolchain for
the offloading. When using `--target=nvptx64-nvidia-cuda` this results
in generating calls to the GNU assembler and linker, leading to errors.
This patch abstracts the portions of the CUDA toolchain that are
independent of the host toolchain or offloading kind into a new base
class called `NVPTXToolChain`. We still need to read the host's triple
to build the CUDA installation, so if not present we just assume it will
match the host's system for now, or the user can provide the path
explicitly.
This should allow the compiler driver to create NVPTX device images
directly from C/C++ code.
Reviewed By: tra
Differential Revision: https://reviews.llvm.org/D140158
Jeffrey Byrnes [Thu, 19 Jan 2023 00:12:18 +0000 (16:12 -0800)]
[AMDGPU] Run autogen checks on test
Change-Id: I46f2ced9ceac592c2a93a00631014a806d4b0693
Paul Kirth [Wed, 18 Jan 2023 21:54:21 +0000 (21:54 +0000)]
Reland [pgo] Avoid introducing relocations by using private alias
In many cases, we can use an alias to avoid a symbolic relocations,
instead of using the public, interposable symbol. When the instrumented
function is in a COMDAT, we can use a hidden alias, and still avoid
references to discarded sections.
Previous versions of this patch allowed the compiler to name the
generated alias, but that would only be valid when the functions were
local. Since the alias may be used across TUs we use a more
deterministic naming convention, and add a ".local" suffix to the alias
name just as we do for relative vtables aliases.
https://reviews.llvm.org/rG20894a478da224bdd69c91a22a5175b28bc08ed9
removed an incorrect assertion on Mach-O which caused assertion failures in LLD.
We addressed the link errors under ThinLTO + PGO + CFI by being more
selective about which comdat functions can be given aliases.
Specifically, we now do not emit an alias in the case of a comdat
function with hidden visibility, since the alias would have the same
linkage and visibility, giving no benefit over using the symbol
directly. This also prevents LowerTypeTest from incorrectly updating the
dangling alias after GlobalOpt replaces uses, and introducing a
duplicate symbol.
Reviewed By: phosek
Differential Revision: https://reviews.llvm.org/D137982
Kirill Stoimenov [Wed, 18 Jan 2023 22:34:07 +0000 (22:34 +0000)]
[HWASAN] Remove FindHeapChunkByAddressFastLocked
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D142042
Shilei Tian [Wed, 18 Jan 2023 23:21:49 +0000 (18:21 -0500)]
[OpenMP] Fix inconsistent task state if hot team is not used
This patch fixes the inconsistent task state when hot team is not used.
When the primary thread executes `__kmp_join_call`, it calls `__kmp_free_team`,
where worker threads will get destroyed if not using hot team. The destroy of
worker threads also reset their task state. However, the primary thread's is not
reset. When the next parallel region is encountered, in `__kmp_task_team_sync`,
the task state of thread will be flipped. Since the state of primary thread is not
reset, it is still 1, but all the worker threads will be 0, this leads to the
inconsistent task state, causing those threads are using completely different
task team.
Fix #59190.
Reviewed By: tlwilmar
Differential Revision: https://reviews.llvm.org/D141979
Joseph Huber [Wed, 18 Jan 2023 23:07:02 +0000 (17:07 -0600)]
[Clang][NFC] Clang-format CUDA toolchain file
Summary:
This file is not formatted, which makes further changes to it more
difficult. Format it.
Jan Korous [Wed, 18 Jan 2023 22:47:03 +0000 (14:47 -0800)]
[-Wunsafe-buffer-usage] Group diagnostics by variable
Differential Revision: https://reviews.llvm.org/D141356
Amir Ayupov [Wed, 18 Jan 2023 22:21:28 +0000 (14:21 -0800)]
[BOLT][NFC] Replace ambiguous BinarySection::isReadOnly with isWritable
Address feedback in https://reviews.llvm.org/D102284#2755060
Reviewed By: yota9
Differential Revision: https://reviews.llvm.org/D141733
Fred Riss [Wed, 18 Jan 2023 22:46:55 +0000 (14:46 -0800)]
[StatCacheFileSystem] Attempt to fix build
Some bots are not happy with the way Error is returned here. Let's see if
std::moving it fixes this.
Fred Riss [Thu, 20 Oct 2022 00:29:36 +0000 (17:29 -0700)]
[Clang] Give Clang the ability to use a shared stat cache
Every Clang instance uses an internal FileSystemStatCache to avoid
stating the same content multiple times. However, different instances
of Clang will contend for filesystem access for their initial stats
during HeaderSearch or module validation.
On some workloads, the time spent in the kernel in these concurrent
stat calls has been measured to be over 20% of the overall compilation
time. This is extremly wassteful when most of the stat calls target
mostly immutable content like a SDK.
This commit introduces a new tool `clang-stat-cache` able to generate
an OnDiskHashmap containing the stat data for a given filesystem
hierarchy.
The driver part of this has been modeled after -ivfsoverlay given
the similarities with what it influences. It introduces a new
-ivfsstatcache driver option to instruct Clang to use a stat cache
generated by `clang-stat-cache`. These stat caches are inserted at
the bottom of the VFS stack (right above the real filesystem).
Differential Revision: https://reviews.llvm.org/D136651
Kirill Stoimenov [Wed, 18 Jan 2023 22:01:27 +0000 (22:01 +0000)]
[HWASAN] Fix Fuchsia link problem
Reviewed By: mysterymath
Differential Revision: https://reviews.llvm.org/D142057
Amir Ayupov [Wed, 18 Jan 2023 22:07:48 +0000 (14:07 -0800)]
[BOLT][NFC] Simplify handleRelocation
Reviewed By: rafauler
Differential Revision: https://reviews.llvm.org/D132089
Jan Korous [Tue, 10 Jan 2023 01:36:48 +0000 (17:36 -0800)]
[-Wunsafe-buffer-usage] Use relevant source locations for warnings
This way we highlight a particular unsafe subexpression by providing more accurate
source location than begin of an entire statement.
Differential Revision: https://reviews.llvm.org/D141340
Volodymyr Sapsai [Tue, 10 Jan 2023 20:41:11 +0000 (12:41 -0800)]
[clang][Sema] Fix uninitialized `SourceLocation` for types with multiple attributes and macros.
Some `TypeLoc`s are considered "sugar" and we go past them in
`GetTypeSourceInfoForDeclarator`. The problem is that we peel off only
the same kind of `TypeLoc` at the time which makes it impossible to
handle mixed sequences like
`AttributedTypeLoc - MacroQualifiedTypeLoc - AttributedTypeLoc - PointerTypeLoc`
In this situation, as shown in the added test, we don't get to
`PointerTypeLoc` and don't set its starLoc leaving it uninitialized.
Address FIXME and peel off "sugar" `TypeLoc`s regardless of their order.
rdar://
102149264
Differential Revision: https://reviews.llvm.org/D141424
Martin Storsjö [Tue, 2 Aug 2022 11:53:36 +0000 (14:53 +0300)]
[CMake] Allow setting the location of host tools with LLVM_NATIVE_TOOL_DIR
This avoids having to specify the location of all individual tools.
In current builds, one may want to specify LLVM_TABLEGEN, CLANG_TABLEGEN,
LLDB_TABLEGEN, LLVM_CONFIG_PATH, CLANG_PSEUDO_GEN and
CLANG_TIDY_CONFUSABLE_CHARS_GEN; specifying just the base directory
containing all of them is much more convenient.
Factorize the code for setting up use of a tool that is used during
the build (which either is newly built in the same build, or
built in a separate nested cmake build - when cross compiling or
when e.g. optimized tablegen is requested - or used from an existing
prebuilt binary).
Differential Revision: https://reviews.llvm.org/D131052
Amir Ayupov [Fri, 9 Dec 2022 23:09:39 +0000 (15:09 -0800)]
[BOLT][NFC] DataAggregator code cleanup
Reviewed By: #bolt, rafauler
Differential Revision: https://reviews.llvm.org/D139794
Amir Ayupov [Wed, 18 Jan 2023 02:26:34 +0000 (18:26 -0800)]
[BOLT][NFC] Remove AArch64 override for evaluateBranch
Use MCInstrAnalysis implementation
Reviewed By: #bolt, rafauler, yota9
Differential Revision: https://reviews.llvm.org/D141983
Tulio Magno Quites Machado Filho [Wed, 18 Jan 2023 19:26:24 +0000 (13:26 -0600)]
[SystemZ] Implement lowering of GET_ROUNDING
Add support for _FLT_ROUNDS_ in SystemZ.
Patch by Tulio Magno Quites Machado Filho.
Reviewed By: Ulrich Weigand
Differential Revision: https://reviews.llvm.org/D140988
Jason Molenda [Wed, 18 Jan 2023 20:29:52 +0000 (12:29 -0800)]
Do qProcessInfo-hint binary loading later in Process setup
The remote stub may give lldb hints about binaries to
be loaded, especially in a firmware type environment, and
relay those hints in the qProcessInfo response. The
binary loading was done very early in Process setup, before
we had any threads, and this made it complicated for people
to write dSYM python scripts which need access to a thread.
Delay the binary loading until a bit later in the Process
startup.
Differential Revision: https://reviews.llvm.org/D141972
rdar://
104235301
Krzysztof Drewniak [Mon, 16 Jan 2023 18:39:21 +0000 (18:39 +0000)]
[llvm][GenericUniformity] Hack around strict is_invocable() checks
With recent (> 15, as far as I can tell, possibly > 16) clang, c++17,
and GNU's libstdc++ (versions 9 and 10 and maybe others), LLVM fails
to compile due to an is_invocable() check in unique_ptr::reset().
To resolve this issue, add a template argument to ImplDeleter to make
things work.
Differential Revision: https://reviews.llvm.org/D141865
Craig Topper [Wed, 18 Jan 2023 19:38:38 +0000 (11:38 -0800)]
[RISCV] Use canonical move instruction in RISCVAsmPrinter::EmitHwasanMemaccessSymbols.
We were using an OR with X0 which is the canonical move for AArch64.
The canonical move for RISC-V is ADDI reg1, reg2, 0.
Reviewed By: reames
Differential Revision: https://reviews.llvm.org/D142044
Craig Topper [Wed, 18 Jan 2023 19:38:17 +0000 (11:38 -0800)]
[RISCV] Use TargetMachine MCSubtargetInfo in RISCVAsmPrinter::EmitHwasanMemaccessSymbols.
The STI object in the class is updated each time runOnMachineFunction
is called. That means STI will be based on the last function processed.
If that function has different attributes than the rest of the module
that could theoretically result in odd behavior.
Use the copy in TargetMachine instead. That will use the global
CPU and mattrs.
Reviewed By: reames
Differential Revision: https://reviews.llvm.org/D142041
Craig Topper [Wed, 18 Jan 2023 19:31:29 +0000 (11:31 -0800)]
[RISCV] Make it explicit that attributes use the MCSubtargetInfo from TargetMachine. NFC
The MCSTI variable is initialized to TM.getMCSubtargetInfo(), but is
re-assigned in every call to runOnMachineFunction. emitAttributes is
called before any call to runOnMachineFunction, but it's not
immediately obvious.
This patch removes the MCSTI variable, and instead queries
TM.getMCSubtargetInfo() at the time emitAttributes is called.
Reviewed By: reames
Differential Revision: https://reviews.llvm.org/D142037
Giorgis Georgakoudis [Wed, 14 Dec 2022 06:57:02 +0000 (22:57 -0800)]
[OpenMP] RecordReplay saves bitcode when JIT-ing
This patch enables to store bitcode images when JIT is enabled for the record-and-replay functionality (see https://reviews.llvm.org/D138931). Credits to @jdoerfert for refactoring the code.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D141986
Johan Erlandsson [Wed, 18 Jan 2023 19:10:55 +0000 (11:10 -0800)]
[hwasan] add pattern for short tag in symbolizer
Lines with 'record_addr:' are not processed when failing to decode
access tag. The regular format is: %02x/%02x but for a short tag it's:
%02x/%02x(%02x). Now it will handle both cases.
Tested-by: Ivar Henckel <ivar.henckel@sony.com>
Reviewed By: fmayer
Differential Revision: https://reviews.llvm.org/D141906
Eric Li [Thu, 12 Jan 2023 22:29:17 +0000 (17:29 -0500)]
[libTooling] Rename `getRangeForEdit` as `getFileRangeForEdit`
With the addition of `getFileRange`, we rename `getRangeForEdit` as
`getFileRangeForEdit` for consistency in the API.
Depends on D141634
Differential Revision: https://reviews.llvm.org/D141636
Sanjay Patel [Wed, 18 Jan 2023 18:35:12 +0000 (13:35 -0500)]
[InstSimplify] reduce "mul nsw i1" to "false"
https://alive2.llvm.org/ce/z/XYGvYg
Follow-up for:
68c197f07eeae71
Shilei Tian [Wed, 18 Jan 2023 18:39:58 +0000 (13:39 -0500)]
[OpenMP] Disable building `libomptarget` on 32-bit systems
There are plenty of assumptions in `libomptarget` and the device runtime
about the pointer size or `size_t`, etc. 32-bit systems are not supported. There
is no point to refine whole things to make it portable. This patch simply disables
building on 32-bit systems.
Fix #60121.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D142023
Sanjay Patel [Wed, 18 Jan 2023 18:21:32 +0000 (13:21 -0500)]
[InstSimplify] add no-wrap parameters to simplifyMul and add more tests; NFC
This gives mul the same capabilities as add/sub.
A potential improvement with nsw was noted in:
1720ec6da040729f17
Caleb Zulawski [Wed, 18 Jan 2023 18:14:15 +0000 (18:14 +0000)]
[clang][Darwin] Try to guess the SDK root with xcrun when unspecified
Picking up from https://reviews.llvm.org/D109460
Reviewed By: ldionne
Differential Revision: https://reviews.llvm.org/D136315
Michael Buch [Wed, 18 Jan 2023 16:42:20 +0000 (16:42 +0000)]
[lldb][Language] List supported languages in expr error text
Before:
```
(lldb) expr --language abc -- 1 + 1
error: unknown language type: 'abc' for expression
```
After:
```
(lldb) expr --language abc -- 1 + 1
error: unknown language type: 'abc' for expression. List of supported languages:
c++
objective-c++
c++03
c++11
c++14
objc++
```
We choose to only list the languages which `expr` will actually
accept instead of all the language constants defined in `Language.cpp`
since that's what the user will most likely need.
Differential Revision: https://reviews.llvm.org/D142034
Tobias Hieta [Wed, 18 Jan 2023 18:17:25 +0000 (19:17 +0100)]
[NFC] Release Note for D138995