Changes

Summary

  1. [analyzer][NFC] Refactor llvm::isa<> usages in the StaticAnalyzer (details)
  2. [RISCV] Use clang_builtin_alias for all RISCV vector intrinsics. (details)
  3. [CodeGenPrepare] Avoid a scalable-vector crash in ctlz/cttz (details)
  4. [clang] Add plugin ActionType to run command line plugin before main action (details)
  5. [MLIR][OpenMP] Shifted hint from CriticalOp to CriticalDeclareOp (details)
  6. [InstCombine] add tests for casted insertelement; NFC (details)
  7. [OpenMP] Add GOMP allocator functions (details)
  8. [WebAssembly] Add prototype relaxed float min max instructions (details)
  9. Fix unused variable warning. (details)
  10. [mlir] fix region property generation in python bindings (details)
  11. InvalidPtrChecker - don't dereference a dyn_cast<> - use cast<> instead. (details)
  12. [IR] Refactor GlobalIFunc to inherit from GlobalObject, Remove GlobalIndirectSymbol (details)
  13. [Clang][AST] Resolve FIXME: Remove ObjCObjectPointer from (details)
  14. [NFC] De-template LazyCallGraph::visitReferences() and move into .cpp file (details)
  15. Raise compile error when using unimplemented functions (details)
  16. Precommit InstCombine/and-xor-or.ll test. NFC. (details)
  17. [clang] Disallow mixing SEH and Objective-C exceptions (details)
  18. [ORC-RT] Configure the ORC runtime for more architectures and platforms (details)
  19. [InstCombine] fold fake vector insert to bit-logic (details)
  20. [lld/mac] Remove else-after-return in ICF code (details)
  21. [MC] Recursively calculate symbol offset (details)
  22. [AMDGPU] Allow rematerialization of SOP with virtual registers (details)
  23. [AMDGPU] MachineLICM cannot hoist VALU (details)
  24. [lldb] Remove variable "any" which is set but not used (details)
  25. [AArch64][GlobalISel] combine (and (or x, c1), c2) => (and x, c2) iff c1 & c2 == 0 (details)
Commit 16be17ad4b13deb23c893c3c668076e70b07f289 by balazs.benics
[analyzer][NFC] Refactor llvm::isa<> usages in the StaticAnalyzer

It turns out llvm::isa<> is variadic, and we could have used this at a
lot of places.

The following patterns:
  x && isa<T1>(x) || isa<T2>(x) ...
Will be replaced by:
  isa_and_non_null<T1, T2, ...>(x)

Sometimes it caused further simplifications, when it would cause even
more code smell.

Aside from this, keep in mind that within `assert()` or any macro
functions, we need to wrap the isa<> expression within a parenthesis,
due to the parsing of the comma.

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D111982
The file was modifiedclang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
The file was modifiedclang/lib/StaticAnalyzer/Core/SValBuilder.cpp
The file was modifiedclang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
The file was modifiedclang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
The file was modifiedclang/lib/StaticAnalyzer/Core/MemRegion.cpp
The file was modifiedclang/lib/StaticAnalyzer/Core/CallEvent.cpp
The file was modifiedclang/lib/StaticAnalyzer/Core/RegionStore.cpp
The file was modifiedclang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
The file was modifiedclang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
The file was modifiedclang/lib/StaticAnalyzer/Core/CheckerContext.cpp
The file was modifiedclang/lib/StaticAnalyzer/Core/Environment.cpp
The file was modifiedclang/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp
The file was modifiedclang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
The file was modifiedclang/lib/StaticAnalyzer/Core/BugReporter.cpp
The file was modifiedclang/lib/StaticAnalyzer/Core/Store.cpp
The file was modifiedclang/lib/StaticAnalyzer/Core/ExprEngine.cpp
The file was modifiedclang/lib/StaticAnalyzer/Core/LoopWidening.cpp
The file was modifiedclang/lib/StaticAnalyzer/Core/SymbolManager.cpp
The file was modifiedclang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
The file was modifiedclang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
The file was modifiedclang/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
The file was modifiedclang/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
Commit a29dfc089d18b542694cd26a06bee822ab90fb56 by craig.topper
[RISCV] Use clang_builtin_alias for all RISCV vector intrinsics.

