Commit Graph

430783 Commits

Author SHA1 Message Date
Kazu Hirata 7aa77c5a67 [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]
2022-07-22 17:56:10 -07:00
Ivan Trofimov 15e9b1d0c0 [libasan] Remove 4Mb stack limit for swapcontext unpoisoning
Reviewed By: vitalybuka, eugenis

Differential Revision: https://reviews.llvm.org/D129219
2022-07-22 17:37:44 -07:00
Peter Klausler 60b1fcb1a5 [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
2022-07-22 17:28:08 -07:00
Fangrui Song 80a4e6fd31 [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
2022-07-22 17:16:41 -07:00
Peter Klausler e03664d40c [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
2022-07-22 16:54:46 -07:00
Ilya Leoshkevich 0d89963df3 [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
2022-07-23 01:38:30 +02:00
Dmitri Gribenko b5414b566a [clang][dataflow] Add DataflowEnvironment::dump()
Start by dumping the flow condition.

Reviewed By: ymandel

Differential Revision: https://reviews.llvm.org/D130398
2022-07-23 01:31:53 +02:00
Volodymyr Sapsai 1e4478bbea 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
2022-07-22 16:26:27 -07:00
Peter Klausler c105d9b3d6 [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
2022-07-22 16:21:32 -07:00
Dmitri Gribenko ee6aba85aa [clang][dataflow] Expose stringification functions for SAT solver enums
Reviewed By: ymandel

Differential Revision: https://reviews.llvm.org/D130399
2022-07-23 01:21:20 +02:00
Ryan Prichard b4722cc4c9 [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
2022-07-22 16:20:47 -07:00
Dmitri Gribenko 589ddd7fe8 [clang][dataflow] ArrayRef'ize debugString()
Reviewed By: ymandel

Differential Revision: https://reviews.llvm.org/D130400
2022-07-23 01:16:31 +02:00
Augusto Noronha c18304e600 [lldb] Remote accidental logs left in TestGuiExpandThreadsTree 2022-07-22 16:06:49 -07:00
Augusto Noronha 3b8a1cc38a [lldb] Disable TestGuiExpandThreadsTree 2022-07-22 16:00:51 -07:00
Peter Klausler 0b8377534e [flang] Fold SET_EXPONENT() and FRACTION()
Fold the intrinsic function SET_EXPONENT() and its special case,
FRACTION().

Differential Revision: https://reviews.llvm.org/D130378
2022-07-22 15:44:54 -07:00
Med Ismail Bennani d959324e1e Revert "[lldb/Fuzzer] Add fuzzer for expression evaluator"
This reverts commit b797834748, since it
breaks building Clang: https://reviews.llvm.org/D129377
2022-07-22 15:24:40 -07:00
ARCHIT SAXENA 3bb1ce2319 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
2022-07-22 15:20:10 -07:00
Alexander Shaposhnikov 2ebfda2417 [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
2022-07-22 22:08:53 +00:00
Fangrui Song 8f0c901c1a [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.
2022-07-22 15:07:28 -07:00
Fangrui Song 1f02ba4843 [Driver][SystemZ] Simplify -mtune
Similar to AArch64.
2022-07-22 14:54:27 -07:00
Fangrui Song a4df2da173 [Driver][RISCV] Simplify -mtune 2022-07-22 14:51:07 -07:00
Fangrui Song 12fbd2d377 [Driver][test] Clean up and improve some -mtune tests
Note: we should test CHECK-NOT: "-tune-cpu" instead of CHECK-NOT: "-tune-cpu" "generic"
2022-07-22 14:37:58 -07:00
Chelsea Cassanova b797834748 [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
2022-07-22 17:32:00 -04:00
Fangrui Song 475e526d85 [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.
2022-07-22 14:19:27 -07:00
Kjetil Kjeka ff1920d106 [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
2022-07-22 14:14:12 -07:00
Artem Belevich 35029d8374 Changed EOL to UNIX. NFC. 2022-07-22 14:11:36 -07:00
Greg Clayton dabe877248 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
2022-07-22 14:04:52 -07:00
Greg Clayton 0bbce7a4c2 Fix buildbot breakage after https://reviews.llvm.org/D130309. 2022-07-22 13:59:06 -07:00
Nikolas Klauser 810adeaa69 [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
2022-07-22 22:57:37 +02:00
rkayaith 65aedd338c [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
2022-07-22 16:56:14 -04:00
Vitaly Buka c93e4b6b2c [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
2022-07-22 13:40:16 -07:00
Nuno Lopes 6a1ccf61cd Revert "[NFC] Add some additional features to MultiLevelTemplateArgumentList"
This reverts commit 0b36a62d5f.

It breaks the assertion build
2022-07-22 21:33:22 +01:00
Shangwu Yao 31d8dbd1e5 [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 (
41958f76d8/clang/lib/CodeGen/TargetInfo.cpp (L7241)).

Differential Revision: https://reviews.llvm.org/D130387
2022-07-22 20:30:15 +00:00
Julian Lettner 2f46983981 [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
2022-07-22 13:29:28 -07:00
Greg Clayton f959d815f4 Fix buildbot breakage after https://reviews.llvm.org/D130309. 2022-07-22 13:24:26 -07:00
Erich Keane 0b36a62d5f [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.
2022-07-22 13:05:42 -07:00
Shilei Tian b95d31a849 [OpenMP][Offloading] Enlarge the work size of `wtime.c` in case of any noise 2022-07-22 16:03:39 -04:00
Alexander Yermolovich 6690c64639 Revert "[DWP][DWARF] Detect and error on debug info offset overflow"
This reverts commit 417738d3a6.
2022-07-22 13:02:08 -07:00
Sanjay Patel 08091a99ae Revert "[InstCombine] enhance fold for subtract-from-constant -> xor"
This reverts commit 79bb915fb6.
This caused regressions because SCEV works better with sub.
2022-07-22 15:56:24 -04:00
Erich Keane 70c62f4cad [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.
2022-07-22 12:52:26 -07:00
Erich Keane 3ff86f9610 [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.
2022-07-22 12:37:14 -07:00
Aaron Ballman 7068aa9841 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
2022-07-22 15:24:54 -04:00
Philip Reames b5c7213647 [LV] Use early return to simplify code structure 2022-07-22 12:15:14 -07:00
Alex Brachet a71a01bc10 [CMake] Stop zstd find_package warnings 2022-07-22 19:06:54 +00:00
Fangrui Song 50f5f37b07 [ELF] Internalize isBitcode. NFC 2022-07-22 11:56:46 -07:00
Fangrui Song e8fd49f24b [ELF] --fortran-common: remove unneeded identify_magic call. NFC 2022-07-22 11:54:27 -07:00
Arnold Schwaighofer 58e6ee0e1f 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
2022-07-22 11:50:58 -07:00
Joel E. Denny cfa6e79df3 [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
2022-07-22 14:46:45 -04:00
Sanjay Patel 479c1886c5 [PhaseOrdering] add test for loop-idiom-recognize + tailcall; NFC 2022-07-22 14:27:52 -04:00
Huan Nguyen 8eb68d92d4 [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
2022-07-22 11:24:09 -07:00