Skip to content

Commit 32ef39e

Browse files
committed
Merge from 'main' to 'sycl-web' (5 commits)
CONFLICT (content): Merge conflict in llvm/lib/CodeGen/AtomicExpandPass.cpp CONFLICT (content): Merge conflict in llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
2 parents 1fa5e00 + ff108f7 commit 32ef39e

File tree

13 files changed

+96
-47
lines changed

13 files changed

+96
-47
lines changed

clang/lib/Sema/SemaFunctionEffects.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,6 +1302,14 @@ class Analyzer {
13021302
return true;
13031303
}
13041304

1305+
bool TraverseCXXRecordDecl(CXXRecordDecl *D) override {
1306+
// Completely skip local struct/class/union declarations since their
1307+
// methods would otherwise be incorrectly interpreted as part of the
1308+
// function we are currently traversing. The initial Sema pass will have
1309+
// already recorded any nonblocking methods needing analysis.
1310+
return true;
1311+
}
1312+
13051313
bool TraverseConstructorInitializer(CXXCtorInitializer *Init) override {
13061314
ViolationSite PrevVS = VSite;
13071315
if (Init->isAnyMemberInitializer())

clang/test/Sema/attr-nonblocking-constraints.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,25 @@ void nb8c()
104104
};
105105
}
106106

107+
void nb8d() [[clang::nonblocking]]
108+
{
109+
// Blocking methods of a local CXXRecordDecl do not generate diagnostics
110+
// for the outer function.
111+
struct F1 {
112+
void method() { void* ptr = new int; }
113+
};
114+
115+
// Skipping the CXXRecordDecl does not skip a following VarDecl.
116+
struct F2 {
117+
F2() { void* ptr = new int; } // expected-note {{constructor cannot be inferred 'nonblocking' because it allocates or deallocates memory}}
118+
} f2; // expected-warning {{function with 'nonblocking' attribute must not call non-'nonblocking' constructor 'nb8d()::F2::F2'}}
119+
120+
// Nonblocking methods of a local CXXRecordDecl are verified independently.
121+
struct F3 {
122+
void method() [[clang::nonblocking]] { void* ptr = new int; }// expected-warning {{function with 'nonblocking' attribute must not allocate or deallocate memory}}
123+
};
124+
}
125+
107126
// Make sure template expansions are found and verified.
108127
template <typename T>
109128
struct Adder {

llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ struct DEMANGLE_ABI SpecialTableSymbolNode : public SymbolNode {
708708
return N->kind() == NodeKind::SpecialTableSymbol;
709709
}
710710

711-
QualifiedNameNode *TargetName = nullptr;
711+
NodeArrayNode *TargetNames = nullptr;
712712
Qualifiers Quals = Qualifiers::Q_None;
713713
};
714714

