Commit graph

430808 commits

Author SHA1 Message Date
Peter Klausler cbfc223920 [flang] Fix name of dummy argument to intrinsic NEW_LINE(A='')
It should be A= but I misspelled it in the intrinsics table as X=.

Differential Revision: https://reviews.llvm.org/D130382
2022-07-23 09:30:56 -07:00
John Ericson 32560211c6 Fix one stray {LLVM -> CLANG}_TOOLS_INSTALL_DIR
Follow up to D117977, where I missed this new usage after one rebase.

Thanks @tsteller in https://reviews.llvm.org/D117977#3670919 for
noticing.

Reviewed By: mstorsjo

Differential Revision: https://reviews.llvm.org/D130362
2022-07-23 16:26:32 +00:00
Kazu Hirata 1cc7f5bede Use static_assert instead of assert (NFC)
Identified with misc-static-assert.
2022-07-23 09:22:27 -07:00
Jez Ng d23da0ec6c [lld-macho] Fold __objc_imageinfo sections
Previously, we treated it as a regular ConcatInputSection. However, ld64
actually parses its contents and uses that to synthesize a single image
info struct, generating one 8-byte section instead of `8 * number of
object files with ObjC code`.

I'm not entirely sure what impact this section has on the runtime, so I
just tried to follow ld64's semantics as closely as possible in this
diff. My main motivation though was to reduce binary size.

No significant perf change on chromium_framework on my 16-core Mac Pro:

             base           diff           difference (95% CI)
  sys_time   1.764 ± 0.062  1.748 ± 0.032  [  -2.4% ..   +0.5%]
  user_time  5.112 ± 0.104  5.106 ± 0.046  [  -0.9% ..   +0.7%]
  wall_time  6.111 ± 0.184  6.085 ± 0.076  [  -1.6% ..   +0.8%]
  samples    30             32

Reviewed By: #lld-macho, thakis

Differential Revision: https://reviews.llvm.org/D130125
2022-07-23 12:12:01 -04:00
Simon Pilgrim 676a03d8a5 [X86] matchBinaryShuffle - limit SHUFFLE(X,Y) -> OR(X,Y) cases to where X + Y are the same width as the result
Minor bit of prep work toward not unnecessarily widening shuffle operands in combineX86ShufflesRecursively, instead only widening in combineX86ShuffleChain if we actual find a match - see Issue #45319
2022-07-23 16:56:45 +01:00
Jez Ng b35e0d0cf3 [lld-macho] Fix segfault when handling LTO + object file weak defs
which occurs when there are EH frames present in the object file's weak
def.

Reviewed By: abrachet

Differential Revision: https://reviews.llvm.org/D130409
2022-07-23 11:48:45 -04:00
Dmitry Vassiliev 4acc02357e [IR] Fixed ambiguous call to llvm::report_fatal_error
This patch fixes the following error with MSVC 16.9.2:
llvm/lib/IR/GCStrategy.cpp(35): error C2668: 'llvm::report_fatal_error': ambiguous call to overloaded function
llvm/include/llvm/Support/ErrorHandling.h(75): note: could be 'void llvm::report_fatal_error(const llvm::Twine &,bool)'
llvm/include/llvm/Support/ErrorHandling.h(73): note: or 'void llvm::report_fatal_error(llvm::StringRef,bool)'
llvm/lib/IR/GCStrategy.cpp(35): note: while trying to match the argument list '(const std::string)'

Reviewed By: RKSimon, barannikov88

Differential Revision: https://reviews.llvm.org/D130407
2022-07-23 16:28:18 +02:00
Dmitri Gribenko aba43035bd Use llvm::sort instead of std::sort where possible
llvm::sort is beneficial even when we use the iterator-based overload,
since it can optionally shuffle the elements (to detect
non-determinism). However llvm::sort is not usable everywhere, for
example, in compiler-rt.

Reviewed By: nhaehnle

Differential Revision: https://reviews.llvm.org/D130406
2022-07-23 15:19:05 +02:00
Corentin Jabot e82880e6b8 [Clang] Update the status of N2393 in c_status.html 2022-07-23 15:15:12 +02:00
Dmitri Gribenko cd9a5cfd2e Use the range-based overload of llvm::sort where possible
Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D130403
2022-07-23 15:13:25 +02:00
Simon Pilgrim 5f89d2bae9 [DAG] Move OR(AND(X,C1),AND(OR(X,Y),C2)) -> OR(AND(X,OR(C1,C2)),AND(Y,C2)) fold to SimplifyDemandedBits
This will fix the SystemZ v3i31 memcpy regression in D77804 (with the help of D129765 as well....).