Previously we used builtin_alias for overloaded intrinsics, but
macros for the non-overloaded version. This patch changes the
non-overloaded versions to also use builtin_alias, but without
the overloadable attribute.

Reviewed By: khchen, HsiangKai

Differential Revision: https://reviews.llvm.org/D112020
The file was modifiedclang/utils/TableGen/RISCVVEmitter.cpp
Commit eabf11f9ea8d647d78e455664658b4faf8880029 by fraser
[CodeGenPrepare] Avoid a scalable-vector crash in ctlz/cttz

This patch fixes a crash when despeculating ctlz/cttz intrinsics with
scalable-vector types. It is not safe to speculatively get the size of
the vector type in bits in case the vector type is not a fixed-length type. As
it happens this isn't required as vector types are skipped anyway.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D112141
The file was addedllvm/test/Transforms/CodeGenPrepare/RISCV/cttz-ctlz.ll
The file was addedllvm/test/Transforms/CodeGenPrepare/RISCV/lit.local.cfg
The file was modifiedllvm/lib/CodeGen/CodeGenPrepare.cpp
Commit fe66433fe119819a033827610f7eae4cdd8b1470 by aeubanks
[clang] Add plugin ActionType to run command line plugin before main action

Currently we have a way to run a plugin if specified on the command line
after the main action, and ways to unconditionally run the plugin before
or after the main action, but no way to run a plugin if specified on the
command line before the main action.

This introduces the missing option.

This is helpful because -clear-ast-before-backend clears the AST before
codegen, while some plugins may want access to the AST.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D112096
The file was addedclang/examples/PluginsOrder/PluginsOrder.cpp
The file was modifiedclang/include/clang/Frontend/FrontendAction.h
The file was modifiedclang/examples/CMakeLists.txt
The file was modifiedclang/lib/Frontend/FrontendAction.cpp
The file was addedclang/examples/PluginsOrder/CMakeLists.txt
The file was modifiedclang/test/CMakeLists.txt
The file was modifiedclang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
The file was addedclang/test/Frontend/plugins-order.c
Commit c4c7e06bd700aeccfbe5c1f075bd5897f54b68f2 by Shraiysh.Vaishay
[MLIR][OpenMP] Shifted hint from CriticalOp to CriticalDeclareOp

According to the OpenMP 5.0 standard, names and hints of critical operation are
closely related. The following are the restrictions on them:
- Unless the effect is as if `hint(omp_sync_hint_none)` was specified, the
   critical construct must specify a name.
- If the hint clause is specified, each of the critical constructs with the
   same name must have a hint clause for which the hint-expression evaluates to
   the same value.

These restrictions will be enforced by design if the hint expression is a part
of the `omp.critical.declare` operation.
- Any operation with no "name" will be considered to have
   `hint(omp_sync_hint_none)`.
- All the operations with the same "name" will have the same hint value.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D112134
The file was modifiedmlir/test/Dialect/OpenMP/invalid.mlir
The file was modifiedmlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
The file was modifiedmlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
The file was modifiedmlir/test/Dialect/OpenMP/ops.mlir
The file was modifiedmlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
The file was modifiedmlir/test/Target/LLVMIR/openmp-llvm.mlir
Commit ea9a0556b451a6c439299842ba71972e25dac6e6 by spatel
[InstCombine] add tests for casted insertelement; NFC
The file was addedllvm/test/Transforms/InstCombine/bitcast-inselt-bitcast.ll
Commit 99d1ce4a621aff2871f64c856545545f112051dc by nawrin.sultana
[OpenMP] Add GOMP allocator functions

This patch adds GOMP_alloc and GOMP_free functions of LIBGOMP.

Differential revision: https://reviews.llvm.org/D111673
The file was modifiedopenmp/runtime/src/kmp_ftn_os.h
The file was modifiedopenmp/runtime/src/kmp_gsupport.cpp
The file was modifiedopenmp/runtime/src/exports_so.txt
Commit e1fb13401e1b90a912ba83c6d1a82794cfdb8aec by tlively
[WebAssembly] Add prototype relaxed float min max instructions

Add relaxed. f32x4.min, f32x4.max, f64x2.min, f64x2.max. These are only
exposed as builtins, and require user opt-in.

