469311 Commits

Author SHA1 Message Date
Christian Sigg
092b6c5ee3 [mlir][nfc] Allow ops to have operands/attributes named context.
This is probably a bad idea, but it's only become a problem with properties and is easy to fix.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D159185
llvmorg-17.0.0-rc4
2023-09-05 09:24:20 +02:00
DianQK
dccf183bb2 [JumpThreading] Invalidate LVI after combineMetadataForCSE.
(cherry picked from commit 7ded71b1e43fff0be3acb74038bfea87f38d5cfa)
2023-09-05 09:00:53 +02:00
DianQK
ae9c45b112 [JumpThreading][NFC] Pre-commit for invalid LVI.
(cherry picked from commit 5855a4be9cbc3c4584d8a1632886c347044dfbef)
2023-09-05 09:00:53 +02:00
Takuya Shimizu
9597525dc1 Revert "[clang][Docs] Added release note for D142609"
The associated commit was reverted and backported in a93ca35, so this
release note line should also be removed.

This reverts commit 061e855767dbe0821d81a8d47158f468dd00ae5f.
2023-09-05 09:00:46 +02:00
Younan Zhang
5b4513afa4 [clang][clangd] Ensure the stack bottom before building AST
`clang::runWithSufficientStackSpace` requires the address of the
initial stack bottom to prevent potential stack overflows.

In addition, add a fallback to ASTFrontendAction in case any client
forgets to call it when not through CompilerInstance::ExecuteAction,
which is rare.

Fixes https://github.com/clangd/clangd/issues/1745.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D158967

(cherry picked from commit e257c0a9190637e44e292271103a13d70bec4b03)
2023-09-05 09:00:36 +02:00
Younan Zhang
c2c9c0f138 [clang] Construct ExprRequirement with SubstitutionDiagnostic on SubstFailure
We're expecting a SubstitutionDiagnostic in diagnoseUnsatisfiedRequirement
if the status of ExprRequirement is SubstFailure. Previously, the Requirement
was created with Expr on SubstFailure by mistake, which could lead to the
assertion failure in the subsequent diagnosis.

Fixes https://github.com/clangd/clangd/issues/1726
Fixes https://github.com/llvm/llvm-project/issues/64723
Fixes https://github.com/llvm/llvm-project/issues/64172

