Skip to content

Commit 28bd166

Browse files
authored
merge main into amd-staging (#658)
2 parents 43c0d1c + 744a94f commit 28bd166

File tree

69 files changed

+6235
-5939
lines changed

Some content is hidden

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

69 files changed

+6235
-5939
lines changed

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3129,8 +3129,11 @@ class AnnotatingParser {
31293129

31303130
// It is very unlikely that we are going to find a pointer or reference type
31313131
// definition on the RHS of an assignment.
3132-
if (IsExpression && !Contexts.back().CaretFound)
3132+
if (IsExpression && !Contexts.back().CaretFound &&
3133+
Line.getFirstNonComment()->isNot(
3134+
TT_RequiresClauseInARequiresExpression)) {
31333135
return TT_BinaryOperator;
3136+
}
31343137

31353138
// Opeartors at class scope are likely pointer or reference members.
31363139
if (!Scopes.empty() && Scopes.back() == ST_Class)

clang/lib/StaticAnalyzer/Core/BugSuppression.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,12 @@ class CacheInitializer : public DynamicRecursiveASTVisitor {
117117
}
118118
}
119119

120-
CacheInitializer(Ranges &R) : Result(R) {}
120+
CacheInitializer(Ranges &R) : Result(R) {
121+
ShouldVisitTemplateInstantiations = true;
122+
ShouldWalkTypesOfTypeLocs = false;
123+
ShouldVisitImplicitCode = false;
124+
ShouldVisitLambdaBody = true;
125+
}
121126
Ranges &Result;
122127
};
123128

clang/test/Analysis/suppression-attr.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
1-
// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
1+
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
2+
3+
void clang_analyzer_warnIfReached();
4+
5+
struct Clazz {
6+
template <typename T>
7+
static void templated_memfn();
8+
};
9+
10+
// This must come before the 'templated_memfn' is defined!
11+
static void instantiate() {
12+
Clazz::templated_memfn<int>();
13+
}
14+
15+
template <typename T>
16+
void Clazz::templated_memfn() {
17+
// When we report a bug in a function, we traverse the lexical decl context
18+
// of it while looking for suppression attributes to record what source
19+
// ranges should the suppression apply to.
20+
// In the past, that traversal didn't follow template instantiations, only
21+
// primary templates.
22+
[[clang::suppress]] clang_analyzer_warnIfReached(); // no-warning
23+
24+
}
225