Differential Revision: https://reviews.llvm.org/D112146
The file was modifiedllvm/test/MC/WebAssembly/simd-encodings.s
The file was modifiedllvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
The file was modifiedclang/include/clang/Basic/BuiltinsWebAssembly.def
The file was modifiedclang/lib/CodeGen/CGBuiltin.cpp
The file was modifiedclang/test/CodeGen/builtins-wasm.c
The file was modifiedllvm/include/llvm/IR/IntrinsicsWebAssembly.td
The file was modifiedllvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
Commit 6b6564fcf9f5cce91630d1888d7e95b187bfc320 by saugustine
Fix unused variable warning.
The file was modifiedcompiler-rt/lib/fuzzer/tests/FuzzerUnittest.cpp
Commit 310736e098f874bb324d1b96d62682e9fb005015 by zinenko
[mlir] fix region property generation in python bindings
The file was modifiedmlir/tools/mlir-tblgen/OpPythonBindingGen.cpp
The file was modifiedmlir/test/mlir-tblgen/op-python-bindings.td
Commit 7562f3df89066ab92a816dc23005c45fd642bdf9 by llvm-dev
InvalidPtrChecker - don't dereference a dyn_cast<> - use cast<> instead.

Avoid dereferencing a nullptr returned by dyn_cast<>, by using cast<> instead which asserts that the cast is valid.
The file was modifiedclang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp
Commit 08ed216000b6503a4a4be52f18394d008d5fb8f4 by i
[IR] Refactor GlobalIFunc to inherit from GlobalObject, Remove GlobalIndirectSymbol

As discussed in:
* https://reviews.llvm.org/D94166
* https://lists.llvm.org/pipermail/llvm-dev/2020-September/145031.html

The GlobalIndirectSymbol class lost most of its meaning in
https://reviews.llvm.org/D109792, which disambiguated getBaseObject
(now getAliaseeObject) between GlobalIFunc and everything else.
In addition, as long as GlobalIFunc is not a GlobalObject and
getAliaseeObject returns GlobalObjects, a GlobalAlias whose aliasee
is a GlobalIFunc cannot currently be modeled properly. Creating
aliases for GlobalIFuncs does happen in the wild (e.g. glibc). In addition,
calling getAliaseeObject on a GlobalIFunc will currently return nullptr,
which is undesirable because it should return the object itself for
non-aliases.

This patch refactors the GlobalIFunc class to inherit directly from
GlobalObject, and removes GlobalIndirectSymbol (while inlining the
relevant parts into GlobalAlias and GlobalIFunc). This allows for
calling getAliaseeObject() on a GlobalIFunc to return the GlobalIFunc
itself, making getAliaseeObject() more consistent and enabling
alias-to-ifunc to be properly modeled in the IR.

I exercised some judgement in the API clients of GlobalIndirectSymbol:
some were 'monomorphized' for GlobalAlias and GlobalIFunc, and
some remained shared (with the type adapted to become GlobalValue).

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D108872
The file was modifiedllvm/lib/Linker/IRMover.cpp
The file was modifiedllvm/include/llvm/IR/GlobalIFunc.h
The file was modifiedllvm/include/llvm/Transforms/Utils/ValueMapper.h
The file was modifiedllvm/include/llvm/IR/Value.h
The file was modifiedllvm/lib/IR/Globals.cpp
The file was modifiedllvm/lib/Transforms/Utils/SplitModule.cpp
The file was modifiedllvm/lib/Transforms/Utils/ValueMapper.cpp
The file was modifiedllvm/lib/Transforms/IPO/LowerTypeTests.cpp
The file was modifiedllvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
The file was modifiedllvm/lib/AsmParser/LLParser.cpp
The file was modifiedllvm/lib/Bitcode/Reader/MetadataLoader.cpp
The file was modifiedllvm/unittests/IR/ConstantsTest.cpp
The file was modifiedllvm/lib/Object/ModuleSymbolTable.cpp
The file was removedllvm/include/llvm/IR/GlobalIndirectSymbol.h
The file was modifiedllvm/include/llvm/IR/GlobalObject.h
The file was modifiedllvm/include/llvm-c/Core.h
The file was modifiedllvm/lib/IR/AsmWriter.cpp
The file was modifiedllvm/include/llvm/CodeGen/AsmPrinter.h
The file was modifiedllvm/include/llvm/IR/GlobalAlias.h
The file was modifiedllvm/lib/Bitcode/Reader/BitcodeReader.cpp
The file was modifiedllvm/include/llvm/AsmParser/LLParser.h
The file was modifiedclang/lib/CodeGen/CodeGenModule.cpp
Commit 2caf7571e1020ae1024ab3f2d52ecc9aea85687d by Akira
[Clang][AST] Resolve FIXME: Remove ObjCObjectPointer from
isSpecifierType

