Skip to content

Commit 961ceed

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:6932f47cfdf4734d68759586047aee240861058e into amd-gfx:781baf4fd9cc
Local branch amd-gfx 781baf4 Manually merged main:1e70122cbc187c08de91a3fb42843efb1221e0e9 into amd-gfx:e9f81d759667 Remote branch main 6932f47 [NFC][VPlan] Correct two typos in comments.
2 parents 781baf4 + 6932f47 commit 961ceed

File tree

494 files changed

+13915
-4600
lines changed

Some content is hidden

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

494 files changed

+13915
-4600
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ Improvements to Clang's diagnostics
239239

240240
- Clang now diagnoses when the result of a [[nodiscard]] function is discarded after being cast in C. Fixes #GH104391.
241241

242+
- Don't emit duplicated dangling diagnostics. (#GH93386).
243+
242244
Improvements to Clang's time-trace
243245
----------------------------------
244246

clang/docs/StandardCPlusPlusModules.rst

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,74 +1297,6 @@ A high-level overview of support for standards features, including modules, can
12971297
be found on the `C++ Feature Status <https://clang.llvm.org/cxx_status.html>`_
12981298
page.
12991299

1300-
Missing VTables for classes attached to modules
1301-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1302-
1303-
Now the compiler may miss emitting the definition of vtables
1304-
for classes attached to modules, if the definition of the class
1305-
doesn't contain any key function in that module units
1306-
(The key function is the first non-pure virtual function that is
1307-
not inline at the point of class definition.)
1308-
1309-
(Note: technically, the key function is not a thing for modules.
1310-
We use the concept here for convinient.)
1311-
1312-
For example,
1313-
1314-
.. code-block:: c++
1315-
1316-
// layer1.cppm
1317-
export module foo:layer1;
1318-
struct Fruit {
1319-
virtual ~Fruit() = default;
1320-
virtual void eval() = 0;
1321-
};
1322-
struct Banana : public Fruit {
1323-
Banana() {}
1324-
void eval() override;
1325-
};
1326-
1327-
// layer2.cppm
1328-
export module foo:layer2;
1329-
import :layer1;
1330-
export void layer2_fun() {
1331-
Banana *b = new Banana();
1332-
b->eval();
1333-
}
1334-
void Banana::eval() {
1335-
}
1336-
1337-
For the above example, we can't find the definition for the vtable of
1338-
class ``Banana`` in any object files.
1339-
1340-
The expected behavior is, for dynamic classes attached to named modules,
1341-
the vtable should always be emitted to the module units the class attaches
1342-
to.
1343-
1344-
To workaround the problem, users can add the key function manually in the
1345-
corresponding module units. e.g.,
1346-
1347-
.. code-block:: c++
1348-
1349-
// layer1.cppm
1350-
export module foo:layer1;
1351-
struct Fruit {
1352-
virtual ~Fruit() = default;
1353-
virtual void eval() = 0;
1354-
};
1355-
struct Banana : public Fruit {
1356-
// Hack a key function to hint the compiler to emit the virtual table.
1357-
virtual void anchor();
1358-
1359-
Banana() {}
1360-
void eval() override;
1361-
};
1362-
1363-
void Banana::anchor() {}
1364-
1365-
This is tracked by
1366-
`#70585 <https://github.com/llvm/llvm-project/issues/70585>`_.
1367-
13681300
Including headers after import is not well-supported
13691301
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13701302

@@ -1436,7 +1368,7 @@ non-module unit depending on the definition of some macros. However, this usage
14361368
is forbidden by P1857R3 which is not yet implemented in Clang. This means that
14371369
is possible to write invalid modules which will no longer be accepted once
14381370
P1857R3 is implemented. This is tracked by
1439-
`#56917 <https://github.com/llvm/llvm-project/issues/56917>`_.
1371+
`#54047 <https://github.com/llvm/llvm-project/issues/54047>`_.
14401372

14411373
Until then, it is recommended not to mix macros with module declarations.
14421374

clang/include/clang/Basic/Attr.td

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,6 +2200,15 @@ def BTFTypeTag : TypeAttr {
22002200
let LangOpts = [COnly];
22012201
}
22022202