It should also allow us to /bend/ the oneuse limitation for cases where we can use demanded bits to safely peek though multiple uses of the AND ops.
2022-07-23 13:17:24 +01:00
Corentin Jabot 559f07b872 [Clang] Adjust extension warnings for #warning
The #warning directive is standard in C++2b and C2x,
this adjusts the pedantic and extensions warning accordingly.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D130415
2022-07-23 14:10:11 +02:00
Corentin Jabot aee76cb59c [Clang] Add support for Unicode identifiers (UAX31) in C2x mode.
This implements
N2836 Identifier Syntax using Unicode Standard Annex 31.

The feature was already implemented for C++,
and the semantics are the same.

Unlike C++ there was, afaict, no decision to
backport the feature in older languages mode,
so C17 and earlier are not modified and the
code point tables for these language modes are conserved.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D130416
2022-07-23 14:08:08 +02:00
Benjamin Kramer 66e66117ba [bazel] Add missing dependencies after 535b507ba5 2022-07-23 13:25:23 +02:00
Simon Pilgrim 6aff1b7b3c [DAG] SimplifyDemandedBits - pull out repeated getValueType() calls. NFC. 2022-07-23 12:01:54 +01:00
Simon Pilgrim 2421a5af72 [DAG] ExpandIntRes_ADDSUB - create UADDO/USUBO instead of ADDCARRY/SUBCARRY if overflow is known to be zero
As noticed on D127115, when splitting ADD/SUB nodes we often end up with cases where overflow from the lower bits is impossible - in such cases we're better off breaking the carry chain dependency as soon as possible.

This path is being exercised by llvm/test/CodeGen/ARM/dsp-mlal.ll, although I haven't been able to get any codegen diff without a topological worklist.
2022-07-23 11:13:44 +01:00
Dimitrije Milosevic 2bfb0fcb51 [MIPS][compiler-rt] Fix stat struct's size for O32 ABI
Add the MIPS O32 ABI value for the stat struct's size.

Differential Revision: https://reviews.llvm.org/D129749.
2022-07-23 11:53:00 +02:00
Simon Pilgrim 8937252465 [DAG] computeKnownBits - add basic shift-by-parts handling
Concat KnownBits from ISD::SHL_PARTS / ISD::SRA_PARTS / ISD::SRL_PARTS lo/hi operands and perform the KnownBits calculation by the shift amount on the extended type, before splitting the KnownBits based on the requested lo/hi result.
2022-07-23 09:46:30 +01:00
Kazu Hirata 380a1b204c Use callables directly in any_of, count_if, etc (NFC) 2022-07-23 00:28:31 -07:00
Peixin Qiao 3ccd4ce29c [flang] Support aint/anint for 80/128 bit in lowering
For aint/anint, LLVM conversion operations llvm.trunc and llvm.round
can support the edge case of aint(-0.) and anint(-0.). The output is -0.
and it is the same of `gfortran` and `classic flang`, while the output
of `ifort` is 0.. The `real(10)/real(16)` is not supported before.
Support it and remove the runtime functions for aint/anint.

For nint, `gfortran`, `ifort`, and LLVM Flang using llvm.lround have
different results when the magnitude of argument is more than the max of
result value range. So delay its support in lowering after more
investigations.

Reviewed By: vzakhari

Differential Revision: https://reviews.llvm.org/D130024
2022-07-23 14:44:20 +08:00
Kazu Hirata 33c18fbc19 [mlir] Use value instead of getValue (NFC) 2022-07-22 23:33:46 -07:00
Kazu Hirata 6fa6901bf0 Use has_value instead of hasValue (NFC) 2022-07-22 23:04:38 -07:00
Jun Zhang 1a3a2eec71
[NFC] Move function definition to cpp file
Signed-off-by: Jun Zhang <jun@junz.org>
2022-07-23 13:43:42 +08:00
Johannes Doerfert 6b7eae11f1 [Attributor][FIX] HasBeenWrittenTo logic should only be used for reads
If we look at a write, we should not enact the "has been written to"
logic introduced to avoid spurious write -> read dependences. Doing so
lead to elimination of stores we needed, which is obviously bad.
2022-07-22 23:57:57 -05:00
Peter Klausler baec06a9d4 [flang] Fold calls to ISHFTC()
The integer arithmetic template supports ISHFTC() but the
integer intrinsic folding code had yet to call it; finish
the job.

Differential Revision: https://reviews.llvm.org/D130379
2022-07-22 18:21:57 -07:00
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