Fangrui Song [Fri, 19 May 2023 14:50:29 +0000 (07:50 -0700)]
Change -fsanitize=function to place two words before the function entry
The current implementation of -fsanitize=function places two words (the prolog
signature and the RTTI proxy) at the function entry, which makes the feature
incompatible with Intel Indirect Branch Tracking (IBT) that needs an ENDBR instruction
at the function entry. To allow the combination, move the two words before the
function entry, similar to -fsanitize=kcfi.
Armv8.5 Branch Target Identification (BTI) has a similar requirement.
Note: for IBT and BTI, whether a function gets a marker instruction at the entry
generally cannot be assumed (it can be disabled by a function attribute or
stronger LTO optimizations).
It is extremely unlikely for two words preceding a function entry to be
inaccessible. One way to achieve this is by ensuring that a function is
aligned at a page boundary and making the preceding page unmapped or
unreadable. This is not reasonable for application or library code.
(Think: the first text section has crt* code not instrumented by
-fsanitize=function.)
We use 0xc105cafe for all targets. .long 0xc105cafe disassembles to invalid
instructions on all architectures I have tested, except Power where it is
`lfs 8, -13570(5)` (Load Floating-Point with a weird offset, unlikely to be used in real code).
---
For the removed function in AsmPrinter.cpp, remove an assert: `mdconst::extract`
already asserts non-nullness.
For compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp,
when the function doesn't have prolog/epilog (-O1 and above), after moving the two words,
the address of the function equals the address of ret instruction,
so symbolizing the function will additionally get a non-zero column number.
Adjust the test to allow an optional column number.
```
.long
3238382334
.long .L__llvm_rtti_proxy-_Z1fv
_Z1fv: // symbolizing here retrieves the line table entry from the second .loc
.file 0 ...
.loc 0 1 0
.cfi_startproc
.loc 0 2 1 prologue_end
retq
```
Reviewed By: peter.smith
Differential Revision: https://reviews.llvm.org/D148665
Jay Foad [Fri, 19 May 2023 14:46:11 +0000 (15:46 +0100)]
[GVN] Simplify presplit coroutine handling. NFC.
Alex Bradbury [Fri, 19 May 2023 14:28:42 +0000 (15:28 +0100)]
[RISCV][MC] Add support for experimental Zvfbfwma extension
Provides MC layer support for Zvfbfwma: vector BF16 widening mul-add.
As currently specified, Zvfbfwma does not appear to have a dependency on
Zvfbfmin or Zfbfmin.
Differential Revision: https://reviews.llvm.org/D147612
Jacob Crawley [Thu, 18 May 2023 15:35:36 +0000 (15:35 +0000)]
[flang] Change return type of reduction intrinsics
Comments in the recent patch https://reviews.llvm.org/D149964,
mentioned that using hlfir_ExprType in cases where intrinsics
return simple scalars adds unnecessary abstraction that isn't
needed unless an array type is being used.
This patch modifies the HLFIR operations for product, sum and any
so that they only return a hlfir_ExprType when the result is an array,
otherwise they will return just the simple scalar type.
Differential Revision: https://reviews.llvm.org/D150877
Roy Jacobson [Fri, 5 May 2023 14:50:50 +0000 (17:50 +0300)]
[Sema] Mark ineligibility of special member functions correctly
I checked if the member function declaration was a copy constructor, but it's not sufficient; We need to check
the arguments against the instantiated class.
Fixed https://github.com/llvm/llvm-project/issues/62555
Reviewed By: erichkeane
Differential Revision: https://reviews.llvm.org/D149961
Alex Bradbury [Fri, 19 May 2023 14:26:25 +0000 (15:26 +0100)]
[RISCV][MC] Add support for experimental Zvfbfmin extension
Provides MC layer support for Zfbfmin: vector BF16 conversions.
Zvfbfmin does not appear to have a dependency on Zfbfmin as currently
specified.
Differential Revision: https://reviews.llvm.org/D147611
Shengchen Kan [Fri, 19 May 2023 14:21:56 +0000 (22:21 +0800)]
Revert "Revert "[X86] Remove patterns for ADC/SBB with immediate 8 and optimize during MC lowering, NFCI""
This reverts commit
cb16b33a03aff70b2499c3452f2f817f3f92d20d.
In fact, the test https://bugs.chromium.org/p/chromium/issues/detail?id=1446973#c2
already passed after
5586bc539acb26cb94e461438de01a5080513401
Alex Bradbury [Fri, 19 May 2023 14:16:38 +0000 (15:16 +0100)]
[RISCV][MC] Add support for experimental Zfbfmin extension
Provides MC layer support for Zfbfmin: scalar BF16 conversions.
As documented, this extension includes FLH, FSH, FMV.H.X, and FMH.X.H as
defined in Zfh/Zfhmin, but doesn't require either extension.
No Zfbfinxmin has been defined (though you would expect one in the
future, for symmetry with Zfhinxmin). See issue
https://github.com/riscv/riscv-bfloat16/issues/27.
Differential Revision: https://reviews.llvm.org/D147610
Jay Foad [Fri, 19 May 2023 14:07:31 +0000 (15:07 +0100)]
[GVN] No else after return. NFC.
Jean Perier [Fri, 19 May 2023 08:24:25 +0000 (10:24 +0200)]
[flang][hlfir] Implement hlfir.forall codegen when no temp is required
The patch applies the schedule built with the utility added in the
previous D150455 patch to generate the code for an ordered assignment
tree. For now, it only supports forall that do not contain user defined
assignments or assignments to vector subscripted entities, and for
which the scheduling analysis does not require temporary storages.
Support for temporary, WHERE, and user-defined/vector subscript
assignment will be added in later patches.
This enables end-to-end support with HLFIR for forall where the schedule
analysis can prove there is no need to create temporary storage.
Differential Revision: https://reviews.llvm.org/D150564
Luke Lau [Tue, 2 May 2023 13:08:17 +0000 (14:08 +0100)]
[RISCV] Add test for unprofitable SLP vectorization
Reviewed By: ABataev
Differential Revision: https://reviews.llvm.org/D149653
Luke Lau [Wed, 17 May 2023 12:01:08 +0000 (13:01 +0100)]
[RISCV] Add tests for store merging with unaligned scalar access
Reviewed By: reames
Differential Revision: https://reviews.llvm.org/D150770
Nico Weber [Fri, 19 May 2023 13:40:06 +0000 (09:40 -0400)]
Revert "[RFC][MC][MachO]Only emits compact-unwind format for "canonical" personality symbols. For the rest, use DWARFs."
This reverts commit
09aaf53a05e3786eea374f3ce57574225036412d.
Causes toolchain asserts building libc++ for x86_64,
see https://reviews.llvm.org/D144999#4356215
LLVM GN Syncbot [Fri, 19 May 2023 13:23:07 +0000 (13:23 +0000)]
[gn build] Port
094ab4781262
Thomas Preud'homme [Thu, 18 May 2023 09:10:21 +0000 (09:10 +0000)]
Add control of hex casing in APInt::toString
This will be used in implementing arbitrary precision support to
FileCheck's numeric variables and expressions.
Reviewed By: foad, RKSimon
Differential Revision: https://reviews.llvm.org/D150879
Jun Zhang [Fri, 19 May 2023 12:56:21 +0000 (20:56 +0800)]
Revert "Reland [clang-repl] Introduce Value to capture expression results"
This reverts commit
d71a4e02277a64a9dece591cdf2b34f15c3b19a0.
See http://45.33.8.238/macm1/61024/step_7.txt
Zequan Wu [Wed, 17 May 2023 21:06:42 +0000 (17:06 -0400)]
Use windows baskslash on anonymous tag locations if using MSVCFormatting and it's not absolute path.
This fixes a nondeterminism on debug info when building on windows natively vs
cross building to windows.
[1] https://github.com/llvm/llvm-project/blob/llvmorg-17-init/clang/lib/Lex/HeaderSearch.cpp#L465
Differential Revision: https://reviews.llvm.org/D150817
Hans Wennborg [Fri, 19 May 2023 12:29:06 +0000 (14:29 +0200)]
Revert "[X86] Remove patterns for ADC/SBB with immediate 8 and optimize during MC lowering, NFCI"
This caused compiler assertions, see comment on
https://reviews.llvm.org/D150107.
This also reverts the dependent follow-up change:
> [X86] Remove patterns for ADD/AND/OR/SUB/XOR/CMP with immediate 8 and optimize during MC lowering, NFCI
>
> This is follow-up of D150107.
>
> In addition, the function `X86::optimizeToFixedRegisterOrShortImmediateForm` can be
> shared with project bolt and eliminates the code in X86InstrRelaxTables.cpp.
>
> Differential Revision: https://reviews.llvm.org/D150949
This reverts commit
2ef8ae134828876ab3ebda4a81bb2df7b095d030 and
5586bc539acb26cb94e461438de01a5080513401.
Kiran Chandramohan [Fri, 19 May 2023 11:51:58 +0000 (11:51 +0000)]
[Flang][OpenMP] Add Todo for doconcurrent with worksharing loop
This is a valid usage. We do not handle it as of now. Gfortran/Ifx produces an error, possibly because `do concurrent` was not allowed in previous versions of the OpenMP standard.
Fixes #62649
Reviewed By: Leporacanthicus
Differential Revision: https://reviews.llvm.org/D150869
Goran Flegar [Fri, 19 May 2023 12:00:38 +0000 (14:00 +0200)]
[mlir][linalg] Fix unused variable on opt build
Dominik Adamski [Fri, 19 May 2023 11:42:16 +0000 (06:42 -0500)]
[MLIR][OpenMP][OMPIRBuilder] Lower OpenMP version attributes to LLVM IR
MLIR version attribute should be lowered to LLVM IR module metadata.
The lowering is done by OpenMPIRBuilder.
Differential Revision: https://reviews.llvm.org/D150574
Reviewed By: kiranchandramohan
Kiran Chandramohan [Fri, 19 May 2023 10:30:15 +0000 (10:30 +0000)]
Revert "[mlir] Fix memory explosion when converting global variable bodies in ModuleTranslation"
Reverting due to failure in spec cam4 benchmark. See github issue
https://github.com/llvm/llvm-project/issues/62802 for details.
This reverts commit
095e6ac9fd92d03dcb1e19b60cb06a8140aae69d.
Dominik Adamski [Fri, 19 May 2023 11:14:52 +0000 (06:14 -0500)]
[OpenMP][MLIR][Flang][bbc][Driver] Add fopenmp-version and generate corresponding MLIR attribute
This patch adds flag -fopenmp-version to the Flang frontend and bbc tool.
This flag is lowered to MLIR OpenMP flag attribute.
Differential Revision: https://reviews.llvm.org/D150354
Reviewed By: kiranchandramohan
Benjamin Kramer [Fri, 19 May 2023 11:19:18 +0000 (13:19 +0200)]
Enna1 [Fri, 19 May 2023 11:18:28 +0000 (19:18 +0800)]
[IR] Adds Instruction::setNoSanitizeMetadata()
This patch adds a new method setNoSanitizeMetadata() for Instruction, and use it in SanitizerMetadata and SanitizerCoverage.
Reviewed By: nickdesaulniers, MaskRay
Differential Revision: https://reviews.llvm.org/D150632
Dominik Adamski [Tue, 9 May 2023 12:26:09 +0000 (07:26 -0500)]
[OpenMP][MLIR] Add OpenMP version attribute to OMP OffloadModuleInterface
The intent of OpenMP version attribute is to be applied to a module
and then hold information on OpenMP version flag.
Information about OpenMP version can be specified in Clang
by flag -fopenmp-version and it is stored in LLVM-IR module metadata:
!llvm.module.flags = !{!0, !1}
!0 = !{i32 7, !"openmp", i32 51}
!1 = !{i32 7, !"openmp-device", i32 51}
OpenMP MLIR version attributes will allow to lower Flang frontend flag
to OpenMP MLIR code and then to LLVM IR.
There are two OpenMP MLIR version attributes. The first one "omp.version"
MLIR attribute corresponds to host OpenMP version. The second one
corresponds to "openmp-device" LLVM-IR metadata. "openmp-device" LLVM-IR
metadata is attached only for offloaded code.
Differential Revision: https://reviews.llvm.org/D150351
Reviewed By: kiranchandramohan
Stephen Tozer [Thu, 18 May 2023 16:13:15 +0000 (17:13 +0100)]
[DebugInfo][InstrRef] Handle non-directly reachable DBG_PHIs in LiveDebugValues
Fixes: https://github.com/llvm/llvm-project/issues/62725
This patch fixes an error in which a DBG_INSTR_REF referring to a DBG_PHI in a
block that is not directly reachable from the entry block results in a crash
during LiveDebugValues. Note that this fix prevents a crash from occurring, but
will give undef locations to users of these PHIs even if a valid location exists.
Reviewed By: jmorse
Differential Revision: https://reviews.llvm.org/D150707
Shengchen Kan [Fri, 19 May 2023 05:26:45 +0000 (13:26 +0800)]
[X86] Remove patterns for ADD/AND/OR/SUB/XOR/CMP with immediate 8 and optimize during MC lowering, NFCI
This is follow-up of D150107.
In addition, the function `X86::optimizeToFixedRegisterOrShortImmediateForm` can be
shared with project bolt and eliminates the code in X86InstrRelaxTables.cpp.
Differential Revision: https://reviews.llvm.org/D150949
Thomas Symalla [Mon, 8 May 2023 18:50:20 +0000 (20:50 +0200)]
[AMDGPU] Improve abs modifier usage
If a call to the llvm.fabs intrinsic has users in another reachable
BB, SelectionDAG will not apply the abs modifier to these users and
instead generate a v_and ..., 0x7fffffff instruction.
For fneg instructions, the issue is similar.
This patch implements `AMDGPUIselLowering::shouldSinkOperands`,
which allows CodegenPrepare to call `tryToSinkFreeOperands`.
Reviewed By: foad
Differential Revision: https://reviews.llvm.org/D150347
Simon Pilgrim [Fri, 19 May 2023 09:40:14 +0000 (10:40 +0100)]
Fix MSVC "not all control paths return a value" warning. NFC.
Simon Pilgrim [Fri, 19 May 2023 09:39:31 +0000 (10:39 +0100)]
Add missing llvm/Support/Compiler.h include for MSVC builds without __has_attribute
Thomas Symalla [Fri, 19 May 2023 09:27:28 +0000 (11:27 +0200)]
[NFC] Fix typo in CodeGenPrepare.cpp
Jay Foad [Mon, 15 May 2023 16:06:07 +0000 (17:06 +0100)]
[M68k] Do not require register scavenging during PEI
Nothing in this target appears to use the scavenger.
Differential Revision: https://reviews.llvm.org/D150584
Hristo Hristov [Thu, 18 May 2023 18:23:01 +0000 (21:23 +0300)]
[libc++][ranges][NFC] Added P2711R1 to release notes
This adds release notes for P2711R.
`join_with_view` is missing an implementation yet.
Implemented in: https://reviews.llvm.org/D144822
Reviewed By: #libc, Mordante
Differential Revision: https://reviews.llvm.org/D150845
Thurston Dang [Fri, 19 May 2023 06:54:29 +0000 (06:54 +0000)]
sanitizer_common: fix buildbot by restoring wcslen semantics
Windows buildbot (https://lab.llvm.org/buildbot/#/builders/127/builds/48479)
was broken by my patch https://reviews.llvm.org/D150909 because it
gated wcslen interception to SI_POSIX, instead of always intercepting wcslen.
This changes it back to always intercepting wcslen.
luxufan [Fri, 19 May 2023 05:35:55 +0000 (13:35 +0800)]
[ValueTracking][InstCombine] Add a new API to allow to ignore poison generating flags or metadatas when implying poison
This patch add a new API `impliesPoisonIgnoreFlagsOrMetadatas` which is
the same as `impliesPoison` but ignoring poison generating flags or
metadatas in the process of implying poison and recording these ignored
instructions.
In InstCombineSelect, replacing `impliesPoison` with
`impliesPoisonIgnoreFlagsOrMetadatas` to allow more patterns like
`select i1 %a, i1 %b, i1 false` to be optimized to and/or instructions
by droping the poison generating flags or metadatas.
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D149404
Yeting Kuo [Mon, 24 Apr 2023 15:56:40 +0000 (23:56 +0800)]
[ASAN] Support memory checks on experimental.vp.strided.load/store.
The patch adds new member MaybeStride into InterestingMemoryOperand to represent
the stride value of experimental.vp.strided.load/store.
Reviewed By: reames
Differential Revision: https://reviews.llvm.org/D149073
Thurston Dang [Thu, 18 May 2023 21:30:28 +0000 (21:30 +0000)]
sanitizer_common: guard the wcslen interceptor code with SANITIZER_INTERCEPT_WCSLEN
This patch adds the #if SANITIZER_INTERCEPT_ guard for wcslen, similarly to how all the other
functions are guarded. It was the only missing SANITIZER_INTERCEPT_ guard [1].
This missing guard was discovered while investigating the stage2/hwasan check failure of https://reviews.llvm.org/D150708 ("hwasan: lay groundwork for importing subset of sanitizer_common interceptors [NFC]"), that was seen in https://lab.llvm.org/buildbot/#/builders/236/builds/4069. llvm_build_hwasan/unittests/ADT/./ADTTests had crashed with a backtrace of:
...
A disassembly of the binary showed that wcslen interception was present (since it was not guarded by SANITIZER_INTERCEPT_WCSLEN); howver, since INIT_WCSLEN was not called, REAL(wcslen) was null, resulting in the null pointer dereference.
[1] I checked this using "egrep '^#[ ]*define[ ]+(INIT_.*)' sanitizer_common_interceptors.inc | tr -s ' ' | sed -r 's/^# /#/' | cut -d ' ' -f 2 | sort | uniq -c | grep -v '^[ ]*2[ ]'"
The other matches are {INIT_PTHREAD_SETNAME_NP, INIT_QSORT, INIT_SHA2_INTECEPTORS(LEN), INIT_TLS_GET_ADDR, INIT_WAIT4}, which all have good reasons for not having exactly two cases.
Differential Revision: https://reviews.llvm.org/D150909
Alina Sbirlea [Fri, 19 May 2023 04:48:01 +0000 (21:48 -0700)]
Revert "ValueTracking: Delete body of isKnownNeverInfinity"
This reverts commit
73925ef8b0eacc6792f0e3ea21a3e6d51f5ee8b0.
Introduces test failures, mismatch inf/nan
Alina Sbirlea [Fri, 19 May 2023 04:47:29 +0000 (21:47 -0700)]
Revert "SimplifyLibCalls: Pass AssumptionCache to isKnownNeverInfinity"
This reverts commit
faa32734bf9a55fa3f91d91f6fdf0f8a951a9c0e.
Revert due to test failures introduced by
73925ef8b0eacc6792f0e3ea21a3e6d51f5ee8b0
Alina Sbirlea [Fri, 19 May 2023 04:42:39 +0000 (21:42 -0700)]
Revert "InstSimplify: Pass AssumptionCache to isKnownNeverInfinity"
This reverts commit
0012b94a4e8e0c757ef0adcd68fb61bb0318b26c.
Reverting due to test failures introduced by
73925ef8b0eacc6792f0e3ea21a3e6d51f5ee8b0
Updated floating-point-compare.ll to keep the assume declaration.
Siva Chandra Reddy [Thu, 18 May 2023 06:26:18 +0000 (06:26 +0000)]
[libc] Add a str() method to FPBits which returns a string representation.
Unit tests for the str() method have also been added.
Previously, a separate test only helper function was being used by the
test matchers which has regressed over many cleanups. Moreover, being a
test only utility, it was not tested separately (and hence the
regression).
Reviewed By: michaelrj
Differential Revision: https://reviews.llvm.org/D150906
Sameer Sahasrabuddhe [Fri, 19 May 2023 06:19:09 +0000 (11:49 +0530)]
[AMDGPU][Uniformity] SI_IF and SI_ELSE pseudos are always divergent
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D150861
Jianjian GUAN [Thu, 18 May 2023 09:32:21 +0000 (17:32 +0800)]
[RISCV] Refactor predicates for rvv VL patterns.
This patch is similar to https://reviews.llvm.org/D150550 and https://reviews.llvm.org/D150754, it adds accurate predicates for VL patterns depending on vector type.
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D150850
Job Noorman [Fri, 19 May 2023 05:41:17 +0000 (07:41 +0200)]
[JITLink][AArch64] Implement R_AARCH64_TSTBR14
This relocation is used for the 14-bit immediate in test and branch
instructions.
Reviewed By: lhames
Differential Revision: https://reviews.llvm.org/D150778
Jianjian GUAN [Thu, 18 May 2023 07:12:17 +0000 (15:12 +0800)]
[RISV] Fix the foreach scope.
Move all independent definations out of the foreach scope.
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D150847
LLVM GN Syncbot [Fri, 19 May 2023 05:41:29 +0000 (05:41 +0000)]
[gn build] Port
d71a4e02277a
Jun Zhang [Thu, 18 May 2023 12:45:56 +0000 (20:45 +0800)]
Reland [clang-repl] Introduce Value to capture expression results
This reverts commit
7158fd381a0bc0222195d6a07ebb42ea57957bda.
* Fixes endianness issue on big endian machines like PowerPC-bl
* Disable tests on platforms that having trouble to support JIT
Signed-off-by: Jun Zhang <jun@junz.org>
khei4 [Fri, 19 May 2023 05:10:02 +0000 (14:10 +0900)]
[SimplifyCFG] add nuw/nsw on BuildLookuptable BitMap shiftwidth calculation
Differential Revision: https://reviews.llvm.org/D150838
Shengchen Kan [Fri, 19 May 2023 02:30:44 +0000 (10:30 +0800)]
[X86] Remove patterns for ADC/SBB with immediate 8 and optimize during MC lowering, NFCI
This is follow-up of D150107.
Vadim Paretsky [Fri, 19 May 2023 01:56:25 +0000 (18:56 -0700)]
[OpenMP] remove usage of std::abs in the new loop collapse support code
On some platforms, std::abs may inadvertently pull in a math library.
This patch replaces its use in the new loop collapse code with
a no thrills in-situ implementation.
Differential Revision: https://reviews.llvm.org/D150882
wanglei [Thu, 18 May 2023 12:41:58 +0000 (20:41 +0800)]
[LoongArch] Handle out-fo-range uimm8 operands in LoongArchAsmParser
With this fix, when encountering an out-of-range uimm8 operand, the code
now triggers an appropriate error message, clearly indicating that the
immediate value must be an integer within the range of 0 to 255.
Manna, Soumi [Fri, 19 May 2023 01:13:58 +0000 (18:13 -0700)]
[NFC][Clang][Coverity] Fix Static Code Analysis Concerns with copy without assign
This patch adds copy/move assignment operator to the class which has user-defined copy/move constructor.
Reviewed By: tahonermann, NoQ, aaronpuchert
Differential Revision: https://reviews.llvm.org/D150411
Mitch Phillips [Thu, 18 May 2023 23:32:55 +0000 (16:32 -0700)]
[HWASan] Ignore shortgranules for global tag selection
Tag selection for global variables is sequential, starting at a
pseduo-ish seed that's based on the hash of the file name.
Previously, it was possible for a global to be assigned a tag in the
range [1,15]. If the global's size was not a multiple of granules (i.e.
`size % 16 != 0`), then the last granule of the global would be assigned
a short granule tag as well.
If the real memory tag of the global (e.g. '04') happened to collide
with the short granule tag (e.g. '04'), then __hwasan_check would
see that the memory tag matched the short granule tag, and dutifully
assume (in this fast check) that everthing is okay.
Unfortunately, if you tried to access the [5,15]th byte, you never get
to the short granule check. This means you miss intra-granule overflows
on the last granule of a global, if said global was assigned a real
memory tag in the range [1,15].
This causes flakiness in certain global tests, if the SHA of the
filename changes between runs.
This problem also exists for heap and stack allocations as well, but
there's a concern that if we exclude the [1,15] range for heap and stack
that it's an unhappy tradeoff. On Android, this would mean that a 1/255
chance of false positive becomes 1/240. On other platforms though (that
have a less-than-8-bit tag space), this may be unacceptable. We can
think about potential fixes for that in other places, but globals are
fine to reduce the space, as really the only thing that matters is
catching sequential overflow. The false-negative scenario is much, much
more common in use-after-free and use-after-scope, which globals don't
have.
Differential Revision: https://reviews.llvm.org/D150742
Vitaly Buka [Thu, 18 May 2023 23:32:36 +0000 (16:32 -0700)]
[test][HWASAN] Test for globals with short granules
Artem Dergachev [Thu, 18 May 2023 23:00:25 +0000 (16:00 -0700)]
[-Wunsafe-buffer-usage] Hide fixits/suggestions behind an extra flag.
This patch implements a new clang driver flag -fsafe-buffer-usage-suggestions
which allows turning the smart suggestion machine on and off (defaults to off).
This is valuable for stability reasons, as the machine is being rapidly improved\
and we don't want accidental breakages to ruin the build for innocent users.
It is also arguably useful in general because it enables separation of concerns
between project contributors: some users will actively update the code to
conform to the programming model, while others simply want to make sure that
they aren't regressing it. Finally, there could be other valid reasons to
opt out of suggestions entirely on some codebases (while continuing to enforce
-Wunsafe-buffer-usage warnings), such as lack of access to hardened libc++
(or even to the C++ standard library in general) on the target platform.
When the flag is disabled, the unsafe buffer usage analysis is reduced to
an extremely minimal mode of operation that contains virtually no smarts:
not only it doesn't offer automatic fixits, but also textual suggestions
such as "change the type of this variable to std::span to preserve bounds
information" are not displayed, and in fact the machine doesn't even try
to blame specific variables in the first place, it simply warns on
the operations and leaves everything else to the user. So this flag turns off
a lot more of our complex machinery than what we already turn off in presence
of say -fno-diagnostic-fixit-info.
The flag is discoverable: when it's off, the warnings are accompanied by a note:
telling the user that there's a flag they can use.
Differential Revision: https://reviews.llvm.org/D146669
Craig Topper [Fri, 19 May 2023 00:10:18 +0000 (17:10 -0700)]
[RISCV] Fix incorrect check-prefixes in attr-riscv-rvv-vector-bits-types.c. NFC
wren romano [Thu, 18 May 2023 23:17:04 +0000 (16:17 -0700)]
[mlir][sparse] Adding SparseTensorEncodingAttr::getDimSlice
This helps catch segfaults and OOB.
Reviewed By: aartbik, Peiming
Differential Revision: https://reviews.llvm.org/D150917
Kai Sasaki [Thu, 18 May 2023 23:23:46 +0000 (08:23 +0900)]
[mlir][bufferization] Prevent crash in one shot bufferization with unranked tensor cast
One shot bufferization does not support bufferizing the cast between unranked tensors. To prevent the crash, we can check the compatibility of the result type in advance. Reported in https://github.com/llvm/llvm-project/issues/62369.
Reviewed By: springerm
Differential Revision: https://reviews.llvm.org/D149239
Matt Arsenault [Wed, 12 Apr 2023 01:23:16 +0000 (21:23 -0400)]
InstSimplify: Pass AssumptionCache through fcmp ord/uno simplification
Matt Arsenault [Tue, 11 Apr 2023 23:54:22 +0000 (19:54 -0400)]
InstSimplify: Pass AssumptionCache to isKnownNeverNaN queries
Matt Arsenault [Tue, 11 Apr 2023 23:25:37 +0000 (19:25 -0400)]
InstSimplify: Pass AssumptionCache through more isKnownNeverNaN queries
Matt Arsenault [Tue, 11 Apr 2023 20:53:02 +0000 (16:53 -0400)]
InstSimplify: Pass AssumptionCache to isKnownNeverInfinity
Makes these cases work with assumes.
Spenser Bauman [Thu, 18 May 2023 23:16:10 +0000 (16:16 -0700)]
[mlir][tosa] Fix constant folding of tosa.mul
The constant folder for tosa.mul produces a tensor attribute whose type
may not match the result type of the operation when broadcasting is
needed. This results in a tosa.const op whose attribute's type does not
match the type of the const op.
This change explicitly expands the attribute to the expected result
type.
Reviewed By: eric-k256, jpienaar
Differential Revision: https://reviews.llvm.org/D150439
Yi Kong [Thu, 18 May 2023 23:26:27 +0000 (16:26 -0700)]
Revert "Reland "[BOLT] Parallelize legacy profile merging""
This reverts commit
611fb179b19857ffb87df81c926902fc7e3412ab.
Broken tests
Alex Langford [Thu, 18 May 2023 22:31:25 +0000 (15:31 -0700)]
[lldb][NFCI] Pre-allocate storage in ObjCLanguage::MethodName::GetFullNameWithoutCategory
The size of a full ObjC MethodName can vary somewhat, but it is
computable ahead of time.
Using a reasonably sized ObjC application, this actually improves the
time it takes to initialize symbol indexes for ObjC names ever so
slightly. Additionally, I found that the variability in time also was
improved considerably.
Differential Revision: https://reviews.llvm.org/D150914
Valentin Clement [Thu, 18 May 2023 23:20:57 +0000 (16:20 -0700)]
[mlir][openacc] Add reduction representation
Similarly to D150622 for private clause, the reduction is currently not
modeled in a good way. This patch is inspired by the reduction representation
in the omp dialect (D105358) and make a new representation for the reduction in
the OpenACC dialect.
A new operation is introduced to model the sequences of operation needed to
initialize a local reduction value and how to combine two values during the
reduction. The operation requires two mandatory regions.
1. The init region specifies how to initialize the local reduction
value. The region has an argument that contains the value of the
reduction accumulator at the start of the reduction. It is expected to
`acc.yield` the new value.
2. The reduction region contains a sequences of operations to combine two
values of the reduction type into one. It has two arguments and it is
expected to `acc.yield` the combined value.
Example:
```mlir
acc.reduction.recipe @reduction_add_i64 : i64 init reduction_operator<add> {
^bb0(%0: i64):
// init region contains a sequence of operations to initialize the local
// reduction value as specified in 2.5.15
%c0 = arith.constant 0 : i64
acc.yield %c0 : i64
} reduction {
^bb0(%0: i64, %1: i64)
// reduction region contains a sequence of operations to combine
// two values into one.
%2 = arith.addi %0, %1 : i64
acc.yield %2 : i64
}
// The reduction symbol is then used in the corresponding operation.
acc.parallel reduction(@reduction_add_i64 -> %a : i64) {
}
Reviewed By: razvanlupusoru, vzakhari
Differential Revision: https://reviews.llvm.org/D150818
Yi Kong [Fri, 28 Apr 2023 12:26:16 +0000 (21:26 +0900)]
Reland "[BOLT] Parallelize legacy profile merging"
This reverts commit
78d8d016490909ac759c6f76c5f8679bc7a58b2e.
Heejin Ahn [Mon, 15 May 2023 20:12:43 +0000 (13:12 -0700)]
[RegisterCoalescer] Remove DbgMergedVRegNums (NFC)
Not sure what this was originally intended for, but this seems to be
unused. It didn't seem to be used when it was first added in D64630
either.
Reviewed By: jmorse
Differential Revision: https://reviews.llvm.org/D150606
Heejin Ahn [Tue, 25 Apr 2023 08:44:25 +0000 (01:44 -0700)]
[DebugInfo][InstrRef] Prettyprint metadata
Some metadata prettyprinting, including variable prettyprinting and
debug line info comments, is currently only supported for `DBG_VALUE`.
This allows `DBG_INSTR_REF` can be printed in the same way.
Reviewed By: jmorse
Differential Revision: https://reviews.llvm.org/D150620
Slava Zakharin [Thu, 18 May 2023 21:51:45 +0000 (14:51 -0700)]
[flang] Fixed initialization of c_ptr/c_funptr arrays.
When lowering ends up outlining the initialization of an entity
containing an array of c_ptr/c_funptr it is treating the array
initializer as scalar due to the missing check for the rank.
When initializing non-0 rank c_ptr/c_funptr entity it has to
recurse via genConstantValue().
Reviewed By: clementval
Differential Revision: https://reviews.llvm.org/D150903
Craig Topper [Thu, 18 May 2023 22:47:29 +0000 (15:47 -0700)]
[RISCV] Remove unused CHECK-ILP lines from attr-riscv-rvv-vector-bits-types.c. NFC
I must have copied these from SVE by accident. They aren't relevant
for RISC-V.
Nikolas Klauser [Wed, 17 May 2023 17:34:51 +0000 (10:34 -0700)]
[libc++][NFC] Rename iterator category checks to make it obvious that they check //only// the iterator category
We plan to add concepts for checking that iterators actually provide what they claim to. This is to avoid people thinking that these type traits actually check the iterator requirements in more detail.
Reviewed By: ldionne, #libc
Spies: Mordante, libcxx-commits, wenlei
Differential Revision: https://reviews.llvm.org/D150801
Hanhan Wang [Tue, 16 May 2023 21:08:44 +0000 (14:08 -0700)]
[mlir][linalg] Fix tensor.pad sizes computation in lowerPack.
The padded sizes should be derived from destination tensor, not source
tensor. There could be more than one incomplete tile in padding domain.
Reviewed By: qedawkins
Differential Revision: https://reviews.llvm.org/D150726
Dave Lee [Thu, 18 May 2023 22:30:07 +0000 (15:30 -0700)]
[lldb] Remove decl for non-existent ResolveSymbolContextForAddress overload (NFC)
Matt Arsenault [Tue, 11 Apr 2023 20:41:02 +0000 (16:41 -0400)]
InstSimplify: Use isKnownNeverInfOrNaN
Matt Arsenault [Tue, 11 Apr 2023 20:32:50 +0000 (16:32 -0400)]
InstSimplify: Combine computeKnownFPClass calls and pass AssumptionCache
Matt Arsenault [Fri, 5 May 2023 15:25:29 +0000 (11:25 -0400)]
AMDGPU: Pattern match fract instructions in AMDGPUCodeGenPrepare
This will allow eliminating the intrinsic uses in the device
libraries, which will remove a subtarget dependency on the f16
version of the intrinsic.
We previously had some wrong patterns for this under unsafe math
which I've removed.
Do it in IR partially to take advantage of the much better isKnownNeverNaN
handling, and partially out of laziness to avoid repeating this in the DAG
and GlobalISel path. Plus I think this should be done much earlier. Ideally
this would be in InstCombine, but you can't introduce target intrinsics
from a generic instruction rooted pattern.
Alex Langford [Wed, 17 May 2023 17:44:38 +0000 (10:44 -0700)]
[lldb] Guarantee the lifetimes of all strings returned from SBAPI
LLDB should guarantee that the strings returned by SBAPI methods
live forever. I went through every method that returns a string and made
sure that it was added to the ConstString StringPool before returning if
it wasn't obvious that it was already doing so.
I've also updated the docs to document this behavior.
Differential Revision: https://reviews.llvm.org/D150804
Hanhan Wang [Fri, 12 May 2023 23:26:30 +0000 (16:26 -0700)]
[mlir][linalg] Add support for dynamic pad op masking vectorization.
Reviewed By: dcaballe, awarzynski
Differential Revision: https://reviews.llvm.org/D150497
wren romano [Wed, 17 May 2023 20:23:04 +0000 (13:23 -0700)]
[mlir][sparse] Adjusting error message wording, to better match new field names
This is a followup to D150330, split out because it's not purely mechanical.
Depends On D150330
Reviewed By: aartbik
Differential Revision: https://reviews.llvm.org/D150409
Alex Langford [Thu, 4 May 2023 00:09:32 +0000 (17:09 -0700)]
[lldb] Refactor ObjCLanguage::MethodName
The goal of this patch is to make it easier to reason about the state of
ObjCLanguage::MethodName. I do that in several ways:
- Instead of using the constructor directly, you go through a factory
method. It returns a std::optional<MethodName> so either you got an
ObjCLanguage::MethodName or you didn't. No more checking if it's valid
to know if you can use it or not.
- ObjCLanguage::MethodName is now immutable. You cannot change its
internals once it is created.
- ObjCLanguage::MethodName::GetFullNameWithoutCategory previously had a
parameter that let you get back an empty string if the method had no
category. Every caller of this method was enabling this behavior so I
dropped the parameter and made it the default behavior.
- No longer store all the various components of the method name as
ConstStrings. The relevant `Get` methods now return llvm::StringRefs
backed by the MethodName's internal storage. The lifetime of these
StringRefs are tied to the MethodName itself, so if you need to
persist these you need to create copies.
Differential Revision: https://reviews.llvm.org/D149914
LLVM GN Syncbot [Thu, 18 May 2023 21:29:09 +0000 (21:29 +0000)]
[gn build] Port
16eb14806d1e
Alex Langford [Fri, 12 May 2023 22:32:51 +0000 (15:32 -0700)]
[lldb][NFCI] Switch to using llvm::DWARFAbbreviationDeclaration
Both LLVM and LLDB implement DWARFAbbreviationDeclaration. As of
631ff46cbf51, llvm's implementation of
DWARFAbbreviationDeclaration::extract behaves the same as LLDB's
implementation, making it easier to merge the implementations.
The only major difference between LLDB's implementation and LLVM's
implementation is that LLVM's DWARFAbbreviationDeclaration is slightly
larger. Specifically, it has some metadata that keeps track of the size
of a declaration (if it has a fixed size) so that it can potentially
optimize extraction in some scenarios. I think this increase in size
should be acceptable and possibly useful on the LLDB side.
Differential Revision: https://reviews.llvm.org/D150716
Peter Klausler [Wed, 17 May 2023 17:23:18 +0000 (10:23 -0700)]
[flang] Don't complain about dummy subroutine under IMPLICIT NONE
The compiler emits a bogus 'No explicit type declared for...' error
when a dummy procedure turns out to be a subroutine (or at least not
a function or object) under control of IMPLICIT NONE.
Fixes https://github.com/llvm/llvm-project/issues/60224
Differential Revision: https://reviews.llvm.org/D150814
Nick Desaulniers [Thu, 18 May 2023 20:52:25 +0000 (13:52 -0700)]
[libcxxabi] allow downstreams to override _LIBCPP_VERBOSE_ABORT
@asbirlea reports that Google does this for sanitizer analysis
downstream. Looks like a few #defines are added into a header which is
then injected into the build.
Reviewed By: vitalybuka, ldionne, #libc_abi
Differential Revision: https://reviews.llvm.org/D150825
Fazlay Rabbi [Thu, 11 May 2023 18:18:02 +0000 (11:18 -0700)]
[OpenMP 5.2] Deprecate MINUS(-) operator on 'reduction' clause
Siva Chandra Reddy [Thu, 18 May 2023 19:25:41 +0000 (19:25 +0000)]
[libc] Use the new wide integer to hex string facility in LibcTest.
The old code, which has regressed over many cleanups, has been replaced
with the new wide integer to hex string facility.
Reviewed By: michaelrj
Differential Revision: https://reviews.llvm.org/D150901
Peiming Liu [Tue, 16 May 2023 23:52:45 +0000 (23:52 +0000)]
[mlir][sparse] Make sparse_tensor::StorageLayout publicly available.
Reviewed By: aartbik
Differential Revision: https://reviews.llvm.org/D150739
Johannes Doerfert [Mon, 15 May 2023 23:02:38 +0000 (16:02 -0700)]
[Attributor][OpenMP-Opt][NFC] Run the update test checks script
Johannes Doerfert [Mon, 15 May 2023 22:37:40 +0000 (15:37 -0700)]
[OpenMP] Add JIT and IR tests
The OpenMP target JIT needs testing, so does the IR we actually generate
for the device. This is the initial commit with variations of an "empty
OpenMP kernel" that should all result in a empty IR kernel.
Differential revision: https://reviews.llvm.org/D150623
Johannes Doerfert [Mon, 15 May 2023 20:52:20 +0000 (13:52 -0700)]
[Attributor] Teach AAMemoryLocation about constant GPU memory
AS(4), when targeting GPUs, is constant. Accesses to constant memory are
(historically) not treated as "memory accesses", hence we should deduce
`memory(none)` for those.
Johannes Doerfert [Mon, 15 May 2023 19:38:20 +0000 (12:38 -0700)]
[OpenMP][NFC] Eliminate warning
Craig Topper [Thu, 18 May 2023 20:25:28 +0000 (13:25 -0700)]
[RISCV] Fix test that was still using __RISCV_RVV_VLEN_BITS. NFC
This constant was renamed to __riscv_v_fixed_vlen during code
review. I missed this in my search and replace.
Joseph Huber [Thu, 18 May 2023 20:20:17 +0000 (15:20 -0500)]
[libc] Add comparison specialization for cpp:string type
We compare this type in the string_test. It had no specialization here
so it could cause linker errors. This patch simply extends the interface
to support it.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D150904
Matt Arsenault [Thu, 18 May 2023 20:19:19 +0000 (21:19 +0100)]
AMDGPU/GlobalISel: Fix broken test
Michael Platings [Thu, 18 May 2023 20:14:56 +0000 (21:14 +0100)]
[NFC][Driver] Fix -Wdangling-else warning
GCC emits this warning because the EXPECT_STREQ macro contains an
if-else statement:
warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wdangling-else]
Alexander Shaposhnikov [Thu, 18 May 2023 20:08:54 +0000 (20:08 +0000)]
[Clang] Fix typo in ReleaseNotes.rst
Alexander Shaposhnikov [Thu, 18 May 2023 20:02:07 +0000 (20:02 +0000)]
[Clang] Update release notes
Update release notes.
This is a follow-up to https://reviews.llvm.org/D146178
Differential revision: https://reviews.llvm.org/D149906
Evandro Menezes [Thu, 18 May 2023 00:07:02 +0000 (19:07 -0500)]
[AArch64] Predicate for ROR immediate
Add a common predicate for when the `ROR` immediate or "Bitfield
extract, one register" idiom is used for `EXTR` or "Bitfield extract,
two registers".
Differential revision: https://reviews.llvm.org/D150832