Skip to content

Commit

Permalink
Merged main:4d6fc88946ee into amd-gfx:c0764b100efa
Browse files Browse the repository at this point in the history
Local branch amd-gfx c0764b1 Merged main:160e8eb44961 into amd-gfx:da11a8d21864
Remote branch main 4d6fc88 [AMDGPU] Add patterns for V_CMP_O/U (llvm#69157)
  • Loading branch information
SC llvm team authored and SC llvm team committed Oct 16, 2023
2 parents c0764b1 + 4d6fc88 commit 90bb2f0
Show file tree
Hide file tree
Showing 580 changed files with 18,867 additions and 10,232 deletions.
10 changes: 10 additions & 0 deletions .ci/generate-buildkite-pipeline-premerge
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ set -o pipefail
# Environment variables script works with:
# List of files affected by this commit
: ${MODIFIED_FILES:=$(git diff --name-only HEAD~1)}
# Fetch origin/main to have an up to date merge base for main...HEAD diff.
git fetch origin main:main
echo "files modified HEAD~1" >&2
git --no-pager diff --name-only HEAD~1 >&2
echo "files modified main...HEAD" >&2
git --no-pager diff --name-only main...HEAD | head -n 10 >&2
merge_base=$(git merge-base main HEAD)
echo "merge base with main $merge_base" >&2
echo "git log" >&2
git --no-pager log --oneline --abbrev-commit -n 5 >&2
# Filter rules for generic windows tests
: ${WINDOWS_AGENTS:='{"queue": "windows"}'}
# Filter rules for generic linux tests
Expand Down
5 changes: 1 addition & 4 deletions bolt/lib/Core/HashUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,7 @@ std::string hashBlockLoose(BinaryContext &BC, const BinaryBasicBlock &BB) {
}

std::string Mnemonic = BC.InstPrinter->getMnemonic(&Inst).first;
Mnemonic.erase(
std::remove_if(Mnemonic.begin(), Mnemonic.end(),
[](unsigned char ch) { return std::isspace(ch); }),
Mnemonic.end());
llvm::erase_if(Mnemonic, [](unsigned char ch) { return std::isspace(ch); });
Opcodes.insert(Mnemonic);
}