There is no reason to have this here, (since all tests pass) and it
isn't even a specifier anyway. We can just treat it as a pointer
instead.

Differential Revision: https://reviews.llvm.org/D110068
The file was modifiedclang/lib/AST/Type.cpp
The file was modifiedclang/lib/AST/DeclPrinter.cpp
Commit 00500d5bad2270ea244adfdc6a48171968f88901 by aeubanks
[NFC] De-template LazyCallGraph::visitReferences() and move into .cpp file

This makes changing it and recompiling it much faster.
The file was modifiedllvm/include/llvm/Analysis/LazyCallGraph.h
The file was modifiedllvm/lib/Analysis/LazyCallGraph.cpp
Commit 6b82adbb4980593f4661edf94e5539adfe1a9f4e by muiez
Raise compile error when using unimplemented functions

The path functions in this patch are unimplemented (as per the TODO comment from upstream). To avoid running into a linker error (missing symbol), this patch raises a compile error by commenting out the functions, which is more user friendly.

Differential Revision: https://reviews.llvm.org/D111892
The file was modifiedlibcxx/include/filesystem
Commit 503d061dc7a8b36dba1df4bf083021a2482c6fb6 by Stanislav.Mekhanoshin
Precommit InstCombine/and-xor-or.ll test. NFC.
The file was modifiedllvm/test/Transforms/InstCombine/and-xor-or.ll
Commit fb8829768d774689c368c49cb3ca17339378cd91 by thakis
[clang] Disallow mixing SEH and Objective-C exceptions

We already disallow mixing SEH and C++ exceptions, and
mixing SEH and Objective-C exceptions seems to not work (see PR52233).
Emitting an error is friendlier than crashing.

Differential Revision: https://reviews.llvm.org/D112157
The file was modifiedclang/lib/Sema/SemaStmt.cpp
The file was modifiedclang/lib/Sema/ScopeInfo.cpp
The file was modifiedclang/include/clang/Sema/ScopeInfo.h
The file was addedclang/test/SemaCXX/exceptions-seh.mm
The file was modifiedclang/include/clang/Basic/DiagnosticSemaKinds.td
Commit 5692ed0cce8c9506eef40ffe6ca2d9629956c51c by blangmuir
[ORC-RT] Configure the ORC runtime for more architectures and platforms

Enable building the ORC runtime for 64-bit and 32-bit ARM architectures,
and for all Darwin embedded platforms (iOS, tvOS, and watchOS). This
covers building the cross-platform code, but does not add TLV runtime
support for the new architectures, which can be added independently.

Incidentally, stop building the Mach-O TLS support file unnecessarily on
other platforms.

Differential Revision: https://reviews.llvm.org/D112111
The file was modifiedcompiler-rt/lib/orc/simple_packed_serialization.h
The file was modifiedcompiler-rt/lib/orc/macho_tlv.x86-64.S
The file was modifiedcompiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
The file was modifiedcompiler-rt/cmake/config-ix.cmake
The file was modifiedcompiler-rt/lib/orc/CMakeLists.txt
The file was modifiedcompiler-rt/lib/orc/elfnix_tls.x86-64.S
Commit 80ab06c599a0f5a90951c36a57b2a9b492b19d61 by spatel
[InstCombine] fold fake vector insert to bit-logic

bitcast (inselt (bitcast X), Y, 0) --> or (and X, MaskC), (zext Y)

https://alive2.llvm.org/ce/z/Ux-662

Similar to D111082 / db231ebdb07f :
We want to avoid relatively opaque vector ops on types that are
likely supported by the backend as scalar integers. The bitwise
logic ops are more likely to allow further combining.

We probably want to generalize this to allow a shift too, but
that would oppose instcombine's general rule of not creating
extra instructions, so that's left as a potential follow-up.
Alternatively, we could do that transform in VectorCombine
with the help of the TTI cost model.