326
namespace [[clang::suppress]]
427
suppressed_namespace {

clang/unittests/Format/TokenAnnotatorTest.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,6 +1391,15 @@ TEST_F(TokenAnnotatorTest, UnderstandsRequiresClausesAndConcepts) {
13911391
ASSERT_EQ(Tokens.size(), 38u) << Tokens;
13921392
EXPECT_TOKEN(Tokens[19], tok::l_brace, TT_RequiresExpressionLBrace);
13931393

1394+
Tokens =
1395+
annotate("template <typename... Ts>\n"
1396+
" requires requires {\n"
1397+
" requires std::same_as<int, SomeTemplate<void(Ts &&...)>>;\n"
1398+
" }\n"
1399+
"void Foo();");
1400+
ASSERT_EQ(Tokens.size(), 34u) << Tokens;
1401+
EXPECT_TOKEN(Tokens[21], tok::ampamp, TT_PointerOrReference);
1402+
13941403
Tokens =
13951404
annotate("template <class A, class B> concept C ="
13961405
"std::same_as<std::iter_value_t<A>, std::iter_value_t<B>>;");

lld/MinGW/Driver.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,8 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
451451
add("-machine:arm64ec");
452452
else if (s == "arm64xpe")
453453
add("-machine:arm64x");
454+
else if (s == "mipspe")
455+
add("-machine:mips");
454456
else
455457
error("unknown parameter: -m" + s);
456458
}

lld/test/MinGW/driver.test

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ ARM64X-SAME: -machine:arm64x
3737
ARM64X-SAME: -alternatename:__image_base__=__ImageBase
3838
ARM64X-SAME: foo.o
3939

40+
RUN: ld.lld -### foo.o -m mipspe 2>&1 | FileCheck -check-prefix=MIPS %s
41+
MIPS: -out:a.exe
42+
MIPS-SAME: -machine:mips
43+
MIPS-SAME: -alternatename:__image_base__=__ImageBase
44+
MIPS-SAME: foo.o
45+
4046
RUN: ld.lld -### foo.o -m i386pep -shared 2>&1 | FileCheck -check-prefix=SHARED %s
4147
RUN: ld.lld -### foo.o -m i386pep --shared 2>&1 | FileCheck -check-prefix=SHARED %s
4248
RUN: ld.lld -### foo.o -m i386pep --dll 2>&1 | FileCheck -check-prefix=SHARED %s

llvm/lib/CodeGen/RegisterCoalescer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4150,7 +4150,7 @@ bool RegisterCoalescer::applyTerminalRule(const MachineInstr &Copy) const {
41504150
continue;
41514151
Register OtherSrcReg, OtherReg;
41524152
unsigned OtherSrcSubReg = 0, OtherSubReg = 0;
4153-
if (!isMoveInstr(*TRI, &MI, OtherSrcReg, OtherReg, OtherSrcSubReg,
4153+
if (!isMoveInstr(*TRI, &Copy, OtherSrcReg, OtherReg, OtherSrcSubReg,
41544154
OtherSubReg))
41554155
return false;
41564156
if (OtherReg == SrcReg)

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8404,7 +8404,7 @@ SDValue RISCVTargetLowering::LowerOperation(SDValue Op,
84048404
if (Store->isTruncatingStore())
84058405
return SDValue();
84068406

8407-
if (!Subtarget.enableUnalignedScalarMem() && Store->getAlign() < 8)
8407+
if (Store->getAlign() < Subtarget.getZilsdAlign())
84088408
return SDValue();
84098409

84108410
SDLoc DL(Op);
@@ -14803,7 +14803,7 @@ void RISCVTargetLowering::ReplaceNodeResults(SDNode *N,
1480314803
assert(Subtarget.hasStdExtZilsd() && !Subtarget.is64Bit() &&
1480414804
"Unexpected custom legalisation");
1480514805

14806-
if (!Subtarget.enableUnalignedScalarMem() && Ld->getAlign() < 8)
14806+
if (Ld->getAlign() < Subtarget.getZilsdAlign())
1480714807
return;
1480814808

1480914809
SDLoc DL(N);

llvm/lib/Target/RISCV/RISCVSubtarget.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,13 @@ class RISCVSubtarget : public RISCVGenSubtargetInfo {
237237

238238
return 0;
239239
}
240+
241+
Align getZilsdAlign() const {
242+
return Align(enableUnalignedScalarMem() ? 1
243+
: allowZilsd4ByteAlign() ? 4
244+
: 8);
245+
}
246+
240247
unsigned getELen() const {
241248
assert(hasVInstructions() && "Expected V extension");
242249
return hasVInstructionsI64() ? 64 : 32;

llvm/lib/Target/RISCV/RISCVZilsdOptimizer.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,7 @@ bool RISCVPreAllocZilsdOpt::runOnMachineFunction(MachineFunction &MF) {
146146

147147
// Check alignment: default is 8-byte, but allow 4-byte with tune feature
148148
// If unaligned scalar memory is enabled, allow any alignment
149-
RequiredAlign = STI->enableUnalignedScalarMem() ? Align(1)
150-
: STI->allowZilsd4ByteAlign() ? Align(4)
151-
: Align(8);
149+
RequiredAlign = STI->getZilsdAlign();
152150
bool Modified = false;
153151
for (auto &MBB : MF) {
154152
Modified |= rescheduleLoadStoreInstrs(&MBB);

0 commit comments

Comments
 (0)