2203+
def BPFFastCall : InheritableAttr,
2204+
TargetSpecificAttr<TargetBPF> {
2205+
let Spellings = [Clang<"bpf_fastcall">];
2206+
let Subjects = SubjectList<[FunctionLike]>;
2207+
let Documentation = [BPFFastCallDocs];
2208+
let LangOpts = [COnly];
2209+
let SimpleHandler = 1;
2210+
}
2211+
22032212
def WebAssemblyExportName : InheritableAttr,
22042213
TargetSpecificAttr<TargetWebAssembly> {
22052214
let Spellings = [Clang<"export_name">];

clang/include/clang/Basic/AttrDocs.td

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2345,6 +2345,25 @@ section.
23452345
}];
23462346
}
23472347

2348+
def BPFFastCallDocs : Documentation {
2349+
let Category = DocCatType;
2350+
let Content = [{
2351+
Functions annotated with this attribute are likely to be inlined by BPF JIT.
2352+
It is assumed that inlined implementation uses less caller saved registers,
2353+
than a regular function.
2354+
Specifically, the following registers are likely to be preserved:
2355+
- ``R0`` if function return value is ``void``;
2356+
- ``R2-R5` if function takes 1 argument;
2357+
- ``R3-R5` if function takes 2 arguments;
2358+
- ``R4-R5` if function takes 3 arguments;
2359+
- ``R5`` if function takes 4 arguments;
2360+
2361+
For such functions Clang generates code pattern that allows BPF JIT
2362+
to recognize and remove unnecessary spills and fills of the preserved
2363+
registers.
2364+
}];
2365+
}
2366+
23482367
def MipsInterruptDocs : Documentation {
23492368
let Category = DocCatFunction;
23502369
let Heading = "interrupt (MIPS)";

clang/include/clang/Driver/Options.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6155,6 +6155,10 @@ def mv8plus : Flag<["-"], "mv8plus">, Group<m_sparc_Features_Group>,
61556155
HelpText<"Enable V8+ mode, allowing use of 64-bit V9 instructions in 32-bit code">;
61566156
def mno_v8plus : Flag<["-"], "mno-v8plus">, Group<m_sparc_Features_Group>,
61576157
HelpText<"Disable V8+ mode">;
6158+
def mfix_gr712rc : Flag<["-"], "mfix-gr712rc">, Group<m_sparc_Features_Group>,
6159+
HelpText<"Enable workarounds for GR712RC errata">;
6160+
def mfix_ut700 : Flag<["-"], "mfix-ut700">, Group<m_sparc_Features_Group>,
6161+
HelpText<"Enable workarounds for UT700 errata">;
61586162
foreach i = 1 ... 7 in
61596163
def ffixed_g#i : Flag<["-"], "ffixed-g"#i>, Group<m_sparc_Features_Group>,
61606164
HelpText<"Reserve the G"#i#" register (SPARC only)">;

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,15 +1318,6 @@ bool Compiler<Emitter>::VisitArraySubscriptExpr(const ArraySubscriptExpr *E) {
13181318
template <class Emitter>
13191319
bool Compiler<Emitter>::visitInitList(ArrayRef<const Expr *> Inits,
13201320
const Expr *ArrayFiller, const Expr *E) {
1321-
1322-
QualType QT = E->getType();
1323-
1324-
if (const auto *AT = QT->getAs<AtomicType>())
1325-
QT = AT->getValueType();
1326-
1327-
if (QT->isVoidType())
1328-
return this->emitInvalid(E);
1329-
13301321
// Handle discarding first.
13311322
if (DiscardResult) {
13321323
for (const Expr *Init : Inits) {
@@ -1336,6 +1327,13 @@ bool Compiler<Emitter>::visitInitList(ArrayRef<const Expr *> Inits,
13361327
return true;
13371328
}
13381329

1330+
QualType QT = E->getType();
1331+
if (const auto *AT = QT->getAs<AtomicType>())
1332+
QT = AT->getValueType();
1333+
1334+
if (QT->isVoidType())
1335+
return this->emitInvalid(E);
1336+
13391337
// Primitive values.
13401338
if (std::optional<PrimType> T = classify(QT)) {
13411339
assert(!DiscardResult);
@@ -3251,12 +3249,9 @@ template <class Emitter> bool Compiler<Emitter>::visit(const Expr *E) {
32513249
if (E->getType().isNull())
32523250
return false;
32533251

3254-
if (E->getType()->isVoidType())
3255-
return this->discard(E);
3256-
32573252
// Create local variable to hold the return value.
3258-
if (!E->isGLValue() && !E->getType()->isAnyComplexType() &&
3259-
!classify(E->getType())) {
3253+
if (!E->getType()->isVoidType() && !E->isGLValue() &&
3254+
!E->getType()->isAnyComplexType() && !classify(E->getType())) {
32603255
std::optional<unsigned> LocalIndex = allocateLocal(E);
32613256
if (!LocalIndex)
32623257
return false;
@@ -5150,7 +5145,7 @@ bool Compiler<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
51505145
// We should already have a pointer when we get here.
51515146
return this->delegate(SubExpr);
51525147
case UO_Deref: // *x
5153-
if (DiscardResult)
5148+
if (DiscardResult || E->getType()->isVoidType())
51545149
return this->discard(SubExpr);
51555150
return this->visit(SubExpr);
51565151
case UO_Not: // ~x

clang/lib/CodeGen/CGCall.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2421,6 +2421,8 @@ void CodeGenModule::ConstructAttributeList(StringRef Name,
24212421
FuncAttrs.addAttribute(llvm::Attribute::NoCfCheck);
24222422
if (TargetDecl->hasAttr<LeafAttr>())
24232423
FuncAttrs.addAttribute(llvm::Attribute::NoCallback);
2424+
if (TargetDecl->hasAttr<BPFFastCallAttr>())
2425+
FuncAttrs.addAttribute("bpf_fastcall");
24242426

24252427
HasOptnone = TargetDecl->hasAttr<OptimizeNoneAttr>();
24262428
if (auto *AllocSize = TargetDecl->getAttr<AllocSizeAttr>()) {

clang/lib/CodeGen/CodeGenPGO.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,10 +1195,15 @@ void CodeGenPGO::emitCounterSetOrIncrement(CGBuilderTy &Builder, const Stmt *S,
11951195

11961196
unsigned Counter = (*RegionCounterMap)[S];
11971197

1198-
llvm::Value *Args[] = {FuncNameVar,
1199-
Builder.getInt64(FunctionHash),
1200-
Builder.getInt32(NumRegionCounters),
1201-
Builder.getInt32(Counter), StepV};
1198+
// Make sure that pointer to global is passed in with zero addrspace
1199+
// This is relevant during GPU profiling
1200+
auto *NormalizedFuncNameVarPtr =
1201+
llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(
1202+
FuncNameVar, llvm::PointerType::get(CGM.getLLVMContext(), 0));
1203+
1204+
llvm::Value *Args[] = {
1205+
NormalizedFuncNameVarPtr, Builder.getInt64(FunctionHash),
1206+
Builder.getInt32(NumRegionCounters), Builder.getInt32(Counter), StepV};
12021207

12031208
if (llvm::EnableSingleByteCoverage)
12041209
Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::instrprof_cover),

clang/lib/Driver/ToolChains/Arch/Sparc.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,4 +264,17 @@ void sparc::getSparcTargetFeatures(const Driver &D, const ArgList &Args,
264264

265265
if (Args.hasArg(options::OPT_ffixed_i5))
266266
Features.push_back("+reserve-i5");
267+
268+
if (Args.hasArg(options::OPT_mfix_gr712rc)) {
269+
Features.push_back("+fix-tn0009");
270+
Features.push_back("+fix-tn0011");
271+
Features.push_back("+fix-tn0012");
272+
Features.push_back("+fix-tn0013");
273+
}
274+
275+
if (Args.hasArg(options::OPT_mfix_ut700)) {
276+
Features.push_back("+fix-tn0009");
277+
Features.push_back("+fix-tn0010");
278+
Features.push_back("+fix-tn0013");
279+
}
267280
}

0 commit comments

Comments
 (0)