Skip to content

Commit 348e987

Browse files

Some content is hidden

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

71 files changed

+340
-268
lines changed

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3791,18 +3791,12 @@ static bool isFunctionDeclarationName(const LangOptions &LangOpts,
37913791
if (Current.is(TT_FunctionDeclarationName))
37923792
return true;
37933793

3794-
if (!Current.Tok.getIdentifierInfo())
3794+
if (Current.isNoneOf(tok::identifier, tok::kw_operator))
37953795
return false;
37963796

37973797
const auto *Prev = Current.getPreviousNonComment();
37983798
assert(Prev);
37993799

3800-
if (Prev->is(tok::coloncolon))
3801-
Prev = Prev->Previous;
3802-
3803-
if (!Prev)
3804-
return false;
3805-
38063800
const auto &Previous = *Prev;
38073801

38083802
if (const auto *PrevPrev = Previous.getPreviousNonComment();
@@ -3851,6 +3845,8 @@ static bool isFunctionDeclarationName(const LangOptions &LangOpts,
38513845

38523846
// Find parentheses of parameter list.
38533847
if (Current.is(tok::kw_operator)) {
3848+
if (Line.startsWith(tok::kw_friend))
3849+
return true;
38543850
if (Previous.Tok.getIdentifierInfo() &&
38553851
Previous.isNoneOf(tok::kw_return, tok::kw_co_return)) {
38563852
return true;

clang/unittests/Format/TokenAnnotatorTest.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,11 @@ TEST_F(TokenAnnotatorTest, UnderstandsOverloadedOperators) {
11291129
ASSERT_EQ(Tokens.size(), 7u) << Tokens;
11301130
// Not TT_FunctionDeclarationName.
11311131
EXPECT_TOKEN(Tokens[3], tok::kw_operator, TT_Unknown);
1132+
1133+
Tokens = annotate("SomeAPI::operator()();");
1134+
ASSERT_EQ(Tokens.size(), 9u) << Tokens;
1135+
// Not TT_FunctionDeclarationName.
1136+
EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_Unknown);
11321137
}
11331138

11341139
TEST_F(TokenAnnotatorTest, OverloadedOperatorInTemplate) {

libc/include/llvm-libc-macros/gpu/signal-macros.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,19 @@
99
#ifndef LLVM_LIBC_MACROS_GPU_SIGNAL_MACROS_H
1010
#define LLVM_LIBC_MACROS_GPU_SIGNAL_MACROS_H
1111

12+
#include "__llvm-libc-common.h"
13+
1214
#define SIGINT 2
1315
#define SIGILL 4
1416
#define SIGABRT 6
1517
#define SIGFPE 8
1618
#define SIGSEGV 11
1719
#define SIGTERM 15
1820

19-
#define SIG_DFL ((void (*)(int))(0))
20-
#define SIG_IGN ((void (*)(int))(1))
21-
#define SIG_ERR ((void (*)(int))(-1))
21+
#define SIG_ERR __LLVM_LIBC_CAST(reinterpret_cast, void (*)(int), -1)
22+
#define SIG_DFL __LLVM_LIBC_CAST(reinterpret_cast, void (*)(int), 0)
23+
#define SIG_IGN __LLVM_LIBC_CAST(reinterpret_cast, void (*)(int), 1)
24+
#define SIG_HOLD __LLVM_LIBC_CAST(reinterpret_cast, void (*)(int), 2)
2225

2326
// Max signal number
2427
#define NSIG 64

libc/include/llvm-libc-macros/linux/signal-macros.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#ifndef LLVM_LIBC_MACROS_LINUX_SIGNAL_MACROS_H
1010
#define LLVM_LIBC_MACROS_LINUX_SIGNAL_MACROS_H
1111

12+
#include "__llvm-libc-common.h"
13+
1214
#define SIGHUP 1
1315
#define SIGINT 2
1416
#define SIGQUIT 3
@@ -86,9 +88,10 @@
8688
#error "Signal stack sizes not defined for your platform."
8789
#endif
8890

89-
#define SIG_DFL ((void (*)(int))0)
90-
#define SIG_IGN ((void (*)(int))1)
91-
#define SIG_ERR ((void (*)(int))(-1))
91+
#define SIG_ERR __LLVM_LIBC_CAST(reinterpret_cast, void (*)(int), -1)
92+
#define SIG_DFL __LLVM_LIBC_CAST(reinterpret_cast, void (*)(int), 0)
93+
#define SIG_IGN __LLVM_LIBC_CAST(reinterpret_cast, void (*)(int), 1)
94+
#define SIG_HOLD __LLVM_LIBC_CAST(reinterpret_cast, void (*)(int), 2)
9295

9396
// SIGCHLD si_codes
9497
#define CLD_EXITED 1 // child has exited

llvm/include/llvm/CodeGen/Passes.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -610,14 +610,6 @@ LLVM_ABI ModulePass *createCheckDebugMachineModulePass();
610610
/// caller saved registers with stack slots.
611611
LLVM_ABI extern char &FixupStatepointCallerSavedID;
612612

613-
/// The pass transforms load/store <256 x i32> to AMX load/store intrinsics
614-
/// or split the data to two <128 x i32>.
615-
LLVM_ABI FunctionPass *createX86LowerAMXTypePass();
616-
617-
/// The pass transforms amx intrinsics to scalar operation if the function has
618-
/// optnone attribute or it is O0.
619-
LLVM_ABI FunctionPass *createX86LowerAMXIntrinsicsPass();
620-
621613
/// When learning an eviction policy, extract score(reward) information,
622614
/// otherwise this does nothing
623615
LLVM_ABI FunctionPass *createRegAllocScoringPass();

llvm/include/llvm/Support/SpecialCaseList.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
#define LLVM_SUPPORT_SPECIALCASELIST_H
1414

1515
#include "llvm/ADT/ArrayRef.h"
16+
#include "llvm/ADT/RadixTree.h"
17+
#include "llvm/ADT/SmallVector.h"
1618
#include "llvm/ADT/StringMap.h"
19+
#include "llvm/ADT/iterator_range.h"
1720
#include "llvm/Support/Allocator.h"
1821
#include "llvm/Support/Compiler.h"
1922
#include "llvm/Support/GlobPattern.h"
@@ -162,6 +165,10 @@ class SpecialCaseList {
162165
};
163166

164167
std::vector<GlobMatcher::Glob> Globs;
168+
169+
RadixTree<iterator_range<StringRef::const_iterator>,
170+
SmallVector<const GlobMatcher::Glob *, 1>>
171+
PrefixToGlob;
165172
};
166173

167174
/// Represents a set of patterns and their line numbers

llvm/lib/CodeGen/CodeGenPrepare.cpp

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4076,16 +4076,13 @@ bool PhiNodeSetIterator::operator!=(const PhiNodeSetIterator &RHS) const {
40764076
/// if it is simplified.
40774077
class SimplificationTracker {
40784078
DenseMap<Value *, Value *> Storage;
4079-
const SimplifyQuery &SQ;
40804079
// Tracks newly created Phi nodes. The elements are iterated by insertion
40814080
// order.
40824081
PhiNodeSet AllPhiNodes;
40834082
// Tracks newly created Select nodes.
40844083
SmallPtrSet<SelectInst *, 32> AllSelectNodes;
40854084

40864085
public:
4087-
SimplificationTracker(const SimplifyQuery &sq) : SQ(sq) {}
4088-
40894086
Value *Get(Value *V) {
40904087
do {
40914088
auto SV = Storage.find(V);
@@ -4095,30 +4092,6 @@ class SimplificationTracker {
40954092
} while (true);
40964093
}
40974094

4098-
Value *Simplify(Value *Val) {
4099-
SmallVector<Value *, 32> WorkList;
4100-
SmallPtrSet<Value *, 32> Visited;
4101-
WorkList.push_back(Val);
4102-
while (!WorkList.empty()) {
4103-
auto *P = WorkList.pop_back_val();
4104-
if (!Visited.insert(P).second)
4105-
continue;
4106-
if (auto *PI = dyn_cast<Instruction>(P))
4107-
if (Value *V = simplifyInstruction(cast<Instruction>(PI), SQ)) {
4108-
for (auto *U : PI->users())
4109-
WorkList.push_back(cast<Value>(U));
4110-
Put(PI, V);
4111-
PI->replaceAllUsesWith(V);
4112-
if (auto *PHI = dyn_cast<PHINode>(PI))
4113-
AllPhiNodes.erase(PHI);
4114-
if (auto *Select = dyn_cast<SelectInst>(PI))
4115-
AllSelectNodes.erase(Select);
4116-
PI->eraseFromParent();
4117-
}
4118-
}
4119-
return Get(Val);
4120-
}
4121-
41224095
void Put(Value *From, Value *To) { Storage.insert({From, To}); }
41234096

41244097
void ReplacePhi(PHINode *From, PHINode *To) {
@@ -4179,8 +4152,7 @@ class AddressingModeCombiner {
41794152
/// Common Type for all different fields in addressing modes.
41804153
Type *CommonType = nullptr;
41814154

4182-
/// SimplifyQuery for simplifyInstruction utility.
4183-
const SimplifyQuery &SQ;
4155+
const DataLayout &DL;
41844156

41854157
/// Original Address.
41864158
Value *Original;
@@ -4189,8 +4161,8 @@ class AddressingModeCombiner {
41894161
Value *CommonValue = nullptr;
41904162

41914163
public:
4192-
AddressingModeCombiner(const SimplifyQuery &_SQ, Value *OriginalValue)
4193-
: SQ(_SQ), Original(OriginalValue) {}
4164+
AddressingModeCombiner(const DataLayout &DL, Value *OriginalValue)
4165+
: DL(DL), Original(OriginalValue) {}
41944166

41954167
~AddressingModeCombiner() { eraseCommonValueIfDead(); }
41964168

@@ -4302,7 +4274,7 @@ class AddressingModeCombiner {
43024274
// Keep track of keys where the value is null. We will need to replace it
43034275
// with constant null when we know the common type.
43044276
SmallVector<Value *, 2> NullValue;
4305-
Type *IntPtrTy = SQ.DL.getIntPtrType(AddrModes[0].OriginalValue->getType());
4277+
Type *IntPtrTy = DL.getIntPtrType(AddrModes[0].OriginalValue->getType());
43064278
for (auto &AM : AddrModes) {
43074279
Value *DV = AM.GetFieldAsValue(DifferentField, IntPtrTy);
43084280
if (DV) {
@@ -4352,7 +4324,7 @@ class AddressingModeCombiner {
43524324
// simplification is possible only if original phi/selects were not
43534325
// simplified yet.
43544326
// Using this mapping we can find the current value in AddrToBase.
4355-
SimplificationTracker ST(SQ);
4327+
SimplificationTracker ST;
43564328

43574329
// First step, DFS to create PHI nodes for all intermediate blocks.
43584330
// Also fill traverse order for the second step.
@@ -4511,7 +4483,6 @@ class AddressingModeCombiner {
45114483
PHI->addIncoming(ST.Get(Map[PV]), B);
45124484
}
45134485
}
4514-
Map[Current] = ST.Simplify(V);
45154486
}
45164487
}
45174488

@@ -5902,8 +5873,7 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
59025873
// the graph are compatible.
59035874
bool PhiOrSelectSeen = false;
59045875
SmallVector<Instruction *, 16> AddrModeInsts;
5905-
const SimplifyQuery SQ(*DL, TLInfo);
5906-
AddressingModeCombiner AddrModes(SQ, Addr);
5876+
AddressingModeCombiner AddrModes(*DL, Addr);
59075877
TypePromotionTransaction TPT(RemovedInsts);
59085878
TypePromotionTransaction::ConstRestorationPt LastKnownGood =
59095879
TPT.getRestorationPoint();

llvm/lib/Support/SpecialCaseList.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,32 @@ void SpecialCaseList::GlobMatcher::preprocess(bool BySize) {
8989
return A.Name.size() < B.Name.size();
9090
});
9191
}
92+
93+
for (const auto &G : reverse(Globs)) {
94+
StringRef Prefix = G.Pattern.prefix();
95+
96+
auto &V = PrefixToGlob.emplace(Prefix).first->second;
97+
V.emplace_back(&G);
98+
}
9299
}
93100

94101
void SpecialCaseList::GlobMatcher::match(
95102
StringRef Query,
96103
llvm::function_ref<void(StringRef Rule, unsigned LineNo)> Cb) const {
97-
for (const auto &G : reverse(Globs))
98-
if (G.Pattern.match(Query))
99-
return Cb(G.Name, G.LineNo);
104+
if (!PrefixToGlob.empty()) {
105+
for (const auto &[_, V] : PrefixToGlob.find_prefixes(Query)) {
106+
for (const auto *G : V) {
107+
if (G->Pattern.match(Query)) {
108+
Cb(G->Name, G->LineNo);
109+
// As soon as we find a match in the vector, we can break for this
110+
// vector, since the globs are already sorted by priority within the
111+
// prefix group. However, we continue searching other prefix groups in
112+
// the map, as they may contain a better match overall.
113+
break;
114+
}
115+
}
116+
}
117+
}
100118
}
101119

102120
SpecialCaseList::Matcher::Matcher(bool UseGlobs, bool RemoveDotSlash)

llvm/lib/Target/AArch64/AArch64InstrInfo.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5151,7 +5151,15 @@ void AArch64InstrInfo::copyPhysReg(MachineBasicBlock &MBB,
51515151

51525152
// GPR32 zeroing
51535153
if (AArch64::GPR32spRegClass.contains(DestReg) && SrcReg == AArch64::WZR) {
5154-
if (Subtarget.hasZeroCycleZeroingGPR32()) {
5154+
if (Subtarget.hasZeroCycleZeroingGPR64() &&
5155+
!Subtarget.hasZeroCycleZeroingGPR32()) {
5156+
MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5157+
&AArch64::GPR64spRegClass);
5158+
assert(DestRegX.isValid() && "Destination super-reg not valid");
5159+
BuildMI(MBB, I, DL, get(AArch64::MOVZXi), DestRegX)
5160+
.addImm(0)
5161+
.addImm(AArch64_AM::getShifterImm(AArch64_AM::LSL, 0));
5162+
} else if (Subtarget.hasZeroCycleZeroingGPR32()) {
51555163
BuildMI(MBB, I, DL, get(AArch64::MOVZWi), DestReg)
51565164
.addImm(0)
51575165
.addImm(AArch64_AM::getShifterImm(AArch64_AM::LSL, 0));

llvm/lib/Target/X86/X86.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,14 @@ FunctionPass *createX86PartialReductionPass();
160160
/// // Analyzes and emits pseudos to support Win x64 Unwind V2.
161161
FunctionPass *createX86WinEHUnwindV2Pass();
162162

163+
/// The pass transforms load/store <256 x i32> to AMX load/store intrinsics
164+
/// or split the data to two <128 x i32>.
165+
FunctionPass *createX86LowerAMXTypePass();
166+
167+
/// The pass transforms amx intrinsics to scalar operation if the function has
168+
/// optnone attribute or it is O0.
169+
FunctionPass *createX86LowerAMXIntrinsicsPass();
170+
163171
InstructionSelector *createX86InstructionSelector(const X86TargetMachine &TM,
164172
const X86Subtarget &,
165173
const X86RegisterBankInfo &);

0 commit comments

Comments
 (0)