Expand Down
6 changes: 6 additions & 0 deletions bolt/lib/Rewrite/RewriteInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1582,6 +1582,12 @@ void RewriteInstance::adjustFunctionBoundaries() {
if (!Function.isSymbolValidInScope(Symbol, SymbolSize))
break;

// Ignore unnamed symbols. Used, for example, by debugging info on RISC-V.
if (BC->isRISCV() && cantFail(Symbol.getName()).empty()) {
++NextSymRefI;
continue;
}

// Skip basic block labels. This happens on RISC-V with linker relaxation
// enabled because every branch needs a relocation and corresponding
// symbol. We don't want to add such symbols as entry points.
Expand Down
28 changes: 28 additions & 0 deletions bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,33 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
public:
using MCPlusBuilder::MCPlusBuilder;

bool equals(const MCTargetExpr &A, const MCTargetExpr &B,
CompFuncTy Comp) const override {
const auto &RISCVExprA = cast<RISCVMCExpr>(A);
const auto &RISCVExprB = cast<RISCVMCExpr>(B);
if (RISCVExprA.getKind() != RISCVExprB.getKind())
return false;

return MCPlusBuilder::equals(*RISCVExprA.getSubExpr(),
*RISCVExprB.getSubExpr(), Comp);
}

void getCalleeSavedRegs(BitVector &Regs) const override {
Regs |= getAliases(RISCV::X2);
Regs |= getAliases(RISCV::X8);
Regs |= getAliases(RISCV::X9);
Regs |= getAliases(RISCV::X18);
Regs |= getAliases(RISCV::X19);
Regs |= getAliases(RISCV::X20);
Regs |= getAliases(RISCV::X21);
Regs |= getAliases(RISCV::X22);
Regs |= getAliases(RISCV::X23);
Regs |= getAliases(RISCV::X24);
Regs |= getAliases(RISCV::X25);
Regs |= getAliases(RISCV::X26);
Regs |= getAliases(RISCV::X27);
}

bool shouldRecordCodeRelocation(uint64_t RelType) const override {
switch (RelType) {
case ELF::R_RISCV_JAL:
Expand Down Expand Up @@ -292,6 +319,7 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
default:
return false;
case RISCV::C_J:
case TargetOpcode::EH_LABEL:
OpNum = 0;
return true;
case RISCV::AUIPC:
Expand Down
18 changes: 18 additions & 0 deletions bolt/test/RISCV/unnamed-sym-no-entry.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/// Verify that unnamed symbols are not added as function entry points. Such
/// symbols are used by relocations in debugging sections.

// clang-format off

// RUN: %clang %cflags -g -Wl,-q -o %t %s

/// Verify that the binary indeed contains an unnamed symbol at _start
// RUN: llvm-readelf -s %t | FileCheck %s --check-prefix=CHECK-ELF
// CHECK-ELF-DAG: [[#%x,START:]] {{.*}} FUNC GLOBAL DEFAULT [[#%d,SECTION:]] _start{{$}}
// CHECK-ELF-DAG: [[#%x,START]] {{.*}} NOTYPE LOCAL DEFAULT [[#SECTION]] {{$}}

/// Verify that BOLT did not create an extra entry point for the unnamed symbol
// RUN: llvm-bolt -o %t.bolt %t --print-cfg | FileCheck %s
// CHECK: Binary Function "_start" after building cfg {
// CHECK: IsMultiEntry: 0

void _start() {}
File renamed without changes.
4 changes: 3 additions & 1 deletion bolt/test/reorder-data-writable-ptload.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// This test checks that reorder-data pass puts new hot .data section
// to the writable segment.

// RUN: %clang %cflags -O3 -nostdlib -Wl,-q %s -o %t.exe
// Use -fPIC -pie to prevent the globals being put in .sdata instead of .data on
// RISC-V.
// RUN: %clang %cflags -fPIC -pie -O3 -nostdlib -Wl,-q %s -o %t.exe
// RUN: llvm-bolt %t.exe -o %t.bolt --reorder-data=".data" \
// RUN: -data %S/Inputs/reorder-data-writable-ptload.fdata
// RUN: llvm-readelf -SlW %t.bolt | FileCheck %s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ void RvalueReferenceParamNotMovedCheck::check(
if (IgnoreUnnamedParams && Param->getName().empty())
return;

if (!Param->isUsed() && Param->hasAttr<UnusedAttr>())
return;

const auto *Function = dyn_cast<FunctionDecl>(Param->getDeclContext());
if (!Function)
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,7 @@ void LoopConvertCheck::doConversion(
bool IsCheapToCopy =
!Descriptor.ElemType.isNull() &&
Descriptor.ElemType.isTriviallyCopyableType(*Context) &&
!Descriptor.ElemType->isDependentSizedArrayType() &&
// TypeInfo::Width is in bits.
Context->getTypeInfo(Descriptor.ElemType).Width <= 8 * MaxCopySize;
bool UseCopy = CanCopy && ((VarNameFromAlias && !AliasVarIsRef) ||
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/index/SymbolCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ void SymbolCollector::finish() {
const Symbol *S = Symbols.find(SID);
if (!S)
continue;
assert(IncludeFiles.find(SID) != IncludeFiles.end());
assert(IncludeFiles.contains(SID));

const auto FID = IncludeFiles.at(SID);
// Determine if the FID is #include'd or #import'ed.
Expand Down
7 changes: 6 additions & 1 deletion clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ Changes in existing checks
<clang-tidy/checks/cppcoreguidelines/pro-type-vararg>` check to ignore
false-positives in unevaluated context (e.g., ``decltype``, ``sizeof``, ...).

- Improved :doc:`cppcoreguidelines-rvalue-reference-param-not-moved
<clang-tidy/checks/cppcoreguidelines/rvalue-reference-param-not-moved>` check
to ignore unused parameters when they are marked as unused.

- Improved :doc:`llvm-namespace-comment
<clang-tidy/checks/llvm/namespace-comment>` check to provide fixes for
``inline`` namespaces in the same format as :program:`clang-format`.
Expand Down Expand Up @@ -267,7 +271,8 @@ Changes in existing checks

- Improved :doc:`modernize-loop-convert
<clang-tidy/checks/modernize/loop-convert>` to support for-loops with
iterators initialized by free functions like ``begin``, ``end``, or ``size``.
iterators initialized by free functions like ``begin``, ``end``, or ``size``
and avoid crash for array of dependent array.

- Improved :doc:`modernize-return-braced-init-list
<clang-tidy/checks/modernize/return-braced-init-list>` check to ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ Example:
std::string Copy(Input); // Oops - forgot to std::move
}

Note that parameters that are unused and marked as such will not be diagnosed.

Example:

.. code-block:: c++

void conditional_use([[maybe_unused]] std::string&& Input) {
// No diagnostic here since Input is unused and marked as such
}

Options
-------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ using testing::ElementsAre;
using testing::ElementsAreArray;
using testing::Eq;
using testing::Field;
using testing::Pair;
using testing::UnorderedElementsAre;

// A helper for building ASTs and getting decls out of it by name. Example usage
// looks like:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,28 @@ void instantiate_a_class_template() {
AClassTemplate<Obj&> withObjRef(o);
withObjRef.never_moves(o);
}

namespace gh68209
{
void f1([[maybe_unused]] int&& x) {}

void f2(__attribute__((unused)) int&& x) {}

void f3(int&& x) {}
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: rvalue reference parameter 'x' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]

template <typename T>
void f4([[maybe_unused]] T&& x) {}

template <typename T>
void f5(__attribute((unused)) T&& x) {}

template<typename T>
void f6(T&& x) {}

void f7([[maybe_unused]] int&& x) { x += 1; }
// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: rvalue reference parameter 'x' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]

void f8(__attribute__((unused)) int&& x) { x += 1; }
// CHECK-MESSAGES: :[[@LINE-1]]:41: warning: rvalue reference parameter 'x' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
} // namespace gh68209
Original file line number Diff line number Diff line change
Expand Up @@ -939,4 +939,18 @@ void fundamentalTypesTest() {
// CHECK-FIXES: for (double Double : Doubles)
}

template <unsigned p> void _dependenceArrayTest() {
unsigned test[3][p];
for (unsigned i = 0; i < p; ++i)
for (unsigned j = 0; j < 3; ++j)
printf("%d", test[j][i]);
// CHECK-MESSAGES: :[[@LINE-2]]:5: warning: use range-based for loop instead
// CHECK-FIXES: (auto & j : test)
// CHECK-FIXES: printf("%d", j[i]);
}
void dependenceArrayTest() {
_dependenceArrayTest<1>();
_dependenceArrayTest<2>();
}

} // namespace PseudoArray
21 changes: 20 additions & 1 deletion clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ C++ Specific Potentially Breaking Changes
Clang as a compiler, but it may break assumptions in Clang-based tools
iterating over the AST.

- The warning `-Wenum-constexpr-conversion` is now also enabled by default on
system headers and macros. It will be turned into a hard (non-downgradable)
error in the next Clang release.

ABI Changes in This Version
---------------------------
- Following the SystemV ABI for x86-64, ``__int128`` arguments will no longer
Expand Down Expand Up @@ -157,6 +161,11 @@ C Language Changes
- ``structs``, ``unions``, and ``arrays`` that are const may now be used as
constant expressions. This change is more consistent with the behavior of
GCC.
- Clang now supports the C-only attribute ``counted_by``. When applied to a
struct's flexible array member, it points to the struct field that holds the
number of elements in the flexible array member. This information can improve
the results of the array bound sanitizer and the
``__builtin_dynamic_object_size`` builtin.

C23 Feature Support
^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -196,6 +205,10 @@ Modified Compiler Flags
* ``-frewrite-includes`` now guards the original #include directives with
``__CLANG_REWRITTEN_INCLUDES``, and ``__CLANG_REWRITTEN_SYSTEM_INCLUDES`` as
appropriate.
* Introducing a new default calling convention for ``-fdefault-calling-conv``:
``rtdcall``. This new default CC only works for M68k and will use the new
``m68k_rtdcc`` CC on every functions that are not variadic. The ``-mrtd``
driver/frontend flag has the same effect when targeting M68k.

Removed Compiler Flags
-------------------------
Expand Down Expand Up @@ -377,10 +390,13 @@ Bug Fixes in This Version
cannot be used with ``Release`` mode builds. (`#68237 <https://github.com/llvm/llvm-project/issues/68237>`_).
- Fix crash in evaluating ``constexpr`` value for invalid template function.
Fixes (`#68542 <https://github.com/llvm/llvm-project/issues/68542>`_)

- Fixed an issue when a shift count larger than ``__INT64_MAX__``, in a right
shift operation, could result in missing warnings about
``shift count >= width of type`` or internal compiler error.
- Fixed an issue with computing the common type for the LHS and RHS of a `?:`
operator in C. No longer issuing a confusing diagnostic along the lines of
"incompatible operand types ('foo' and 'foo')" with extensions such as matrix
types. Fixes (`#69008 <https://github.com/llvm/llvm-project/issues/69008>`_)

Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -535,6 +551,9 @@ X86 Support

- Added option ``-m[no-]evex512`` to disable ZMM and 64-bit mask instructions
for AVX512 features.
- Support ISA of ``USER_MSR``.
* Support intrinsic of ``_urdmsr``.
* Support intrinsic of ``_uwrmsr``.

Arm and AArch64 Support
^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
9 changes: 9 additions & 0 deletions clang/docs/StandardCPlusPlusModules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,15 @@ the BMI within ``clang-cl.exe``.

This is tracked in: https://github.com/llvm/llvm-project/issues/64118

delayed template parsing is not supported/broken with C++ modules
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The feature `-fdelayed-template-parsing` can't work well with C++ modules now.
Note that this is significant on Windows since the option will be enabled by default
on Windows.

This is tracked in: https://github.com/llvm/llvm-project/issues/61068

Header Units
============

Expand Down
1 change: 1 addition & 0 deletions clang/include/clang-c/Index.h
Original file line number Diff line number Diff line change
Expand Up @@ -2980,6 +2980,7 @@ enum CXCallingConv {
CXCallingConv_AArch64VectorCall = 16,
CXCallingConv_SwiftAsync = 17,
CXCallingConv_AArch64SVEPCS = 18,
CXCallingConv_M68kRTD = 19,

CXCallingConv_Invalid = 100,
CXCallingConv_Unexposed = 200
Expand Down
24 changes: 24 additions & 0 deletions clang/include/clang/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -4302,6 +4302,30 @@ class RecordDecl : public TagDecl {
return field_begin() == field_end();
}

FieldDecl *getLastField() {
FieldDecl *FD = nullptr;
for (FieldDecl *Field : fields())
FD = Field;
return FD;
}
const FieldDecl *getLastField() const {
return const_cast<RecordDecl *>(this)->getLastField();
}

template <typename Functor>
const FieldDecl *findFieldIf(Functor &Pred) const {
for (const Decl *D : decls()) {
if (const auto *FD = dyn_cast<FieldDecl>(D); FD && Pred(FD))
return FD;

if (const auto *RD = dyn_cast<RecordDecl>(D))
if (const FieldDecl *FD = RD->findFieldIf(Pred))
return FD;
}

return nullptr;
}

/// Note that the definition of this type is now complete.
virtual void completeDefinition();

Expand Down
10 changes: 10 additions & 0 deletions clang/include/clang/AST/DeclBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "clang/AST/DeclarationName.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/Specifiers.h"
#include "llvm/ADT/ArrayRef.h"
Expand Down Expand Up @@ -477,6 +478,15 @@ class alignas(8) Decl {
// Return true if this is a FileContext Decl.
bool isFileContextDecl() const;

/// Whether it resembles a flexible array member. This is a static member
/// because we want to be able to call it with a nullptr. That allows us to
/// perform non-Decl specific checks based on the object's type and strict
/// flex array level.
static bool isFlexibleArrayMemberLike(
ASTContext &Context, const Decl *D, QualType Ty,
LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel,
bool IgnoreTemplateOrMacroSubstitution);

ASTContext &getASTContext() const LLVM_READONLY;

/// Helper to get the language options from the ASTContext.
Expand Down
1 change: 0 additions & 1 deletion clang/include/clang/Analysis/FlowSensitive/Formula.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/ADT/STLFunctionalExtras.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
Expand Down
Loading

0 comments on commit 90bb2f0

Please sign in to comment.