Skip to content

Commit 4e544f4

Browse files
authored
merge main into amd-staging (llvm#2604)
2 parents 0d4b852 + 5115bc5 commit 4e544f4

File tree

313 files changed

+5103
-2336
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

313 files changed

+5103
-2336
lines changed

clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,21 @@ intCastExpression(bool IsSigned,
3939
// std::cmp_{} functions trigger a compile-time error if either LHS or RHS
4040
// is a non-integer type, char, enum or bool
4141
// (unsigned char/ signed char are Ok and can be used).
42-
const auto HasIntegerType = hasType(hasCanonicalType(qualType(
42+
auto IntTypeExpr = expr(hasType(hasCanonicalType(qualType(
4343
isInteger(), IsSigned ? isSignedInteger() : isUnsignedInteger(),
44-
unless(isActualChar()), unless(booleanType()), unless(enumType()))));
45-
46-
const auto IntTypeExpr = expr(HasIntegerType);
44+
unless(isActualChar()), unless(booleanType()), unless(enumType())))));
4745

4846
const auto ImplicitCastExpr =
4947
CastBindName.empty() ? implicitCastExpr(hasSourceExpression(IntTypeExpr))
5048
: implicitCastExpr(hasSourceExpression(IntTypeExpr))
5149
.bind(CastBindName);
5250

53-
const auto ExplicitCastExpr =
54-
anyOf(explicitCastExpr(has(ImplicitCastExpr)),
55-
ignoringImpCasts(explicitCastExpr(has(ImplicitCastExpr))));
56-
57-
// Match function calls or variable references not directly wrapped by an
58-
// implicit cast
59-
const auto CallIntExpr = CastBindName.empty()
60-
? callExpr(HasIntegerType)
61-
: callExpr(HasIntegerType).bind(CastBindName);
51+
const auto CStyleCastExpr = cStyleCastExpr(has(ImplicitCastExpr));
52+
const auto StaticCastExpr = cxxStaticCastExpr(has(ImplicitCastExpr));
53+
const auto FunctionalCastExpr = cxxFunctionalCastExpr(has(ImplicitCastExpr));
6254

63-
return expr(anyOf(ImplicitCastExpr, ExplicitCastExpr, CallIntExpr));
55+
return expr(anyOf(ImplicitCastExpr, CStyleCastExpr, StaticCastExpr,
56+
FunctionalCastExpr));
6457
}
6558

6659
static StringRef parseOpCode(BinaryOperator::Opcode Code) {

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,6 @@ Changes in existing checks
237237
<clang-tidy/checks/modernize/use-designated-initializers>` check by avoiding
238238
diagnosing designated initializers for ``std::array`` initializations.
239239

240-
- Improved :doc:`modernize-use-integer-sign-comparison
241-
<clang-tidy/checks/modernize/use-integer-sign-comparison>` check by matching
242-
valid integer expressions not directly wrapped around an implicit cast.
243-
244240
- Improved :doc:`modernize-use-ranges
245241
<clang-tidy/checks/modernize/use-ranges>` check by updating suppress
246242
warnings logic for ``nullptr`` in ``std::find``.

clang-tools-extra/test/clang-tidy/checkers/modernize/use-integer-sign-comparison.cpp

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -121,81 +121,3 @@ int AllComparisons() {
121121

122122
return 0;
123123
}
124-
125-
namespace PR127471 {
126-
int getSignedValue();
127-
unsigned int getUnsignedValue();
128-
129-
void callExprTest() {
130-
131-
if (getSignedValue() < getUnsignedValue())
132-
return;
133-
// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]
134-
// CHECK-FIXES: if (std::cmp_less(getSignedValue() , getUnsignedValue()))
135-
136-
int sVar = 0;
137-
if (getUnsignedValue() > sVar)
138-
return;
139-
// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]
140-
// CHECK-FIXES: if (std::cmp_greater(getUnsignedValue() , sVar))
141-
142-
unsigned int uVar = 0;
143-
if (getSignedValue() > uVar)
144-
return;
145-
// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]
146-
// CHECK-FIXES: if (std::cmp_greater(getSignedValue() , uVar))
147-
148-
}
149-
150-
// Add a class with member functions for testing member function calls
151-
class TestClass {
152-
public:
153-
int getSignedValue() { return -5; }
154-
unsigned int getUnsignedValue() { return 5; }
155-
};
156-
157-
void memberFunctionTests() {
158-
TestClass obj;
159-
160-
if (obj.getSignedValue() < obj.getUnsignedValue())
161-
return;
162-
// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]
163-
// CHECK-FIXES: if (std::cmp_less(obj.getSignedValue() , obj.getUnsignedValue()))
164-
}
165-
166-
void castFunctionTests() {
167-
// C-style casts with function calls
168-
if ((int)getUnsignedValue() < (unsigned int)getSignedValue())
169-
return;
170-
// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]
171-
// CHECK-FIXES: if (std::cmp_less(getUnsignedValue(),getSignedValue()))
172-
173-
174-
// Static casts with function calls
175-
if (static_cast<int>(getUnsignedValue()) < static_cast<unsigned int>(getSignedValue()))
176-
return;
177-
// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]
178-
// CHECK-FIXES: if (std::cmp_less(getUnsignedValue(),getSignedValue()))
179-
}
180-
181-
// Define tests
182-
#define SIGNED_FUNC getSignedValue()
183-
#define UNSIGNED_FUNC getUnsignedValue()
184-
185-
void defineTests() {
186-
if (SIGNED_FUNC < UNSIGNED_FUNC)
187-
return;
188-
// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]
189-
// CHECK-FIXES: if (std::cmp_less(SIGNED_FUNC , UNSIGNED_FUNC))
190-
}
191-
192-
// Template tests (should not warn)
193-
template <typename T1>
194-
void templateFunctionTest(T1 value) {
195-
if (value() < getUnsignedValue())
196-
return;
197-
198-
if (value() < (getSignedValue() || getUnsignedValue()))
199-
return;
200-
}
201-
} // namespace PR127471

clang/docs/SanitizerSpecialCaseList.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ precedence. Here are a few examples.
109109
.. code-block:: bash
110110
111111
$ cat ignorelist1.txt
112-
# test.cc will be instrumented.
112+
# test.cc will not be instrumented.
113113
src:*
114114
src:*/mylib/*=sanitize
115115
src:*/mylib/test.cc
116116
117117
$ cat ignorelist2.txt
118-
# test.cc will not be instrumented.
118+
# test.cc will be instrumented.
119119
src:*
120120
src:*/mylib/test.cc
121121
src:*/mylib/*=sanitize

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ def err_drv_cannot_open_randomize_layout_seed_file : Error<
219219
"cannot read randomize layout seed file '%0'">;
220220
def err_drv_invalid_version_number : Error<
221221
"invalid version number in '%0'">;
222+
def err_drv_invalid_version_number_inferred
223+
: Error<"invalid version number '%0' inferred from '%1'">;
222224
def err_drv_missing_version_number : Error<"missing version number in '%0'">;
223225
def err_drv_kcfi_arity_unsupported_target : Error<
224226
"target '%0' is unsupported by -fsanitize-kcfi-arity">;

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,6 +2059,7 @@ def VecCreateOp : CIR_Op<"vec.create", [Pure]> {
20592059
}];
20602060

20612061
let hasVerifier = 1;
2062+
let hasFolder = 1;
20622063
}
20632064

20642065
//===----------------------------------------------------------------------===//

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ struct MissingFeatures {
8181
static bool opFuncCPUAndFeaturesAttributes() { return false; }
8282
static bool opFuncSection() { return false; }
8383
static bool opFuncSetComdat() { return false; }
84+
static bool opFuncAttributesForDefinition() { return false; }
8485

8586
// CallOp handling
8687
static bool opCallPseudoDtor() { return false; }
@@ -226,6 +227,9 @@ struct MissingFeatures {
226227
static bool implicitConstructorArgs() { return false; }
227228
static bool intrinsics() { return false; }
228229
static bool attributeNoBuiltin() { return false; }
230+
static bool emitCtorPrologue() { return false; }
231+
static bool thunks() { return false; }
232+
static bool runCleanupsScope() { return false; }
229233

230234
// Missing types
231235
static bool dataMemberType() { return false; }

clang/lib/Basic/Targets/PPC.cpp

Lines changed: 7 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "clang/Basic/MacroBuilder.h"
1616
#include "clang/Basic/TargetBuiltins.h"
1717
#include "llvm/TargetParser/PPCTargetParser.h"
18+
#include <optional>
1819

1920
using namespace clang;
2021
using namespace clang::targets;
@@ -516,129 +517,14 @@ static bool ppcUserFeaturesCheck(DiagnosticsEngine &Diags,
516517
bool PPCTargetInfo::initFeatureMap(
517518
llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, StringRef CPU,
518519
const std::vector<std::string> &FeaturesVec) const {
519-
Features["altivec"] = llvm::StringSwitch<bool>(CPU)
520-
.Case("7400", true)
521-
.Case("g4", true)
522-
.Case("7450", true)
523-
.Case("g4+", true)
524-
.Case("970", true)
525-
.Case("g5", true)
526-
.Case("pwr6", true)
527-
.Case("pwr7", true)
528-
.Case("pwr8", true)
529-
.Case("pwr9", true)
530-
.Case("ppc64", true)
531-
.Case("ppc64le", true)
532-
.Default(false);
533-
534-
Features["power9-vector"] = (CPU == "pwr9");
535-
Features["crypto"] = llvm::StringSwitch<bool>(CPU)
536-
.Case("ppc64le", true)
537-
.Case("pwr9", true)
538-
.Case("pwr8", true)
539-
.Default(false);
540-
Features["power8-vector"] = llvm::StringSwitch<bool>(CPU)
541-
.Case("ppc64le", true)
542-
.Case("pwr9", true)
543-
.Case("pwr8", true)
544-
.Default(false);
545-
Features["bpermd"] = llvm::StringSwitch<bool>(CPU)
546-
.Case("ppc64le", true)
547-
.Case("pwr9", true)
548-
.Case("pwr8", true)
549-
.Case("pwr7", true)
550-
.Default(false);
551-
Features["extdiv"] = llvm::StringSwitch<bool>(CPU)
552-
.Case("ppc64le", true)
553-
.Case("pwr9", true)
554-
.Case("pwr8", true)
555-
.Case("pwr7", true)
556-
.Default(false);
557-
Features["direct-move"] = llvm::StringSwitch<bool>(CPU)
558-
.Case("ppc64le", true)
559-
.Case("pwr9", true)
560-
.Case("pwr8", true)
561-
.Default(false);
562-
Features["crbits"] = llvm::StringSwitch<bool>(CPU)
563-
.Case("ppc64le", true)
564-
.Case("pwr9", true)
565-
.Case("pwr8", true)
566-
.Default(false);
567-
Features["vsx"] = llvm::StringSwitch<bool>(CPU)
568-
.Case("ppc64le", true)
569-
.Case("pwr9", true)
570-
.Case("pwr8", true)
571-
.Case("pwr7", true)
572-
.Default(false);
573-
Features["htm"] = llvm::StringSwitch<bool>(CPU)
574-
.Case("ppc64le", true)
575-
.Case("pwr9", true)
576-
.Case("pwr8", true)
577-
.Default(false);
578-
579-
// ROP Protect is off by default.
580-
Features["rop-protect"] = false;
581-
// Privileged instructions are off by default.
582-
Features["privileged"] = false;
583520

584-
if (getTriple().isOSAIX()) {
585-
// The code generated by the -maix-small-local-[exec|dynamic]-tls option is
586-
// turned off by default.
587-
Features["aix-small-local-exec-tls"] = false;
588-
Features["aix-small-local-dynamic-tls"] = false;
589-
590-
// Turn off TLS model opt by default.
591-
Features["aix-shared-lib-tls-model-opt"] = false;
592-
}
593-
594-
Features["spe"] = llvm::StringSwitch<bool>(CPU)
595-
.Case("8548", true)
596-
.Case("e500", true)
597-
.Default(false);
598-
599-
Features["isa-v206-instructions"] = llvm::StringSwitch<bool>(CPU)
600-
.Case("ppc64le", true)
601-
.Case("pwr9", true)
602-
.Case("pwr8", true)
603-
.Case("pwr7", true)
604-
.Case("a2", true)
605-
.Default(false);
606-
607-
Features["isa-v207-instructions"] = llvm::StringSwitch<bool>(CPU)
608-
.Case("ppc64le", true)
609-
.Case("pwr9", true)
610-
.Case("pwr8", true)
611-
.Default(false);
612-
613-
Features["isa-v30-instructions"] =
614-
llvm::StringSwitch<bool>(CPU).Case("pwr9", true).Default(false);
615-
616-
Features["quadword-atomics"] =
617-
getTriple().isArch64Bit() && llvm::StringSwitch<bool>(CPU)
618-
.Case("pwr9", true)
619-
.Case("pwr8", true)
620-
.Default(false);
621-
622-
// Power10 includes all the same features as Power9 plus any features specific
623-
// to the Power10 core.
624-
if (CPU == "pwr10" || CPU == "power10") {
625-
initFeatureMap(Features, Diags, "pwr9", FeaturesVec);
626-
addP10SpecificFeatures(Features);
627-
}
628-
629-
// Power11 includes all the same features as Power10 plus any features
630-
// specific to the Power11 core.
631-
if (CPU == "pwr11" || CPU == "power11") {
632-
initFeatureMap(Features, Diags, "pwr10", FeaturesVec);
633-
addP11SpecificFeatures(Features);
634-
}
521+
const llvm::Triple &TheTriple = getTriple();
635522

636-
// Future CPU should include all of the features of Power 11 as well as any
637-
// additional features (yet to be determined) specific to it.
638-
if (CPU == "future") {
639-
initFeatureMap(Features, Diags, "pwr11", FeaturesVec);
640-
addFutureSpecificFeatures(Features);
641-
}
523+
std::optional<llvm::StringMap<bool>> FeaturesOpt =
524+
llvm::PPC::getPPCDefaultTargetFeatures(TheTriple,
525+
llvm::PPC::normalizeCPUName(CPU));
526+
if (FeaturesOpt)
527+
Features = FeaturesOpt.value();
642528

643529
if (!ppcUserFeaturesCheck(Diags, FeaturesVec))
644530
return false;
@@ -700,26 +586,6 @@ bool PPCTargetInfo::initFeatureMap(
700586
return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
701587
}
702588

703-
// Add any Power10 specific features.
704-
void PPCTargetInfo::addP10SpecificFeatures(
705-
llvm::StringMap<bool> &Features) const {
706-
Features["htm"] = false; // HTM was removed for P10.
707-
Features["paired-vector-memops"] = true;
708-
Features["mma"] = true;
709-
Features["power10-vector"] = true;
710-
Features["pcrelative-memops"] = true;
711-
Features["prefix-instrs"] = true;
712-
Features["isa-v31-instructions"] = true;
713-
}
714-
715-
// Add any Power11 specific features.
716-
void PPCTargetInfo::addP11SpecificFeatures(
717-
llvm::StringMap<bool> &Features) const {}
718-
719-
// Add features specific to the "Future" CPU.
720-
void PPCTargetInfo::addFutureSpecificFeatures(
721-
llvm::StringMap<bool> &Features) const {}
722-
723589
bool PPCTargetInfo::hasFeature(StringRef Feature) const {
724590
return llvm::StringSwitch<bool>(Feature)
725591
.Case("powerpc", true)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This contains code dealing with C++ code generation.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "CIRGenFunction.h"
14+
#include "CIRGenModule.h"
15+
16+
#include "clang/AST/GlobalDecl.h"
17+
#include "clang/CIR/MissingFeatures.h"
18+
19+
using namespace clang;
20+
using namespace clang::CIRGen;
21+
22+
cir::FuncOp CIRGenModule::codegenCXXStructor(GlobalDecl gd) {
23+
const CIRGenFunctionInfo &fnInfo =
24+
getTypes().arrangeCXXStructorDeclaration(gd);
25+
cir::FuncType funcType = getTypes().getFunctionType(fnInfo);
26+
cir::FuncOp fn = getAddrOfCXXStructor(gd, &fnInfo, /*FnType=*/nullptr,
27+
/*DontDefer=*/true, ForDefinition);
28+
assert(!cir::MissingFeatures::opFuncLinkage());
29+
CIRGenFunction cgf{*this, builder};
30+
curCGF = &cgf;
31+
{
32+
mlir::OpBuilder::InsertionGuard guard(builder);
33+
cgf.generateCode(gd, fn, funcType);
34+
}
35+
curCGF = nullptr;
36+
37+
setNonAliasAttributes(gd, fn);
38+
assert(!cir::MissingFeatures::opFuncAttributesForDefinition());
39+
return fn;
40+
}

0 commit comments

Comments
 (0)