llvm/lib/CodeGen/AtomicExpandPass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,7 @@ Value *AtomicExpandImpl::insertRMWLLSCLoop(
13011301
// Atomic RMW expands to a Load-linked / Store-Conditional loop, because it is
13021302
// hard to predict precise branch weigths we mark the branch as "unknown"
13031303
// (50/50) to prevent misleading optimizations.
1304-
setExplicitlyUnknownBranchWeightsIfProfiled(*CondBr, DEBUG_TYPE, F);
1304+
setExplicitlyUnknownBranchWeightsIfProfiled(*CondBr, DEBUG_TYPE);
13051305

13061306
Builder.SetInsertPoint(ExitBB, ExitBB->begin());
13071307
return Loaded;

llvm/lib/Demangle/MicrosoftDemangle.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
#include "llvm/Demangle/MicrosoftDemangle.h"
1717

18+
#include "llvm/ADT/ArrayRef.h"
19+
#include "llvm/ADT/SmallVector.h"
1820
#include "llvm/Demangle/Demangle.h"
1921
#include "llvm/Demangle/DemangleConfig.h"
2022
#include "llvm/Demangle/MicrosoftDemangleNodes.h"
@@ -277,6 +279,15 @@ demanglePointerCVQualifiers(std::string_view &MangledName) {
277279
DEMANGLE_UNREACHABLE;
278280
}
279281

282+
static NodeArrayNode *smallVecToNodeArray(ArenaAllocator &Arena,
283+
ArrayRef<Node *> Vec) {
284+
NodeArrayNode *Arr = Arena.alloc<NodeArrayNode>();
285+
Arr->Count = Vec.size();
286+
Arr->Nodes = Arena.allocArray<Node *>(Vec.size());
287+
std::memcpy(Arr->Nodes, Vec.data(), Vec.size() * sizeof(Node *));
288+
return Arr;
289+
}
290+
280291
std::string_view Demangler::copyString(std::string_view Borrowed) {
281292
char *Stable = Arena.allocUnalignedBuffer(Borrowed.size());
282293
// This is not a micro-optimization, it avoids UB, should Borrowed be an null
@@ -323,8 +334,19 @@ Demangler::demangleSpecialTableSymbolNode(std::string_view &MangledName,
323334
}
324335

325336
std::tie(STSN->Quals, IsMember) = demangleQualifiers(MangledName);
326-
if (!consumeFront(MangledName, '@'))
327-
STSN->TargetName = demangleFullyQualifiedTypeName(MangledName);
337+
338+
SmallVector<Node *, 1> TargetNames;
339+
while (!consumeFront(MangledName, '@')) {
340+
QualifiedNameNode *QN = demangleFullyQualifiedTypeName(MangledName);
341+
if (Error)
342+
return nullptr;
343+
assert(QN);
344+
TargetNames.push_back(QN);
345+
}
346+
347+
if (!TargetNames.empty())
348+
STSN->TargetNames = smallVecToNodeArray(Arena, TargetNames);
349+
328350
return STSN;
329351
}
330352

llvm/lib/Demangle/MicrosoftDemangleNodes.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,9 +662,9 @@ void VcallThunkIdentifierNode::output(OutputBuffer &OB,
662662
void SpecialTableSymbolNode::output(OutputBuffer &OB, OutputFlags Flags) const {
663663
outputQualifiers(OB, Quals, false, true);
664664
Name->output(OB, Flags);
665-
if (TargetName) {
665+
if (TargetNames) {
666666
OB << "{for `";
667-
TargetName->output(OB, Flags);
667+
TargetNames->output(OB, Flags, "'s `");
668668
OB << "'}";
669669
}
670670
}

llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,7 @@ static void buildPartialInvariantUnswitchConditionalBranch(
388388
IRB.CreateCondBr(Cond, Direction ? &UnswitchedSucc : &NormalSucc,
389389
Direction ? &NormalSucc : &UnswitchedSucc, ProfData);
390390
if (!ProfData)
391-
setExplicitlyUnknownBranchWeightsIfProfiled(*BR, DEBUG_TYPE,
392-
BR->getFunction());
391+
setExplicitlyUnknownBranchWeightsIfProfiled(*BR, DEBUG_TYPE);
393392
}
394393

395394
/// Rewrite the PHI nodes in an unswitched loop exit basic block.
@@ -3203,8 +3202,7 @@ injectPendingInvariantConditions(NonTrivialUnswitchCandidate Candidate, Loop &L,
32033202
auto *InvariantBr =
32043203
Builder.CreateCondBr(InjectedCond, InLoopSucc, CheckBlock);
32053204
// We don't know anything about the relation between the limits.
3206-
setExplicitlyUnknownBranchWeightsIfProfiled(
3207-
*InvariantBr, DEBUG_TYPE, InvariantBr->getParent()->getParent());
3205+
setExplicitlyUnknownBranchWeightsIfProfiled(*InvariantBr, DEBUG_TYPE);
32083206

32093207
Builder.SetInsertPoint(CheckBlock);
32103208
Builder.CreateCondBr(

llvm/test/Demangle/ms-operators.test

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,24 @@
143143
??_7A@B@@6BC@D@@@
144144
; CHECK: const B::A::`vftable'{for `D::C'}
145145

146+
??_7A@B@@6BC@D@@E@F@@@
147+
; CHECK: const B::A::`vftable'{for `D::C's `F::E'}
148+
149+
??_7A@B@@6BC@D@@E@F@@G@H@@@
150+
; CHECK: const B::A::`vftable'{for `D::C's `F::E's `H::G'}
151+
146152
??_8Middle2@@7B@
147153
; CHECK: const Middle2::`vbtable'
148154

155+
??_7A@@6BB@@@
156+
; CHECK: const A::`vftable'{for `B'}
157+
158+
??_7A@@6BB@@C@@@
159+
; CHECK: const A::`vftable'{for `B's `C'}
160+
161+
??_7A@@6BB@@C@@D@@@
162+
; CHECK: const A::`vftable'{for `B's `C's `D'}
163+
149164
??_9Base@@$B7AA
150165
; CHECK: [thunk]: __cdecl Base::`vcall'{8, {flat}}
151166

llvm/test/TableGen/directive1.td

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ def TDL_DirA : Directive<[Spelling<"dira">]> {
186186
// IMPL: #ifdef GEN_FLANG_DIRECTIVE_CLAUSE_SETS
187187
// IMPL-NEXT: #undef GEN_FLANG_DIRECTIVE_CLAUSE_SETS
188188
// IMPL-EMPTY:
189-
// IMPL-NEXT: namespace llvm {
190-
// IMPL-NEXT: namespace tdl {
189+
// IMPL-NEXT: namespace llvm::tdl {
191190
// IMPL-EMPTY:
192191
// IMPL-NEXT: // Sets for dira
193192
// IMPL-EMPTY:
@@ -204,8 +203,8 @@ def TDL_DirA : Directive<[Spelling<"dira">]> {
204203
// IMPL-EMPTY:
205204
// IMPL-NEXT: static requiredClauses_TDLD_dira {
206205
// IMPL-NEXT: };
207-
// IMPL-NEXT: } // namespace tdl
208-
// IMPL-NEXT: } // namespace llvm
206+
// IMPL-EMPTY:
207+
// IMPL-NEXT: } // namespace llvm::tdl
209208
// IMPL-EMPTY:
210209
// IMPL-NEXT: #endif // GEN_FLANG_DIRECTIVE_CLAUSE_SETS
211210
// IMPL-EMPTY:

llvm/test/TableGen/directive2.td

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ def TDL_DirA : Directive<[Spelling<"dira">]> {
159159
// IMPL: #ifdef GEN_FLANG_DIRECTIVE_CLAUSE_SETS
160160
// IMPL-NEXT: #undef GEN_FLANG_DIRECTIVE_CLAUSE_SETS
161161
// IMPL-EMPTY:
162-
// IMPL-NEXT: namespace llvm {
163-
// IMPL-NEXT: namespace tdl {
162+
// IMPL-NEXT: namespace llvm::tdl {
164163
// IMPL-EMPTY:
165164
// IMPL-NEXT: // Sets for dira
166165
// IMPL-EMPTY:
@@ -177,8 +176,8 @@ def TDL_DirA : Directive<[Spelling<"dira">]> {
177176
// IMPL-EMPTY:
178177
// IMPL-NEXT: static requiredClauses_TDLD_dira {
179178
// IMPL-NEXT: };
180-
// IMPL-NEXT: } // namespace tdl
181-
// IMPL-NEXT: } // namespace llvm
179+
// IMPL-EMPTY:
180+
// IMPL-NEXT: } // namespace llvm::tdl
182181
// IMPL-EMPTY:
183182
// IMPL-NEXT: #endif // GEN_FLANG_DIRECTIVE_CLAUSE_SETS
184183
// IMPL-EMPTY:

0 commit comments

Comments
 (0)