This is part of solving:
https://llvm.org/PR52057
The file was modifiedllvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
The file was modifiedllvm/test/Transforms/InstCombine/bitcast-inselt-bitcast.ll
Commit 1412719066a6efdfdb35a400d589d84a0ef83f28 by thakis
[lld/mac] Remove else-after-return in ICF code

No behavior change.
The file was modifiedlld/MachO/ICF.cpp
Commit 5d57578a4e48e4b4cdd41533670a012ad265c8a1 by thakis
[MC] Recursively calculate symbol offset

This is speculative since I'm not sure if there's some implicit contract that a
variable symbol must not have another variable symbol in its evaluation tree.

Downstream bug: https://bugs.chromium.org/p/chromium/issues/detail?id=471146#c23.

Test is based on alias.s (removed checks since we just need to know it didn't
crash).

Differential Revision: https://reviews.llvm.org/D109109
The file was modifiedllvm/lib/MC/MCFragment.cpp
The file was addedllvm/test/MC/MachO/chained-alias-offset.s
Commit 618583565687f5a494066fc902a977f6057fc93e by Stanislav.Mekhanoshin
[AMDGPU] Allow rematerialization of SOP with virtual registers

D106408 was doing this for all targets although it was
reverted due to couple performance regressions on some targets.
The difference for AMDGPU is the ability to rematerialize SOP
instructions with virtual register uses like we already do for VOP.

Differential Revision: https://reviews.llvm.org/D110743
The file was modifiedllvm/lib/Target/AMDGPU/SIInstrInfo.cpp
The file was modifiedllvm/test/CodeGen/AMDGPU/remat-sop.mir
Commit c80d8a8ceabb5c42e0143d9507394068075538f9 by Stanislav.Mekhanoshin
[AMDGPU] MachineLICM cannot hoist VALU

MachineLoop::isLoopInvariant() returns false for all VALU
because of the exec use. Check TII::isIgnorableUse() to
allow hoisting.

That unfortunately results in higher register consumption
since MachineLICM does not adequately estimate pressure.
Therefor I think it shall only be enabled after D107677 even
though it does not depend on it.

Differential Revision: https://reviews.llvm.org/D107859
The file was modifiedllvm/test/CodeGen/AMDGPU/indirect-call.ll
The file was modifiedllvm/test/CodeGen/AMDGPU/wave32.ll
The file was modifiedllvm/test/CodeGen/AMDGPU/global-atomics-fp.ll
The file was modifiedllvm/test/CodeGen/AMDGPU/vgpr-descriptor-waterfall-loop-idom-update.ll
The file was modifiedllvm/test/CodeGen/AMDGPU/fp64-atomics-gfx90a.ll
The file was modifiedllvm/test/CodeGen/AMDGPU/srem64.ll
The file was modifiedllvm/test/CodeGen/AMDGPU/unstructured-cfg-def-use-issue.ll
The file was modifiedllvm/test/CodeGen/AMDGPU/sdiv64.ll
The file was modifiedllvm/test/CodeGen/AMDGPU/udiv64.ll
The file was modifiedllvm/test/CodeGen/AMDGPU/urem64.ll
The file was modifiedllvm/test/CodeGen/AMDGPU/dag-divergence-atomic.ll
The file was modifiedllvm/lib/CodeGen/MachineLoopInfo.cpp
The file was modifiedllvm/test/CodeGen/AMDGPU/mul24-pass-ordering.ll
The file was modifiedllvm/test/CodeGen/AMDGPU/infinite-loop.ll
Commit 207998c242c8c8a270ff22a5136da87338546725 by Jonas Devlieghere
[lldb] Remove variable "any" which is set but not used
The file was modifiedlldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm
Commit b046eb19b8a42ffa3b4742e765cc013d3eefd6b5 by Jon Roelofs
[AArch64][GlobalISel] combine (and (or x, c1), c2) => (and x, c2) iff c1 & c2 == 0

https://godbolt.org/z/h8ejrG4hb

rdar://83597585

Differential Revision: https://reviews.llvm.org/D111856
The file was modifiedllvm/include/llvm/Target/GlobalISel/Combine.td
The file was modifiedllvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
The file was addedllvm/test/CodeGen/AArch64/GlobalISel/combine-and-or-disjoint-mask.mir
The file was modifiedllvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h