In addition, this patch also fixes an invalid test from D129499.

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D158061
2023-09-05 09:00:27 +02:00
Elizabeth Andrews
175a130b9f [NFC][Clang] Fix static analyzer concern about null value dereference
Differential Revision: https://reviews.llvm.org/D157554
2023-09-05 09:00:27 +02:00
Fangrui Song
7150c6d4ee [sanitizer] scanf interceptor: fix write size for %mc/%mC/%mS
When the optional assignment-allocation character 'm' (Extension to the
ISO C standard) is present, we currently use internal_strlen(buf)+1 for
all of cCsS[ (D85350). Fix cCS to use the correct size.

Fix https://github.com/llvm/llvm-project/issues/61768

Reviewed By: #sanitizers, vitalybuka

Differential Revision: https://reviews.llvm.org/D158485

(cherry picked from commit beeb37a8f3275281be305d2d1afe35ca053e21c0)
2023-09-05 08:59:58 +02:00
Vassil Vassilev
ecea6d6828 [CodeGen] First check the kind and then the llvm::Function properties.
This patch fixes valgrind reports from downstream consumers about conditional
jump over uninitialised memory.

The original report:

```[ RUN      ] ScopeReflectionTest.IsComplete
==987150== Conditional jump or move depends on uninitialised value(s)
==987150==    at 0x1E1128F: clang::CodeGen::CodeGenModule::SetLLVMFunctionAttributesForDefinition(clang::Decl const*, llvm::Function*) (CodeGenModule.cpp:2391)
==987150==    by 0x1E4F181: clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (CodeGenModule.cpp:5669)
==987150==    by 0x1E4A194: clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (CodeGenModule.cpp:3909)
==987150==    by 0x1E4A752: clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (CodeGenModule.cpp:3649)
==987150==    by 0x1E532F5: clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) [clone .part.0] (CodeGenModule.cpp:6563)
==987150==    by 0x1B0BEDD: (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) (ModuleBuilder.cpp:190)
==987150==    by 0x1AEA47B: clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (CodeGenAction.cpp:235)
==987150==    by 0x101B02F: clang::IncrementalASTConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (IncrementalParser.cpp:52)
==987150==    by 0x101ED93: clang::IncrementalParser::ParseOrWrapTopLevelDecl() (IncrementalParser.cpp:276)
==987150==    by 0x101FBBC: clang::IncrementalParser::Parse(llvm::StringRef) (IncrementalParser.cpp:342)
==987150==    by 0x100E104: clang::Interpreter::Parse(llvm::StringRef) (Interpreter.cpp:360)
==987150==    by 0xE734C0: Cpp::Interpreter::Parse(llvm::StringRef) (CppInterOpInterpreter.h:172)
==987150==  Uninitialised value was created by a heap allocation
==987150==    at 0x844BE63: operator new(unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==987150==    by 0x1B0C882: StartModule (ModuleBuilder.cpp:139)
==987150==    by 0x1B0C882: clang::CodeGenerator::StartModule(llvm::StringRef, llvm::LLVMContext&) (ModuleBuilder.cpp:360)
==987150==    by 0x101C4AF: clang::IncrementalParser::GenModule() (IncrementalParser.cpp:372)
==987150==    by 0x101FC0E: clang::IncrementalParser::Parse(llvm::StringRef) (IncrementalParser.cpp:362)
==987150==    by 0x100E104: clang::Interpreter::Parse(llvm::StringRef) (Interpreter.cpp:360)
==987150==    by 0x100E243: clang::Interpreter::create(std::unique_ptr<clang::CompilerInstance, std::default_delete<clang::CompilerInstance> >) (Interpreter.cpp:279)
==987150==    by 0xF2131A: compat::createClangInterpreter(std::vector<char const*, std::allocator<char const*> >&) (Compatibility.h:123)
==987150==    by 0xF22AB9: Cpp::Interpreter::Interpreter(int, char const* const*, char const*, std::vector<std::shared_ptr<clang::ModuleFileExtension>, std::allocator<std::shared_ptr<clang::ModuleFileExtension> > > const&, void*, bool) (CppInterOpInterpreter.h:146)
==987150==    by 0xF1827A: CreateInterpreter (CppInterOp.cpp:2494)
==987150==    by 0xECFA0E: TestUtils::GetAllTopLevelDecls(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<clang::Decl*, std::allocator<clang::Decl*> >&, bool) (Utils.cpp:23)
==987150==    by 0xE9CB85: ScopeReflectionTest_IsComplete_Test::TestBody() (ScopeReflectionTest.cpp:71)
==987150==    by 0xF0ED0C: void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (in /home/vvassilev/workspace/builds/scratch/cppyy/InterOp/build-with-clang-repl-release/unittests/CppInterOp/CppInterOpTests)
==987150==
```

Differential revision: https://reviews.llvm.org/D159339

(cherry picked from commit 92246a9be0ba47788ada9621bef58ce7819be526)
2023-09-04 08:27:20 +02:00
Fangrui Song
e04acab63c [Driver] Report warnings for unclaimed TargetSpecific options for assembler input
This patch amends D151590 to not error for unlaimed TargetSpecific
options for `-x assembler` input files. This input type causes Driver to
construct tools::ClangAs (-fintegrated-as) or other assemblers (e.g.
tools::gnutools::Assembler) Their ConstructJobs methods, unlike
Clang::ConstructJobs, claim very few options. If an option is unclaimed,
it either leads to a -Wunused-command-line-argument warning or an error
(if `TargetSpecific` is set):
```
% clang '-###' --target=aarch64 -mbranch-protection=bti -c a.s
clang: error: unsupported option '-mbranch-protection=' for target 'aarch64'
```

It seems that downgrading the diagnostic to warning is most useful as
many users use CFLAGS even for `.s` files:
```
clang --target=aarch64 -mbranch-protection=bti -S a.c
clang --target=aarch64 -mbranch-protection=bti -c a.s
```

I decide not to suppress the warning so that
-Wunused-command-line-argument lovers still get a warning, and help
projects use proper ASFLAGS/CFLAGS/etc.

Note: `-mbranch-protection=bti a.S` currently has no warning as `-x assembler-with-cpp`
instructs clangDriver to select tools::Clang and claim most options.

Revert D159010 to demonstrate that we emit a warning for -mfpmath= for
`-x assembler` input.

Modify my AIX cleanup cd18efb61d759405956dbd30e4b5f2720d8e1783 to
add an err_drv_unsupported_opt_for_target.

Reviewed By: thesamesam

Differential Revision: https://reviews.llvm.org/D159173

(cherry picked from commit e9d454d1c195958645fb0948f8b97262e7f8b33a)
2023-09-04 08:26:41 +02:00
hstk30
ca372df48a [AArch64] Fix arm neon vstx lane memVT size
StN lane memory size set too big lead to alias analysis goes wrong.

Fixes https://github.com/llvm/llvm-project/issues/64696

Differential Revision: https://reviews.llvm.org/D158611

(cherry picked from commit db8f6c009e5a17d304be7404e50eb20b2dd0c75b)
2023-09-04 08:26:32 +02:00
Martin Storsjö
466677b126 [llvm-windres] Implement the windres flag --use-temp-file
Whether a temp file or a pipe is used for preprocessing is an
internal detail, this flag has a notable effect on the preprocessing
in GNU windres. Without this flag, GNU windres passes command
arguments as-is to popen(), which means they get evaluated by a
shell without being re-escaped for this case. To mimic this,
llvm-windres has manually tried to unescape arguments.

When GNU windres is given the --use-temp-file flag, it uses a
different API for invoking the preprocessor, and this API takes care
of preserving special characters in the command line arguments.
For users of GNU windres, this means that by using --use-temp-file,
they don't need to do the (quite terrible) double escaping of
quotes/spaces etc.

The xz project uses the --use-temp-file flag when invoking
GNU windres, see
6b117d3b1f.
However as llvm-windres didn't implement this flag and just
assumed the GNU windres popen() behaviour, they had to use a
different codepath for llvm-windres.

That separate codepath for llvm-windres broke later when llvm-windres
got slightly more accurate unescaping of lone quotes in
0f4c6b120f21d582ab7c5c4f2b2a475086c34938 /
https://reviews.llvm.org/D146848 (fixing a discrepancy to GNU
windres as found in https://github.com/llvm/llvm-project/issues/57334),
and this was reported in
https://github.com/mstorsjo/llvm-mingw/issues/363.

Not touching the implementation of the --preprocessor option
with respect to the --use-temp-file flag; that option is doubly
tricky as GNU windres changed its behaviour in a backwards incompatible
way recently (and llvm-windres currently matches the old behaviour).
(See
https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=21c33bcbe36377abf01614fb1b9be439a3b6de20,
https://sourceware.org/bugzilla/show_bug.cgi?id=27594 and
https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=5edb8e3f5ad8d74a83fc0df7f6e4514eed0aa77f;hp=3abbafc2aacc6706fea3e3e326e2f08d107c3672
for the behaviour change.)

Differential Revision: https://reviews.llvm.org/D159223

(cherry picked from commit 2bcc0fdc58a220cb9921b47ec8a32c85f2511a47)
2023-09-04 08:26:18 +02:00
Haojian Wu
6a562bbd51 [Tooling/Inclusion] Add std::range symbols in the mapping.
Fixes https://github.com/llvm/llvm-project/issues/64191

Differential Revision: https://reviews.llvm.org/D156648

(cherry picked from commit 171868dc2cd60c6e3eaeb3861b18ba0e22461291)
2023-09-04 08:26:02 +02:00
Fangrui Song
a612cb0b81 [sanitizer][test] -std=c2x instead of -std=c23
Adjust tests from dd230efe703f34678ce52280e50238abf908aaa1 to use
-std=c2x instead, as Clang in release/17.x doesn't support -std=c23.
2023-09-01 08:32:36 +02:00
Fangrui Song
051aa171d2 [Driver] Adjust -fsanitize=function & -mexecute-only interop after D158614
clangDriver depends on clangBasic, so clangBasic should not depend on
clangDriver, even just its header. Also remove clangBasic's dependency
on LLVMOption.

The issue can be seen through the bazel commit
d26dd681f9726ed7d43d7c0bdd8ee3cb2db69a2b which is reverted now.

Add hasFlagNoClaim and use it as we don't want to suppress
-Wunused-command-line-argument for -mexecute-only just because
-fsanitize= is specified.
2023-09-01 08:26:36 +02:00
Ying Yi
c138c8a72e [UBSan] Disable the function and kcfi sanitizers on an execute-only target.
An execute-only target disallows data access to code sections.
-fsanitize=function and -fsanitize=kcfi instrument indirect function
calls to load a type hash before the function label. This results in a
non-execute access to the code section and a runtime error.

To solve the issue, -fsanitize=function should not be included in any
check group (e.g. undefined) on an execute-only target. If a user passes
-fsanitize=undefined, there is no error and no warning. However, if the
user explicitly passes -fsanitize=function or -fsanitize=kcfi on an
execute-only target, an error will be emitted.

Fixes: https://github.com/llvm/llvm-project/issues/64931.

Reviewed By: MaskRay, probinson, simon_tatham

Differential Revision: https://reviews.llvm.org/D158614
2023-09-01 08:26:36 +02:00
Phoebe Wang
e9eaf3dc64 [X86][BF16] Lower FP_ROUND for vector types under AVX512BF16
Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D158952

(cherry picked from commit b667e9c23d6d2f1c7371eb4a03b30de4a6f8b7b6)
2023-09-01 08:24:05 +02:00
Phoebe Wang
a0de0b440f [X86][BF16] Add test coverage for AVX-NE-CONVERT
Split from D158952.

(cherry picked from commit 30ec9473c6685d64d5caa17e2a6e8f4ccf275159)
2023-09-01 08:24:05 +02:00
Haojian Wu
dc2d2f9ba1 [clangd] Respect IWYU keep pragma for standard headers.
see the issue https://github.com/llvm/llvm-project/issues/64191

Differential Revision: https://reviews.llvm.org/D156650

(cherry picked from commit dcb28244faa88cb566a852533790bcac75daaa0f)
2023-09-01 08:23:39 +02:00
Craig Topper
b879e0f5c4 [RISCV] Prevent tryToFoldBNEOnCmpXchgResult from deleting AND if it has others users.
This disables the transform if the branch does not have the kill
flag set for the AND we want to delete.

Ideally we'd be able to share the AND with the AND we create in
the expansion, but that's a more complex transform. So this starts
with the simple approach to fix miscompile.

This should be backported to LLVM 17.

Fixes PR65025.ll

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D158962

(cherry picked from commit ff6d33382faf3709fa270ae0abb8d165142df9ae)
2023-09-01 08:23:28 +02:00
Amy Kwan
2b3336fa54 [PowerPC][lld] Account for additional X-Forms -> D-Form/DS-Forms load/stores when relaxing initial-exec to local-exec
D153645 added additional X-Form load/stores that can be generated for TLS accesses.
However, these added instructions have not been accounted for in lld. As a result,
lld does not know how to handle them and cannot relax initial-exec to local-exec
when the initial-exec sequence contains these additional load/stores.

This patch aims to resolve https://github.com/llvm/llvm-project/issues/64424.

Differential Revision: https://reviews.llvm.org/D158197

(cherry picked from commit 698b45aa902de4d30c798e8d6bd080c8e31bade8)
2023-09-01 08:23:17 +02:00
Simon Tatham
844f1e5a02 [AArch64] Add Defs=[NZCV] to MTE loop pseudos.
The `STGloop` family of pseudo-instructions all expand to a loop which
iterates over a region of memory setting all its MTE tags to a given
value. The loop writes to the flags in order to check termination. But
the unexpanded pseudo-instructions were not marked as modifying the
flags. Therefore it was possible for one to end up in a location where
the flags were live, and then the loop would corrupt them.

We spotted the effect of this in a libc++ test involving a lot of
complicated inlining, and haven't been able to construct a smaller
test case that demonstrates actual incorrect output code. So my test
here is just checking that `implicit-def $nzcv` shows up on the
pseudo-instructions as they're output from isel.

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D158262

(cherry picked from commit b09c575975b691e988a0f2e31d632c5f1038ab1d)
2023-08-31 09:00:36 +02:00
Mark de Wever
078e20cade [libc++][format] Fixes out of bounds access.
Fixes https://llvm.org/PR65011

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D158940

(cherry picked from commit 8930d04d5580c6a2cf04545c87387cd150cd7b46)
2023-08-31 09:00:27 +02:00
Yuxuan Shui
4a999da214 [lldb][windows] _wsopen_s does not accept bits other than _S_IREAD | _S_IWRITE
When sending file from a Linux host to a Windows remote, Linux host will try to copy the source file's permission bits, which will contain `_S_I?GRP` and `_S_I?OTH` bits. Those bits are rejected by `_wsopen_s`, causing it to return EINVAL.

This patch masks out the rejected bits.

GitHub issue: #64313

Reviewed By: jasonmolenda, DavidSpickett

Differential Revision: https://reviews.llvm.org/D156817

(cherry picked from commit 9a4b3fdb82327e808213070fd157be3c557b8b9d)
2023-08-31 08:59:53 +02:00
Garvit Gupta
1b1113731f [RISCV] Fix assertion failure when zcmp extension is enabled.
Before accessing "getOpcode" thorugh machine instruction, check if the iterator
has reached the end of Machine basic block otherwise we will crash at the
assertion `!NodePtr->isKnownSentinel()`.

The above assertion is hit in "Prologue/Epilogue Insertion & Frame Finalization
pass".

Reviewed By: craig.topper, wangpc

Differential Revision: https://reviews.llvm.org/D158256

(cherry picked from commit fdef7952cbc26fd31d0d92a4f14dde58bc461fe9)
2023-08-31 08:59:43 +02:00
Markus Böck
b66219d735 [mlir] Fix infinite recursion in alias initializer
The alias initializer keeps a list of child indices around. When an alias is then marked as non-deferrable, all children are also marked non-deferrable.

This is currently done naively which leads to an infinite recursion if using mutable types or attributes containing a cycle.

This patch fixes this by adding an early return if the alias is already marked non-deferrable. Since this function is the only way to mark an alias as non-deferrable, it is guaranteed that if it is marked non-deferrable, all its children are as well, and it is not required to walk all the children.
This incidentally makes the non-deferrable marking also `O(n)` instead of `O(n^2)` (although not performance sensitive obviously).

Differential Revision: https://reviews.llvm.org/D158932
2023-08-31 08:54:24 +02:00
Matthias Springer
cc7e24c7a7 [mlir] Fix crash when adding nested dialect extensions
A dialect extension can add additional dialect extensions in its `apply` function. This used to crash when the vector of `extensions` was internally reallocated while it is being iterated over.

Differential Revision: https://reviews.llvm.org/D158838
2023-08-31 08:54:24 +02:00
Balaji V. Iyer
94f348b784 [mlir][math] Modify math.powf to handle negative bases.
Powf expansion currently returns NaN when the base is negative.
This is because taking natural log of a negative number gives
NaN. This patch will square the base and half the exponent, thereby
getting around the negative base problem.

Reviewed By: rsuderman

Differential Revision: https://reviews.llvm.org/D158797
2023-08-31 08:54:24 +02:00
Matthias Springer
ad5ed49a14 [mlir][memref] Fix crash in SubViewReturnTypeCanonicalizer
`SubViewReturnTypeCanonicalizer` is used by `OpWithOffsetSizesAndStridesConstantArgumentFolder`, which folds constant SSA value (dynamic) sizes into static sizes. The previous implementation crashed when a dynamic size was folded into a static `1` dimension, which was then mistaken as a rank reduction.

Differential Revision: https://reviews.llvm.org/D158721
2023-08-31 08:54:24 +02:00
Lei Huang
08d720da6b [PowerPC] Update V17.0.0 release notes 2023-08-30 19:58:36 +02:00
Serge Pavlov
45c677d8c6 [clang][test] Make check pattern shorter
A check pattern in clang/test/SemaCXX/template-64605.cpp contains template
specialization kind (the text "implicit_instantiation"). It does not need to
be checked and can be safely removed.

Presence of this text in the check pattern prevents from backporting some
commits to the release branch: https://github.com/llvm/llvm-project/issues/64605.
It has only recently been printed and the relevant commit is not present in
the release/17.x branch.

(cherry picked from commit 8859c644ede4898f90f77dcad2286de08a9ba62e)
2023-08-30 17:10:36 +02:00
Serge Pavlov
78447a8ad5 [clang] Run test for concrete target
The test clang/test/SemaCXX/template-64605.cpp uses pragma FENV_ACCESS,
which is not supported on all targets. Restrict it to x86_64 only.

(cherry picked from commit 73e5a70e676850b79f196e01e2194a2485041584)
2023-08-30 17:10:36 +02:00
Serge Pavlov
cfd6f0fb9d [clang] Set FP options in Sema when instantiating CompoundStmt
When an expression is instantiated, TreeTransform skips ImplicitCastExpr
nodes, assuming they are recreated when the instantiated expression is
built. It breaks functions that use non-default floating-point options,
because they are kept in these ImplicitCastExprs. In this case the
recreated ImplicitCastExpr takes FP options from the current Sema state
and not from AST node.

To fix this issue the FP options in Sema object are set when a compound
statement is cloned in TreeTransform.

This change fixes https://github.com/llvm/llvm-project/issues/64605
([Regression 16 -> 17] Template instantiation ignores FENV_ACCESS being
ON for both definition and instantiation).

Differential Revision: https://reviews.llvm.org/D158158

(cherry picked from commit 0baf85c331090fbe2d2b42214ed0664d55feb0b5)
2023-08-30 17:10:36 +02:00
Tom Stellard
b8ea78cf44 workflows: Fix libclang-abi test after update to use download-artifac… (#64877)
workflows: Fix libclang-abi test after update to use download-artifact v3
2023-08-30 17:07:16 +02:00
Aaron Ballman
b8444b613b Silently accept -Wgnu-empty-initializer
5d8aaad445
removed the warning group as the functionality is no longer a GNU
extension. However, users have asked for the warning group to be
supported so that code transitioning from Clang 16 to Clang 17 has an
easier migration path when compiling with -Werror. This patch restores
the warning group, but as an ignored warning group because the
functionality is now always considered to be a C extension rather than
a GNU extension. This allows users to do:

  -Werror -pedantic -Wno-gnu-empty-intializer -Wno-c2x-extensions

to silence the diagnostics in both Clang 16 and Clang 17.

Fixes https://github.com/llvm/llvm-project/issues/64357
Differential Revision: https://reviews.llvm.org/D157503

(cherry picked from commit 151214b40d869455666ca76548a9e3ad639f79de)
2023-08-30 17:02:23 +02:00
Jon Roelofs
5a60d716ca [CMake] Add a few more missing dependencies on ClangDriverOptions
This often breaks modules-enabled bootstrap builds.

(cherry picked from commit 1e4d6122cda6529781ecf467c2ae84e5dd41acdf)
2023-08-30 17:01:13 +02:00
Owen Pan
1440745b0a [clang-format] Exclude kw_decltype in RemoveParentheses
From https://en.cppreference.com/w/cpp/language/decltype:
Note that if the name of an object is parenthesized, it is treated as an
ordinary lvalue expression, thus decltype(x) and decltype((x)) are often
different types.

Fixes #64786.

Differential Revision: https://reviews.llvm.org/D158155

(cherry picked from commit e3a79503a30f8c9d8fba79f3e5427bb895f320cf)
2023-08-30 17:00:56 +02:00
Luke Lau
6f1974e04c [RISCV] Don't relax policy to ta when vmerge's VL shrinks during folding
When folding a vmerge into its operands, if the resulting VL is smaller than
what the vmerge had originally then what was previously in its body then gets
moved to the tail. In that case, we can't relax the tail policy to agnostic
when the merge operand is undefined, since we need to preserve these elements
past the new VL.

Fixes https://github.com/llvm/llvm-project/issues/64754

Reviewed By: craig.topper, reames

Differential Revision: https://reviews.llvm.org/D158161

(cherry picked from commit 007b41b3939832b6938bb1ba91e9febebf93d3b8)
2023-08-30 17:00:48 +02:00
Luke Lau
993681f594 [RISCV] Add test case showing vmerge fold miscompile with tail policy
Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D158160

(cherry picked from commit 6e532f94eb0e2c9c93a3d75b4cf53bf12ab9f518)
2023-08-30 17:00:48 +02:00
Fangrui Song
9afe667683 Function multi-versioning: disable ifunc for ELF targets other than glibc/Android/FreeBSD
Generalize D127933 (Fuchsia special case) to other ELF targets. Ensure
that musl, NetBSD, OpenBSD, etc do not get ifunc codegen which is
unsupported in their rtld.

Link: https://discourse.llvm.org/t/does-ifunc-use-from-llvm-require-os-support/67628
Close: https://github.com/llvm/llvm-project/issues/64631
(cherry picked from commit 0c3a02b8c09bb408a74a638a263e51d67c92ca74)
2023-08-30 17:00:27 +02:00
Brooks Davis
b6cf21feee [msan] Fix compilation on non-glibc
SANITIZER_GLIBC is always defined so should be tested with an if not an
ifdef.

Fixes: ad7e2501000d

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D159041

(cherry picked from commit 692344d87357ded619d216b265a9375f4326d8fb)
2023-08-30 17:00:18 +02:00
Martin Storsjö
c8abecdaca [compiler-rt] [test] Adjust an XFAIL for strtoll_strict.c for MinGW targets
8033231240f223dc7c718d1d27ece2dbcc8057c6 made this test pass
in MinGW environments, even if it still is failing in MSVC
environments.

(cherry picked from commit 277fc9475fb89c0b80d4237dbc8d698a55203c0d)
2023-08-30 17:00:18 +02:00
Fangrui Song
dd230efe70 [sanitizer] Intercept glibc 2.38 __isoc23_* functions
`strtol("0b1", 0, 0)` can be (pre-C23) 0 or (C23) 1.
`sscanf("0b10", "%i", &x)` is similar. glibc 2.38 introduced
`__isoc23_strtol` and `__isoc23_scanf` family functions for binary
compatibility.

When `_ISOC2X_SOURCE` is defined (implied by `_GNU_SOURCE`) or
`__STDC_VERSION__ > 201710L`, `__GLIBC_USE_ISOC2X` is defined to 1 and
these `__isoc23_*` symbols are used.

Add `__isoc23_` versions for the following interceptors:

* sanitizer_common_interceptors.inc implements strtoimax/strtoumax.
  Remove incorrect FIXME about https://github.com/google/sanitizers/issues/321
* asan_interceptors.cpp implements just strtol and strtoll. The default
  `replace_str` mode checks `nptr` is readable and `endptr` is writable.
  atoi reuses the existing strtol interceptor.
* msan_interceptors.cpp implements strtol family functions and their
  `_l` versions. Tested by lib/msan/tests/msan_test.cpp
* sanitizer_common_interceptors.inc implements scanf family functions.

The strtol family functions are spreaded, which is not great, but the
patch (intended for release/17.x) does not attempt to address the issue.

Add symbols to lib/sanitizer_common/symbolizer/scripts/global_symbols.txt to
support both glibc pre-2.38 and 2.38.

When build bots migrate to glibc 2.38+, we will lose test coverage for
non-isoc23 versions since the existing C++ unittests imply `_GNU_SOURCE`.
Add test/sanitizer_common/TestCases/{strtol.c,scanf.c}.
They catch msan false positive in the absence of the interceptors.

Fix https://github.com/llvm/llvm-project/issues/64388
Fix https://github.com/llvm/llvm-project/issues/64946

Link: https://lists.gnu.org/archive/html/info-gnu/2023-07/msg00010.html
("The GNU C Library version 2.38 is now available")

Reviewed By: #sanitizers, vitalybuka, mgorny

Differential Revision: https://reviews.llvm.org/D158943

(cherry picked from commit ad7e2501000da2494860f06a306dfe8c08cc07c3)
2023-08-30 17:00:18 +02:00
Fangrui Song
cf16374055 [asan] Intercept atoll and strtoll on Windows
`_MSC_VER>=1800` (Visual Studio 2013) supports atoll/strtoll.
Remove the obsoleted workaround ASAN_INTERCEPT_ATOLL_AND_STRTOLL.

test/asan/TestCases/atoll_strict.c passes but
test/asan/TestCases/strtoll_strict.c doesn't.

(cherry picked from commit 8033231240f223dc7c718d1d27ece2dbcc8057c6)
2023-08-30 17:00:18 +02:00
dingfei
4dea033c9b [clang] Update NumFunctionDeclBits for FunctionDeclBitfields
NumFunctionDeclBits is not updated when DeductionCandidateKind is
incremented.

Fixes https://github.com/llvm/llvm-project/issues/64171

Reviewed By: cor3ntin, balazske, aaron.ballman

Differential Revision: https://reviews.llvm.org/D158145

(cherry picked from commit 91c4b5550ecfbb7afe7275c341b73a6d3a1bbd78)
2023-08-30 16:59:56 +02:00
Galen Elias
2c9feb07f3 [clang-format] Fix braced initializer with templated base class
Fixes #64134.

Differential Revision: https://reviews.llvm.org/D156705

(cherry picked from commit 400da115c58ae19445cfdc871a3f559f160fc5c6)
2023-08-30 16:59:39 +02:00
Takuya Shimizu
8c5c652ed7 [clang][ExprConstant] Fix crash on uninitialized base class subobject
This patch fixes the reported regression caused by D146358 through adding notes about an uninitialized base class when we diagnose uninitialized constructor.

This also changes the wording from the old one in order to make it clear that the uninitialized subobject is a base class and its constructor is not called.
Wording changes:
BEFORE: `subobject of type 'Base' is not initialized`
AFTER: `constructor of base class 'Base' is not called`

Fixes https://github.com/llvm/llvm-project/issues/63496

Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D153969
2023-08-30 16:59:25 +02:00
Vassil Vassilev
d469d5ce19 Reland "[clang-repl] Adapt to the recent dylib-related changes in ORC."
Original commit message:"

ORC splits into separate dylibs symbols coming from the process and symbols
materialized in the Jit. This patch adapts intent of the existing interface and
adds a regression test to make sure both Jit'd and compiled symbols can be found.

Differential revision: https://reviews.llvm.org/D159115
"

This patch disables the test statement on windows as it seems we might have a
bug in the way we model dllimports.

(cherry picked from commit 452cb7f20bc7b976eb6fec4ac9f2d902f4175c08)
2023-08-30 16:58:23 +02:00
Phoebe Wang
94af834cb8 [X86][BF16] Lower FP_EXTEND for vector types under AVX512BF16
Fixes #64460

Reviewed By: RKSimon, skan

Differential Revision: https://reviews.llvm.org/D158950

(cherry picked from commit 6688701497ea8e562b769bdb154a40f4a1099abb)
2023-08-30 16:58:00 +02:00
Erik Desjardins
acc6a14413 [Tests][ConstraintElim] autogen newly-added case in large-constant-ints.ll (NFC)
I forgot to do this in 66ec5df3a7f33366455d50769e4e878544becea6 / https://reviews.llvm.org/D158810.

Since this is testing for an assertion failure, the test checks don't matter, but we might as well avoid unnecessary churn the next time someone modifies this test.

(cherry picked from commit df112cba034eefb86d0e92e18518f5e944d58c37)
2023-08-30 16:57:47 +02:00