Kazu Hirata [Sat, 23 Jul 2022 00:56:10 +0000 (17:56 -0700)]
[flang] Fix a warning
This patch fixes:
llvm-project/flang/lib/Semantics/expression.cpp:405:12: error:
moving a local object in a return statement prevents copy elision
[-Werror,-Wpessimizing-move]
Ivan Trofimov [Mon, 11 Jul 2022 17:12:31 +0000 (10:12 -0700)]
[libasan] Remove 4Mb stack limit for swapcontext unpoisoning
Reviewed By: vitalybuka, eugenis
Differential Revision: https://reviews.llvm.org/D129219
Peter Klausler [Fri, 15 Jul 2022 19:15:07 +0000 (12:15 -0700)]
[flang] Correct folding of TRANSFER(integer, character array)
The code that copies data from a constant source array into a character
array constant result was failing to copy its last element if it was
only partially defined due to misalignment.
Differential Revision: https://reviews.llvm.org/D130376
Fangrui Song [Sat, 23 Jul 2022 00:16:41 +0000 (17:16 -0700)]
[Driver] Error for -gsplit-dwarf with RISC-V linker relaxation
-gsplit-dwarf produces a .dwo file which will not be processed by the linker. If
.dwo files contain relocations, they will not be resolved. Therefore the
practice is that .dwo files do not contain relocations.
Address ranges and location description need to use forms/entry kinds indexing
into .debug_addr (DW_FORM_addrx/DW_RLE_startx_endx/etc), which is currently not
implemented.
There is a difficult-to-read MC error with -gsplit-dwarf with RISC-V for both -mrelax and -mno-relax.
```
% clang --target=riscv64-linux-gnu -g -gsplit-dwarf -c a.c
error: A dwo section may not contain relocations
```
We expect to fix -mno-relax soon, so report a driver error for -mrelax for now.
Link: https://github.com/llvm/llvm-project/issues/56642
Reviewed By: compnerd, kito-cheng
Differential Revision: https://reviews.llvm.org/D130190
Peter Klausler [Fri, 22 Jul 2022 17:52:30 +0000 (10:52 -0700)]
[flang] Fix parsing and semantics for array element substring%KIND/%LEN
A type-param-inquiry of %KIND or %LEN applies to a designator, and
so must also be allowed for a substring. F18 presently (mis)parses
instances of a type-param-inquiry as structure component references
and then fixes them in expression semantics when types are known and
we can distinguish them. But when the base of a type-param-inquiry is
a substring of an array element, as in "charArray(i)(j:k)%len",
parsing fails.
Adjust the grammar to parse these cases, and extend expression semantics
to process the new production.
Differential Revision: https://reviews.llvm.org/D130375
Ilya Leoshkevich [Fri, 22 Jul 2022 23:38:26 +0000 (01:38 +0200)]
[Lit] Pass through DFLTCC from the surrounding environment
Many distros ship zlib with the IBM Z deflate hardware acceleration
patch [1]. Sometimes it's desirable to disable the acceleration, for
example, for reproducibility. This can be done by exporting DFLTCC=0.
llvm-lit clears this environment variable, which causes
compress-debug-sections-zlib.test fail on z15 and later machines. Add
DFLTCC to the list of variables to keep.
[1] https://github.com/madler/zlib/pull/410
Reviewed By: abrachet
Differential Revision: https://reviews.llvm.org/D130253
Dmitri Gribenko [Fri, 22 Jul 2022 23:23:17 +0000 (01:23 +0200)]
[clang][dataflow] Add DataflowEnvironment::dump()
Start by dumping the flow condition.
Reviewed By: ymandel
Differential Revision: https://reviews.llvm.org/D130398
Volodymyr Sapsai [Fri, 22 Jul 2022 18:43:07 +0000 (11:43 -0700)]
Move "clang/Basic/TokenKinds.h" into a separate top-level module.
Fixes modular build for clangPseudoGrammar from clang-tools-extra.
Starting from https://reviews.llvm.org/D126731 clangPseudoGrammar
doesn't depend on generated .inc headers but still depends on
"Basic/TokenKinds.h". It means clangPseudoGrammar depends on module
'Clang_Basic' which does depend on generated .inc headers. To avoid
these coarse dependencies and extra build steps, extract
"clang/Basic/TokenKinds.h" into a top-level module 'Clang_Basic_TokenKinds'.
rdar://
97387951
Differential Revision: https://reviews.llvm.org/D130377
Peter Klausler [Mon, 18 Jul 2022 18:16:01 +0000 (11:16 -0700)]
[flang] Admit trailing blanks when checking I/O specifiers
Fortran specifically allows character-valued I/O specifiers
to have trailing blanks, e.g. OPEN(666,STATUS='SCRATCH ').
The runtime I/O library already handles them, but the I/O
static checks in semantics do not.
Differential Revision: https://reviews.llvm.org/D130381
Dmitri Gribenko [Fri, 22 Jul 2022 23:18:03 +0000 (01:18 +0200)]
[clang][dataflow] Expose stringification functions for SAT solver enums
Reviewed By: ymandel
Differential Revision: https://reviews.llvm.org/D130399
Ryan Prichard [Fri, 22 Jul 2022 23:20:47 +0000 (16:20 -0700)]
[libc++][test] Fix infinite loop when mkstemp fails
mkstemp is guaranteed to make at least TMP_MAX attempts to create the
random file, and if it can't, it fails with EEXIST. get_temp_file_name
shouldn't call mkstemp again if it fails with anything other than
EEXIST. A single mkstemp call seems sufficient.
On Android, I've seen mkstemp fail with:
- EROFS (because cwd wasn't set to a writable filesystem)
- EACCES (because cwd pointed to a dir owned by root, but the test
program was running as the shell user instead)
Previously, get_temp_file_name would run forever in these situations.
See D4962 and "llvm-svn: 229035"
Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D130214
Dmitri Gribenko [Fri, 22 Jul 2022 23:13:24 +0000 (01:13 +0200)]
[clang][dataflow] ArrayRef'ize debugString()
Reviewed By: ymandel
Differential Revision: https://reviews.llvm.org/D130400
Augusto Noronha [Fri, 22 Jul 2022 23:06:49 +0000 (16:06 -0700)]
[lldb] Remote accidental logs left in TestGuiExpandThreadsTree
Augusto Noronha [Fri, 22 Jul 2022 22:59:58 +0000 (15:59 -0700)]
[lldb] Disable TestGuiExpandThreadsTree
Peter Klausler [Fri, 15 Jul 2022 21:34:32 +0000 (14:34 -0700)]
[flang] Fold SET_EXPONENT() and FRACTION()
Fold the intrinsic function SET_EXPONENT() and its special case,
FRACTION().
Differential Revision: https://reviews.llvm.org/D130378
Med Ismail Bennani [Fri, 22 Jul 2022 22:21:34 +0000 (15:21 -0700)]
Revert "[lldb/Fuzzer] Add fuzzer for expression evaluator"
This reverts commit
b797834748f1954950880bf50fb78abedd4494e6, since it
breaks building Clang: https://reviews.llvm.org/D129377
ARCHIT SAXENA [Fri, 22 Jul 2022 22:02:16 +0000 (15:02 -0700)]
Add a nop instruction if a section starts with landing pad for function splitter
This change adds a nop instruction if section starts with landing pad. This change is like [D73739](https://reviews.llvm.org/D73739) which avoids zero offset landing pad in basic block sections.
Detailed description:
The current machine functions splitter can create ˜sections which start with a landing pad themselves. This places landing pad at offset zero from LPStart.
```
.section .text.split.foo10,"ax",@progbits
foo10.cold: # %lpad
.cfi_startproc
.cfi_personality 3, __gxx_personality_v0
.cfi_lsda 3, .Lexception5
.cfi_def_cfa %rsp, 16
.Ltmp11: <--- This is a Landing pad and also LP Start as it is start of this section
movq %rax, %rdi <--- first instruction is at offest 0 from LPStart
callq _Unwind_Resume@PLT
```
This will cause landing pad entries to become zero (.Ltmp11-foo10.cold)
```
.Lcst_begin4:
.uleb128 .Ltmp9-.Lfunc_begin2 # >> Call Site 1 <<
.uleb128 .Ltmp10-.Ltmp9 # Call between .Ltmp9 and .Ltmp10
.uleb128 .Ltmp11-foo10.cold <---This is zero # jumps to .Ltmp11
.byte 3 # On action: 2
.uleb128 .Ltmp10-.Lfunc_begin2 # >> Call Site 2 <<
.uleb128 .Lfunc_end9-.Ltmp10 # Call between .Ltmp10 and .Lfunc_end9
.byte 0 # has no landing pad
.byte 0 # On action: cleanup
.p2align 2
```
The C++ ABI somehow assumes that no landing pads point directly to LPStart (which works in the normal case since the function begin is never a landing pad), and uses LP.offset = 0 to specify no landing pad. This change adds a nop instruction at start of such sections so that such a case could be avoided. Output:
```
.section .text.split.foo10,"ax",@progbits
foo10.cold: # %lpad
.cfi_startproc
.cfi_personality 3, __gxx_personality_v0
.cfi_lsda 3, .Lexception5
.cfi_def_cfa %rsp, 16
nop <--- new instruction that is added
.Ltmp11:
movq %rax, %rdi
callq _Unwind_Resume@PLT
```
Reviewed By: modimo, snehasish, rahmanl
Differential Revision: https://reviews.llvm.org/D130133
Alexander Shaposhnikov [Fri, 22 Jul 2022 22:08:47 +0000 (22:08 +0000)]
[InstCombine] Improve folding of mul + icmp
This diff adds folds for patterns like X * A < B
where A, B are constants and "mul" has either "nsw" or "nuw".
(to address https://github.com/llvm/llvm-project/issues/56563).
Test plan:
1/ ninja check-llvm check-clang
2/ Bootstrapped LLVM/Clang pass tests
Differential revision: https://reviews.llvm.org/D130039
Fangrui Song [Fri, 22 Jul 2022 22:07:28 +0000 (15:07 -0700)]
[Driver] Report -Wunused-command-line-argument for unimplemented -mtune=
Most common architectures (aarch64,riscv,s390x,x86,etc) have implemented -mtune=.
Don't ignore -mtune= in generic code.
Fangrui Song [Fri, 22 Jul 2022 21:54:27 +0000 (14:54 -0700)]
[Driver][SystemZ] Simplify -mtune
Similar to AArch64.
Fangrui Song [Fri, 22 Jul 2022 21:51:07 +0000 (14:51 -0700)]
[Driver][RISCV] Simplify -mtune
Fangrui Song [Fri, 22 Jul 2022 21:37:58 +0000 (14:37 -0700)]
[Driver][test] Clean up and improve some -mtune tests
Note: we should test CHECK-NOT: "-tune-cpu" instead of CHECK-NOT: "-tune-cpu" "generic"
Chelsea Cassanova [Mon, 11 Jul 2022 21:24:50 +0000 (17:24 -0400)]
[lldb/Fuzzer] Add fuzzer for expression evaluator
This commit adds a fuzzer for LLDB's expression evaluator.
The fuzzer takes a different approach than the current fuzzers
present, and uses an approach that is currently being used for
clang fuzzers.
Instead of fuzzing the evaluator with randomly mutated
characters, protobufs are used to generate a subset of C++. This
is then converted to valid C++ code and sent to the expression
evaluator. In addition, libprotobuf_mutator is used to mutate
the fuzzer's inputs from valid C++ code to valid C++ code, rather
than mutating from valid code to total nonsense.
Differential revision: https://reviews.llvm.org/D129377
Fangrui Song [Fri, 22 Jul 2022 21:19:27 +0000 (14:19 -0700)]
[Driver][AArch64] Simplify -mtune
llvm::sys::getHostCPUName()'s return value is not empty. `-mtune=` (empty value)
has caused a driver error. So we can omit `!TuneCPU.empty()` check.
Kjetil Kjeka [Fri, 22 Jul 2022 20:59:11 +0000 (13:59 -0700)]
[NVPTX] Promote i24, i40, i48 and i56 to next power-of-two register when passing
Today llc will crash when attempting to use non-power-of-two integer types as
function arguments or returns. This patch enables passing non standard integer
values in functions by promoting them before store and truncating after load.
The main motivation of implementing this change is that rust casts small structs
(less than pointer size) into an integer of the same size. As an example, if a
struct contains three u8 then it will be passed as an i24. This patch is a step
towards enabling rust compilation to ptx while retaining the target independent
optimizations.
More context can be found in https://github.com/llvm/llvm-project/issues/55764
Differential Revision: https://reviews.llvm.org/D129291
Artem Belevich [Fri, 22 Jul 2022 21:09:42 +0000 (14:09 -0700)]
Changed EOL to UNIX. NFC.
Greg Clayton [Fri, 22 Jul 2022 20:18:40 +0000 (13:18 -0700)]
Cache the value for absolute path in FileSpec.
Checking if a path is absolute can be expensive and currently the result is not cached in the FileSpec object. This patch adds caching and also code to clear the cache if the file is modified.
Differential Revision: https://reviews.llvm.org/D130396
Greg Clayton [Fri, 22 Jul 2022 20:59:06 +0000 (13:59 -0700)]
Fix buildbot breakage after https://reviews.llvm.org/D130309.
Nikolas Klauser [Sun, 10 Jul 2022 19:58:01 +0000 (21:58 +0200)]
[runtimes] Add pstl to the list of default runtimes to fix the build
Reviewed By: ldionne, #libc, #libc_abi
Spies: h-vetinari, sstefan1, libcxx-commits, mgorny
Differential Revision: https://reviews.llvm.org/D129452
rkayaith [Sat, 16 Jul 2022 20:41:33 +0000 (16:41 -0400)]
[mlir][python] Fix issue in diagnostic note initialization
Previously the elements of the notes tuple would be invalid objects when
accessed from a diagnostic handler, resulting in a segfault when used.
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D129943
Vitaly Buka [Thu, 21 Jul 2022 01:23:17 +0000 (18:23 -0700)]
[asan] Reset stack bounds of context
ClearShadowMemoryForContextStack assumes that context contains the stack
bounds. This is not true for a context from getcontext or oucp of
swapcontext.
Reviewed By: kstoimenov
Differential Revision: https://reviews.llvm.org/D130218
Nuno Lopes [Fri, 22 Jul 2022 20:33:22 +0000 (21:33 +0100)]
Revert "[NFC] Add some additional features to MultiLevelTemplateArgumentList"
This reverts commit
0b36a62d5f3505e21692ae0abf25ef00836329e3.
It breaks the assertion build
Shangwu Yao [Fri, 22 Jul 2022 19:22:08 +0000 (19:22 +0000)]
[CUDA/SPIR-V] Force passing aggregate type byval
This patch forces copying aggregate type in kernel arguments by value when
compiling CUDA targeting SPIR-V. The original behavior is not passing by value
when there is any of destructor, copy constructor and move constructor defined
by user. This patch makes the behavior of SPIR-V generated from CUDA follow
the CUDA spec
(https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#global-function-argument-processing),
and matches the NVPTX
implementation (
https://github.com/llvm/llvm-project/blob/
41958f76d8a2c47484fa176cba1de565cfe84de7/clang/lib/CodeGen/TargetInfo.cpp#L7241).
Differential Revision: https://reviews.llvm.org/D130387
Julian Lettner [Fri, 22 Jul 2022 18:33:35 +0000 (11:33 -0700)]
[Sanitizer][Darwin] Factor out code for GCD worker registration
This is a NFC change to factor out GCD worker thread registration via
the pthread introspection hook.
In a follow-up change we also want to register GCD workers for ASan to
make sure threads are registered before we attempt to print reports on
them.
rdar://
93276353
Differential Revision: https://reviews.llvm.org/D126351
Greg Clayton [Fri, 22 Jul 2022 20:24:04 +0000 (13:24 -0700)]
Fix buildbot breakage after https://reviews.llvm.org/D130309.
Erich Keane [Fri, 22 Jul 2022 20:04:59 +0000 (13:04 -0700)]
[NFC] Add some additional features to MultiLevelTemplateArgumentList
These are useful when dealing with multi-depth instantiation in deferred
concepts, so this is split off of that patch.
Shilei Tian [Fri, 22 Jul 2022 20:03:04 +0000 (16:03 -0400)]
[OpenMP][Offloading] Enlarge the work size of `wtime.c` in case of any noise
Alexander Yermolovich [Fri, 22 Jul 2022 20:02:08 +0000 (13:02 -0700)]
Revert "[DWP][DWARF] Detect and error on debug info offset overflow"
This reverts commit
417738d3a66cc65f3fc58ab9535c17fac1ddaff1.
Sanjay Patel [Fri, 22 Jul 2022 18:33:35 +0000 (14:33 -0400)]
Revert "[InstCombine] enhance fold for subtract-from-constant -> xor"
This reverts commit
79bb915fb60b2cd220d89e3bb54f67abb8cdb7bd.
This caused regressions because SCEV works better with sub.
Erich Keane [Fri, 22 Jul 2022 19:52:26 +0000 (12:52 -0700)]
[NFC] give getParentFunctionOrMethod a 'Lexical' parameter
Split up from the deferred concepts implementation, this function is
useful for determining the containing function of a different function.
However, in some cases it is valuable to instead get the lexical parent.
This adds a parameter to the existing function to allow a 'Lexical'
parameter to instead select the lexical parent.
Erich Keane [Fri, 22 Jul 2022 19:30:47 +0000 (12:30 -0700)]
[NFC] Start saving InstantiatedFromDecl in non-template functions
In cases where a non-template function is defined inside a function
template, we don't have information about the original uninstantiated
version. In the case of concepts instantiation, we will need the
ability to get back to the original template. This patch splits a piece
of the deferred concepts instantaition patch off to accomplish the
storage of this, with minor runtime overhead, and zero additional
storage.
Aaron Ballman [Fri, 22 Jul 2022 19:24:54 +0000 (15:24 -0400)]
Strengthen -Wint-conversion to default to an error
Clang has traditionally allowed C programs to implicitly convert
integers to pointers and pointers to integers, despite it not being
valid to do so except under special circumstances (like converting the
integer 0, which is the null pointer constant, to a pointer). In C89,
this would result in undefined behavior per 3.3.4, and in C99 this rule
was strengthened to be a constraint violation instead. Constraint
violations are most often handled as an error.
This patch changes the warning to default to an error in all C modes
(it is already an error in C++). This gives us better security posture
by calling out potential programmer mistakes in code but still allows
users who need this behavior to use -Wno-error=int-conversion to retain
the warning behavior, or -Wno-int-conversion to silence the diagnostic
entirely.
Differential Revision: https://reviews.llvm.org/D129881
Philip Reames [Fri, 22 Jul 2022 19:12:05 +0000 (12:12 -0700)]
[LV] Use early return to simplify code structure
Alex Brachet [Fri, 22 Jul 2022 19:06:54 +0000 (19:06 +0000)]
[CMake] Stop zstd find_package warnings
Fangrui Song [Fri, 22 Jul 2022 18:56:46 +0000 (11:56 -0700)]
[ELF] Internalize isBitcode. NFC
Fangrui Song [Fri, 22 Jul 2022 18:54:27 +0000 (11:54 -0700)]
[ELF] --fortran-common: remove unneeded identify_magic call. NFC
Arnold Schwaighofer [Wed, 20 Jul 2022 20:27:11 +0000 (13:27 -0700)]
llvm.swift.async.context.addr cannot be modeled as NoMem because we don't want it to be cse'd accross async suspends
An async suspend models the split between two partial async functions.
`llvm.swift.async.context.addr ` will have a different value in the two
partial functions so it is not correct to generally CSE the instruction.
rdar://
97336162
Differential Revision: https://reviews.llvm.org/D130201
Joel E. Denny [Fri, 22 Jul 2022 18:38:09 +0000 (14:38 -0400)]
[Libomptarget] Don't report lack of CUDA devices
Sometimes libomptarget's CUDA plugin produces unhelpful diagnostics
about a lack of CUDA devices before an application runs:
```
$ clang -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa hello-world.c
$ ./a.out
CUDA error: Error returned from cuInit
CUDA error: no CUDA-capable device is detected
Hello World: 4
```
This can happen when the CUDA plugin was built but all CUDA devices
are currently disabled in some manner, perhaps because
`CUDA_VISIBLE_DEVICES` is set to the empty string. As shown in the
above example, it can even happen when we haven't compiled the
application for offloading to CUDA.
The following code from `openmp/libomptarget/plugins/cuda/src/rtl.cpp`
appears to be intended to handle this case, and it chooses not to
write a diagnostic to stderr unless debugging is enabled:
```
if (NumberOfDevices == 0) {
DP("There are no devices supporting CUDA.\n");
return;
}
```
The problem is that the above code is never reached because the
earlier `cuInit` returns `CUDA_ERROR_NO_DEVICE`. This patch handles
that `cuInit` case in the same manner as the above code handles the
`NumberOfDevices == 0` case.
Reviewed By: tianshilei1992
Differential Revision: https://reviews.llvm.org/D130371
Sanjay Patel [Fri, 22 Jul 2022 17:56:12 +0000 (13:56 -0400)]
[PhaseOrdering] add test for loop-idiom-recognize + tailcall; NFC
Huan Nguyen [Fri, 22 Jul 2022 18:23:38 +0000 (11:23 -0700)]
[BOLT] Handle broken .dynsym in stripped binaries
Strip tools cause a few symbols in .dynsym to have bad section index.
This update safely keeps such broken symbols intact.
Test Plan:
```
ninja check-bolt
```
Reviewed By: Amir
Differential Revision: https://reviews.llvm.org/D130073
Shilei Tian [Fri, 22 Jul 2022 18:16:47 +0000 (14:16 -0400)]
[OpenMP] Fix test error introduced in D130179
zhijian [Fri, 22 Jul 2022 17:52:18 +0000 (13:52 -0400)]
[AIX][NFC] modify the llvm-ar help information for big archive.
Reviewers: James Henderson
Differential Revision: https://reviews.llvm.org/D130292
Shilei Tian [Fri, 22 Jul 2022 17:46:31 +0000 (13:46 -0400)]
[OpenMP][DeviceRTL] Fix the issue that multiple calls to `omp_get_wtime` is optimized out by mistake
Multiple calls to `omp_get_wtime` could be optimized out due to the function
is mistakenly marked as `readnone`. This patch fixes the issue, and also add the
support to run optimization on `libomptarget` tests.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D130179
zr33 [Fri, 22 Jul 2022 17:45:09 +0000 (10:45 -0700)]
[BOLT][DWARF] Fix bolt/test/X86/shared-abbrev.s
There should not be a end of child mark before DW_AT_ranges, removed it and fixed unit offset.
Reviewed By: ayermolo
Differential Revision: https://reviews.llvm.org/D130335
Alexander Yermolovich [Mon, 18 Jul 2022 22:12:07 +0000 (15:12 -0700)]
[DWP][DWARF] Detect and error on debug info offset overflow
Right now we silently overflow uint32_t for debug_indfo sections. Added a check
and error out.
Differential Revision: https://reviews.llvm.org/D130046
Sergei Barannikov [Fri, 22 Jul 2022 17:45:02 +0000 (10:45 -0700)]
[clang][CodeGen] Only include ABIInfo.h where required (NFC)
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D130322
Paul Kirth [Fri, 22 Jul 2022 17:34:58 +0000 (17:34 +0000)]
[clang-doc] Add check for pointer validity
clang-doc would SEGV when running over the Fuchsia code base.
This patch adds a check to avoid dereferencing potentially null pointers
in the Values vector. These pointers were either never valid or had been
invalidated when the underlying pointer in std::unique_ptr was moved from,
hence making it nullptr within the vector.
Reviewed By: phosek
Differential Revision: https://reviews.llvm.org/D130279
Michael Jones [Wed, 13 Jul 2022 17:17:54 +0000 (10:17 -0700)]
[libc][nfc] move printf inf/nan to separate function
The floating point functions all use the same inf and nan formatting. By
separating this functionality out of the %a conversion I make it
available for reuse by %f/e/g.
Reviewed By: lntue, sivachandra
Differential Revision: https://reviews.llvm.org/D129665
Christopher Bate [Wed, 20 Jul 2022 20:39:30 +0000 (14:39 -0600)]
[mlir][Arithmetic] Add `arith.delinearize_index` operation
This change adds a new DelinearizeIndexOp to the `arith` dialect. The
operation accepts an `index` type as well as a basis (array of index
values) representing how the index should be decomposed into a
multi-index. The decomposition obeys a canonical semantic that treats
the final basis element as "fastest varying" and the first basis element
as "slowest varying". A naive lowering of the operation using a sequence
of `arith.divui` and `arith.remui` operations is also given.
Differential Revision: https://reviews.llvm.org/D129697
Thomas Raoux [Fri, 22 Jul 2022 17:13:22 +0000 (17:13 +0000)]
[mlir][vector] NFC change to improve doc of vector distribution op
Improve doc based on post commit review from https://reviews.llvm.org/D123703
Add more details on the op semantic, explicitly mention what part are parallel
and what parts are serial.
Differential Revision: https://reviews.llvm.org/D125227
Greg Clayton [Thu, 21 Jul 2022 21:43:29 +0000 (14:43 -0700)]
[NFC] Improve FileSpec internal APIs and usage in preparation for adding caching of resolved/absolute.
The FileSpect APIs allow users to modify instance variables directly by getting a non const reference to the directory and filename instance variables. This makes it impossibly to control all of the times the FileSpec object is modified so we can clear the cache. This patch modifies the APIs of FileSpec so no one can modify the directory or filename directly by adding set accessors and by removing the get accessors that are non const.
Many clients were using FileSpec::GetCString(...) which returned a unique C string from a ConstString'ified version of the result of GetPath() which returned a std::string. This caused many locations to use this convenient function incorrectly and could cause many strings to be added to the constant string pool that didn't need to. Most clients were converted to using FileSpec::GetPath().c_str() when possible. Other clients were modified to use the newly renamed version of this function which returns an actualy ConstString:
ConstString FileSpec::GetPathAsConstString(bool denormalize = true) const;
This avoids the issue where people were getting an already uniqued "const char *" that came from a ConstString only to put the "const char *" back into a "ConstString" object. By returning the ConstString instead of a "const char *" clients can be more efficient with the result.
The patch:
- Removes the non const GetDirectory() and GetFilename() get accessors
- Adds set accessors to replace the above functions: SetDirectory() and SetFilename().
- Adds ClearDirectory() and ClearFilename() to replace usage of the FileSpec::GetDirectory().Clear()/FileSpec::GetFilename().Clear() call sites
- Fixed all incorrect usage of FileSpec::GetCString() to use FileSpec::GetPath().c_str() where appropriate, and updated other call sites that wanted a ConstString to use the newly returned ConstString appropriately and efficiently.
Differential Revision: https://reviews.llvm.org/D130309
Thomas Raoux [Wed, 20 Jul 2022 16:10:10 +0000 (16:10 +0000)]
[mlir][vector] Extend transfer_write to read propagation
Folding of transfer_write into transfer_read is already supported but
this requires the read and write to have the same permuation map.
After linalg vectorization it is common to have different ppermuation
map for write followed by read even though the cases could be
propagated.
This canonicalization handle cases where the permuation maps are
different but the data read and written match and replace the transfer
ops with broadcast and permuation
Differential Revision: https://reviews.llvm.org/D130135
Alex Brachet [Fri, 22 Jul 2022 17:04:55 +0000 (17:04 +0000)]
[llvm-driver] Fix build after
07b749800
The llvm-driver build is not enabled on any bots so this
wasn't caught earlier.
Dylan Fleming [Fri, 22 Jul 2022 16:40:50 +0000 (16:40 +0000)]
[Flang] Generate documentation for compiler flags
This patch aims to create a webpage to document
Flang's command line options on https://flang.llvm.org/docs/
in a similar way to Clang's
https://clang.llvm.org/docs/ClangCommandLineReference.html
This is done by using clang_tablegen to generate an .rst
file from Options.td (which is current shared with Clang)
For this to work, ClangOptionDocEmitter.cpp was updated
to allow specific Flang flags to be included,
rather than bulk excluding clang flags.
Note:
Some headings in the generated documentation will incorrectly
contain references to Clang, e.g.
"Flags controlling the behaviour of Clang during compilation"
This is because Options.td (Which is shared between both Clang and Flang)
contains hard-coded DocBrief sections. I couldn't find a non-intrusive way
to make this target-dependant, as such I've left this as is, and it will need revisiting later.
Reviewed By: awarzynski
Differential Revision: https://reviews.llvm.org/D129864
Alex Brachet [Fri, 22 Jul 2022 17:02:11 +0000 (17:02 +0000)]
[libc] Don't call user comparator function for equal pointers
The standard says two equal pointers must compare equal
so there is no need to call the user comparator function
in this case.
Differential Revision: https://reviews.llvm.org/D130310
zhijian [Fri, 22 Jul 2022 17:02:09 +0000 (13:02 -0400)]
[NFC] Fixed build fail of https://lab.llvm.org/buildbot/#/builders/207/builds/8752
which caused by https://reviews.llvm.org/D127864
Konstantin Varlamov [Fri, 22 Jul 2022 16:58:56 +0000 (09:58 -0700)]
[libc++][ranges] Implement `ranges::shuffle`.
Differential Revision: https://reviews.llvm.org/D130321
tlattner [Wed, 13 Jul 2022 18:42:30 +0000 (11:42 -0700)]
Remove references to old mailing lists that have moved to discourse. Replace with links to discourse.
Reviewed By: #libc_abi, ldionne
Differential Revision: https://reviews.llvm.org/D129675
Jacques Pienaar [Fri, 22 Jul 2022 16:56:08 +0000 (09:56 -0700)]
[mlir][tosa] Flip accessors used to prefixed form (NFC)
Follow up from dialect flip, just flipping accessors. Both forms still
generated.
Stefan Pintilie [Thu, 21 Jul 2022 10:48:33 +0000 (05:48 -0500)]
[PowerPC][NFC] Convert the MMA test cases to use opaque pointers.
This patch modifies only test cases.
Converted the MMA test cases to use opaque pointers.
Reviewed By: lei, amyk
Differential Revision: https://reviews.llvm.org/D130090
Simon Pilgrim [Fri, 22 Jul 2022 16:17:25 +0000 (17:17 +0100)]
[AArch64] Use neon instructions for i64/i128 ISD::PARITY calculation
As noticed on D129765 and reported on Issue #56531 - aarch64 targets can use the neon ctpop + add-reduce instructions to speed up scalar ctpop instructions, but we fail to do this for parity calculations.
I'm not sure where the cutoff should be for specific CPUs, but i64 (+ i128 special case) shows a definite reduction in instruction count. i32 is about the same (but scalar <-> neon transfers are probably more costly?), and sub-i32 promotion looks to be a definite regression compared to parity expansion optimized for those widths.
Differential Revision: https://reviews.llvm.org/D130246
Simon Pilgrim [Fri, 22 Jul 2022 15:49:58 +0000 (16:49 +0100)]
[X86] Add X64 test coverage to smul-with-overflow.ll
Mircea Trofin [Thu, 21 Jul 2022 15:30:23 +0000 (08:30 -0700)]
[NFC] FunctionSamples::getEntrySamples -> getHeadSamplesEstimate
The name `getEntrySamples` was misleading for 2 reasons. One, it's
close in name to `Function::getEntryCount`, but the equivalent here is
`getHeadSamples`; second, as opposed to the other get* APIs in
`FunctionSamples`, it performs an estimate/heuristic rather than just
retrieving raw data (or a non-heuristic derivate off that data, like
`getMaxCountInside`)
The new name should more clearly communicate its intent; and, being
close (in name) to `getHeadSamples`, it should allow the reader discover
the relation between them.
Also updated the doc comments for both `getHeadSamples[Estimate]` so a
reader may better understand the relation between them.
Differential Revision: https://reviews.llvm.org/D130281
Slava Zakharin [Tue, 19 Jul 2022 22:35:56 +0000 (15:35 -0700)]
[flang] Try to lower math intrinsics to math operations first.
This commit changes how math intrinsics are lowered: we, first,
try to lower them into MLIR operations or libm calls via
mathOperations table and only then fallback to pgmath runtime calls.
The pgmath fallback is needed, because mathOperations does not
support all intrinsics that pgmath supports. The main purpose
of this change is to get rid of llvmIntrinsics table so that
we do not have to update both llvmIntrinsics and mathOperations
when adding new intrinsic support.
mathOperations lowering should phase out pgmath lowering, when
more operations are available (e.g. power operations being
added in D129809 and D129811; complex type operations from
Complex dialect).
Differential Revision: https://reviews.llvm.org/D130129
Slava Zakharin [Thu, 21 Jul 2022 20:17:44 +0000 (13:17 -0700)]
[flang] Reduced CHECKs for transpose_opt.f90
This commit addresses concerns raised in D129497.
Differential Revision: https://reviews.llvm.org/D130300
Shilei Tian [Fri, 22 Jul 2022 15:45:06 +0000 (11:45 -0400)]
Revert "[OpenMP][DeviceRTL] Fix the issue that multiple calls to `omp_get_wtime` is optimized out by mistake"
This reverts commit
ad34f1dba80efb62f5181e30b039a017fd5d164e.
Benjamin Kramer [Fri, 22 Jul 2022 15:43:02 +0000 (17:43 +0200)]
[LV] Remove unused variable. NFC.
Shilei Tian [Fri, 22 Jul 2022 15:43:23 +0000 (11:43 -0400)]
[OpenMP][DeviceRTL] Fix the issue that multiple calls to `omp_get_wtime` is optimized out by mistake
Multiple calls to `omp_get_wtime` could be optimized out due to the function
is mistakenly marked as `readnone`. This patch fixes the issue, and also add the
support to run optimization on `libomptarget` tests.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D130179
Craig Topper [Fri, 22 Jul 2022 15:07:26 +0000 (08:07 -0700)]
[DAGCombiner] Simplify code around call to reduceLoadWidth in visitAND. NFC
We were looking for loads or any_extend+load. reduceLoadWidth
hasn't known how to look through such an any_extend to find the
load since D40667 almost 5 years ago.
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D130333
Philip Reames [Fri, 22 Jul 2022 15:32:43 +0000 (08:32 -0700)]
[LV] Rework widening cost of uniform memory ops for clarity [nfc]
Reorganize the code to make it clear what is and isn't handle, and why.
Restructure bailout to remove (false and confusing) dependence on
CM_Scalarize; just return invalid cost and propagate, that's what it
is for.
Jeff Niu [Tue, 19 Jul 2022 16:14:52 +0000 (09:14 -0700)]
[mlir][ods] Remove warning in `AttrOrTypeDef`
This warning was added because using attribute or type assembly formats
with `skipDefaultBuilders` set could cause compilation errors, since the
required builder prototype may not necessarily be generated and would
need to be checked by hand. This patch removes the warning because a
warning that the generated C++ "might" not compile is not particularly
useful. Attempting to address the TODO (i.e. detect whether a builder of
the correct prototype is provided) would be fragile since it would not
be possible to account for implicit conversions, etc.
In general, ODS should not be emitting warnings in cases like these.
Reviewed By: rriddle, wrengr
Differential Revision: https://reviews.llvm.org/D130102
VitalyR [Fri, 22 Jul 2022 14:53:41 +0000 (10:53 -0400)]
[CUDA] remove duplicate condition
Reviewed by: Yaxun Liu
Differential Revision: https://reviews.llvm.org/D130168
Change-Id: Ia00c3dfa9ea20e61235817fd4bb61d33c7c98a60
Sam Estep [Fri, 22 Jul 2022 15:15:46 +0000 (15:15 +0000)]
[clang][dataflow] Refactor ApplyBuiltinTransfer field out into DataflowAnalysisOptions struct
Depends On D130304
This patch pulls the `ApplyBuiltinTransfer` from the `TypeErasedDataflowAnalysis` class into a new `DataflowAnalysisOptions` struct, to allow us to add additional options later without breaking existing code.
Reviewed By: gribozavr2, sgatev
Differential Revision: https://reviews.llvm.org/D130305
Maksim Panchenko [Thu, 21 Jul 2022 01:51:08 +0000 (18:51 -0700)]
[BOLT] Add support for the latest perf tool
The latest perf tool can return non-empty buffer when executing
buildid-list command, even when perf.data was recorded with -B flag.
Some binaries will be listed without the ID, while others may have a
recorded ID. Allow invalid entires on the input, while checking the
valid ones for the match.
Reviewed By: Amir
Differential Revision: https://reviews.llvm.org/D130223
Malhar Jajoo [Fri, 22 Jul 2022 12:52:20 +0000 (13:52 +0100)]
[Costmodel] Add "type-based-intrinsic-cost" cli option
This patch adds a command line flag to be able to test
the type based cost-model analysis for Intrinsics.
Differential Revision: https://reviews.llvm.org/D129109
Tue Ly [Fri, 22 Jul 2022 14:43:01 +0000 (10:43 -0400)]
[libc] Temporarily disable arm32's sinf, cosf, sincosf entrypoints.
With correctly rounded implementations, these functions will be tested for all
rounding modes. Since fegetround and fesetround are not implemented for arm32,
these tests will fail in all non-default rounding modes. We will re-enable
these entrypoints and tests once fegetround and fesetround are implemented for
arm32.
Shubham Narlawar [Fri, 22 Jul 2022 14:20:53 +0000 (15:20 +0100)]
[AArch64] Move SeparateConstOffsetFromGEPPass before LSR and enable EnableGEPOpt by default.
GEP's across basic blocks were not getting splitted due to EnableGEPOpt
which was turned off by default. Hence, EarlyCSE missed the opportunity
to eliminate common part of GEP's. This can be achieved by simply
turning GEP pass on.
- This patch moves SeparateConstOffsetFromGEPPass() just before LSR.
- It enables EnableGEPOpt by default.
Resolves - https://github.com/llvm/llvm-project/issues/50528
Added an unit test.
Differential Revision: https://reviews.llvm.org/D128582
Jacques Pienaar [Fri, 22 Jul 2022 14:20:24 +0000 (07:20 -0700)]
[mlir][tosa] Split canonicalization and folders out of TosaOps.
Scope ops file to ops. Used canonicalization as grouping for canonicalization
patterns and folders (also considered OpTransforms but that felt too generic
and the former two are used together).
Reviewed By: silvas, rsuderman
Differential Revision: https://reviews.llvm.org/D130297
Sam Estep [Fri, 22 Jul 2022 14:10:15 +0000 (14:10 +0000)]
[clang][dataflow] Move NoopAnalysis from unittests to include
This patch moves `Analysis/FlowSensitive/NoopAnalysis.h` from `clang/unittests/` to `clang/include/clang/`, so that we can use it for doing context-sensitive analysis.
Reviewed By: ymandel, gribozavr2, sgatev
Differential Revision: https://reviews.llvm.org/D130304
Nikita Popov [Fri, 22 Jul 2022 14:06:40 +0000 (16:06 +0200)]
[AsmPrinter] Move lowerConstant() error code out of switch (NFC)
Move this out of the switch, so that different branches can
indicate an error by breaking out of the switch. This becomes
important if there are more than the two current error cases.
Tue Ly [Tue, 5 Apr 2022 20:17:18 +0000 (16:17 -0400)]
[libc] Implement sinf function that is correctly rounded to all rounding modes.
Implement sinf function that is correctly rounded to all rounding modes.
- We use a simple range reduction for `pi/16 < |x|` :
Let `k = round(x / pi)` and `y = (x/pi) - k`.
So `k` is an integer and `-0.5 <= y <= 0.5`.
Then
```
sin(x) = sin(y*pi + k*pi)
= (-1)^(k & 1) * sin(y*pi)
~ (-1)^(k & 1) * y * P(y^2)
```
where `y*P(y^2)` is a degree-15 minimax polynomial generated by Sollya with:
```
> P = fpminimax(sin(x*pi)/x, [|0, 2, 4, 6, 8, 10, 12, 14|], [|D...|], [0, 0.5]);
```
- Performance benchmark using perf tool from CORE-MATH project
(https://gitlab.inria.fr/core-math/core-math/-/tree/master) on Ryzen 1700:
Before this patch (not correctly rounded):
```
$ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh sinf
CORE-MATH reciprocal throughput : 17.892
System LIBC reciprocal throughput : 25.559
LIBC reciprocal throughput : 29.381
```
After this patch (correctly rounded):
```
$ CORE_MATH_PERF_MODE="rdtsc" ./perf.sh sinf
CORE-MATH reciprocal throughput : 17.896
System LIBC reciprocal throughput : 25.740
LIBC reciprocal throughput : 27.872
LIBC reciprocal throughput : 20.012 (with `-msse4.2` flag)
LIBC reciprocal throughput : 14.244 (with `-mfma` flag)
```
Reviewed By: zimmermann6
Differential Revision: https://reviews.llvm.org/D123154
zhijian [Fri, 22 Jul 2022 13:55:21 +0000 (09:55 -0400)]
[llvm-ar] Add object mode option -X for AIX
Summary:
1. Added a new option object mode -X for llvm-ar. In AIX OS , there is a object mode option -X for ar command.
please see the "-X mode" part of https://www.ibm.com/docs/ko/aix/7.1?topic=ar-command
Specifies the type of object file ar should examine. The mode must be one of the following:
32
Processes only 32-bit object files
64
Processes only 64-bit object files
32_64
Processes both 32-bit and 64-bit object files
any
Processes all of the supported object files.
The default is to process 32-bit object files (ignore 64-bit objects). The mode can also be set with the OBJECT_MODE environment variable. For example, OBJECT_MODE=64 causes ar to process any 64-bit objects and ignore 32-bit objects. The -X flag overrides the OBJECT_MODE variable.
2. Before adding the new option -X, the default behaviors of llvm-ar like -Xany, but after the adding the new option -X, the default behaviors of llvm-ar change to -X32 ,in order to let some test cases which has 32bit and 64bit object file in the same llvm-ar command, we need to add the "export OBJECT_MODE=any" into test case to change the default behaviors of llvm-ar's object mode.
Reviewers: James Henderson, Owen Reynolds, Fangrui Song
Differential Revision: https://reviews.llvm.org/D127864
Joseph Huber [Thu, 21 Jul 2022 13:02:10 +0000 (09:02 -0400)]
[Libomptarget] Make the plugins link as LLVM libraries
Previously we made `libomptarget` link as an LLVM library so we have
access to the LLVM core libraries. After the initial patch stuck we can
now apply the same changes to the plugins. This will allow us to use
LLVM in all of `libomptarget` when we have uses for them. In the future
this should allow us to remove the dependencies on `libelf`, `libffi`,
and `dl`.
Reviewed By: JonChesterfield
Differential Revision: https://reviews.llvm.org/D130262
Egor Zhdan [Wed, 13 Jul 2022 15:40:24 +0000 (16:40 +0100)]
[Clang][Driver] Fix include paths for `--sysroot /` on OpenBSD/FreeBSD
This is the same change as https://reviews.llvm.org/D126289, but applied for OpenBSD & FreeBSD.
Differential Revision: https://reviews.llvm.org/D129654
Tue Ly [Sat, 16 Jul 2022 02:59:36 +0000 (22:59 -0400)]
[libc] Add float type and flag for nearest_integer to enable SSE4.2.
Add float type and flag for nearest integer to automatically test with
and without SSE4.2 flag.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D129916
Kiran Chandramohan [Fri, 22 Jul 2022 13:03:59 +0000 (13:03 +0000)]
[MLIR][OpenMP] Add a constraint to the Threadprivate Op
Add a constraint to ensure that the operand and result of the
threadprivate operation are the same.
Reviewed By: peixin
Differential Revision: https://reviews.llvm.org/D128609
Kiran Chandramohan [Fri, 22 Jul 2022 12:57:23 +0000 (12:57 +0000)]
[MLIR,OpenMP] : Add Conversion pattern for Critical Op
The Conversion pattern enables conversion of Critical Op with block
arguments.
Fixes https://github.com/llvm/llvm-project/issues/56629
Reviewed By: shraiysh
Differential Revision: https://reviews.llvm.org/D130343
Nikita Popov [Fri, 22 Jul 2022 12:46:01 +0000 (14:46 +0200)]
[LangRef] Update opaque pointers status (NFC)
Opaque pointers support is complete and default. Specify ptr as
the normal pointer type and i8* as something supported under
non-default options.
A larger update of examples in LangRef is still needed.
Kadir Cetinkaya [Thu, 21 Jul 2022 10:43:08 +0000 (12:43 +0200)]
[clangd] Make forwarding parameter detection logic resilient
This could crash when our heuristic picks the wrong function. Make sure
there is enough parameters in the candidate to prevent those crashes.
Also special case copy/move constructors to make the heuristic work in
presence of those.
Fixes https://github.com/llvm/llvm-project/issues/56620
Differential Revision: https://reviews.llvm.org/D130260
Louis Dionne [Wed, 20 Jul 2022 14:42:04 +0000 (10:42 -0400)]
[libc++] Take advantage of -fexperimental-library in libc++
When -fexperimental-library is passed, libc++ will now pick up the
appropriate __has_feature flag defined by Clang to enable the
experimental library features.
As a fly-by, also update the documentation for the various TSes.
Differential Revision: https://reviews.llvm.org/D130176