Skip to content

Commit b10fae6

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:134ae13adaff into amd-gfx:456d45aaa291
Local branch amd-gfx 456d45a Merged main:3bb89b6bfbb5 into amd-gfx:40a7b75c817a Remote branch main 134ae13 [compiler-rt] Fix instrprof-darwin-exports test (llvm#67487)
2 parents 456d45a + 134ae13 commit b10fae6

File tree

16 files changed

+4901
-1622
lines changed

16 files changed

+4901
-1622
lines changed

clang/lib/Format/ContinuationIndenter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,7 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState &State) {
13361336
(PreviousNonComment->ClosesTemplateDeclaration ||
13371337
PreviousNonComment->ClosesRequiresClause ||
13381338
PreviousNonComment->isOneOf(
1339-
TT_AttributeParen, TT_AttributeSquare, TT_FunctionAnnotationRParen,
1339+
TT_AttributeRParen, TT_AttributeSquare, TT_FunctionAnnotationRParen,
13401340
TT_JavaAnnotation, TT_LeadingJavaAnnotation))) ||
13411341
(!Style.IndentWrappedFunctionNames &&
13421342
NextNonComment->isOneOf(tok::kw_operator, TT_FunctionDeclarationName))) {

clang/lib/Format/FormatToken.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ namespace format {
3030
TYPE(ArrayInitializerLSquare) \
3131
TYPE(ArraySubscriptLSquare) \
3232
TYPE(AttributeColon) \
33+
TYPE(AttributeLParen) \
3334
TYPE(AttributeMacro) \
34-
TYPE(AttributeParen) \
35+
TYPE(AttributeRParen) \
3536
TYPE(AttributeSquare) \
3637
TYPE(BinaryOperator) \
3738
TYPE(BitFieldColon) \

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ class AnnotatingParser {
377377
// detected one yet.
378378
if (PrevNonComment && OpeningParen.is(TT_Unknown)) {
379379
if (PrevNonComment->is(tok::kw___attribute)) {
380-
OpeningParen.setType(TT_AttributeParen);
380+
OpeningParen.setType(TT_AttributeLParen);
381381
} else if (PrevNonComment->isOneOf(TT_TypenameMacro, tok::kw_decltype,
382382
tok::kw_typeof,
383383
#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) tok::kw___##Trait,
@@ -475,8 +475,8 @@ class AnnotatingParser {
475475
}
476476
}
477477

478-
if (OpeningParen.is(TT_AttributeParen))
479-
CurrentToken->setType(TT_AttributeParen);
478+
if (OpeningParen.is(TT_AttributeLParen))
479+
CurrentToken->setType(TT_AttributeRParen);
480480
if (OpeningParen.is(TT_TypeDeclarationParen))
481481
CurrentToken->setType(TT_TypeDeclarationParen);
482482
if (OpeningParen.Previous &&
@@ -2382,11 +2382,15 @@ class AnnotatingParser {
23822382
// Strip trailing qualifiers such as const or volatile when checking
23832383
// whether the parens could be a cast to a pointer/reference type.
23842384
while (T) {
2385-
if (T->is(TT_AttributeParen)) {
2385+
if (T->is(TT_AttributeRParen)) {
23862386
// Handle `x = (foo *__attribute__((foo)))&v;`:
2387-
if (T->MatchingParen && T->MatchingParen->Previous &&
2388-
T->MatchingParen->Previous->is(tok::kw___attribute)) {
2389-
T = T->MatchingParen->Previous->Previous;
2387+
assert(T->is(tok::r_paren));
2388+
assert(T->MatchingParen);
2389+
assert(T->MatchingParen->is(tok::l_paren));
2390+
assert(T->MatchingParen->is(TT_AttributeLParen));
2391+
if (const auto *Tok = T->MatchingParen->Previous;
2392+
Tok && Tok->is(tok::kw___attribute)) {
2393+
T = Tok->Previous;
23902394
continue;
23912395
}
23922396
} else if (T->is(TT_AttributeSquare)) {
@@ -3993,7 +3997,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
39933997
// after pointer qualifiers.
39943998
if ((Style.SpaceAroundPointerQualifiers == FormatStyle::SAPQ_After ||
39953999
Style.SpaceAroundPointerQualifiers == FormatStyle::SAPQ_Both) &&
3996-
(Left.is(TT_AttributeParen) ||
4000+
(Left.is(TT_AttributeRParen) ||
39974001
Left.canBePointerOrReferenceQualifier())) {
39984002
return true;
39994003
}
@@ -4186,7 +4190,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
41864190
return Style.SpaceBeforeParensOptions.AfterRequiresInExpression ||
41874191
spaceRequiredBeforeParens(Right);
41884192
}
4189-
if ((Left.is(tok::r_paren) && Left.is(TT_AttributeParen)) ||
4193+
if (Left.is(TT_AttributeRParen) ||
41904194
(Left.is(tok::r_square) && Left.is(TT_AttributeSquare))) {
41914195
return true;
41924196
}
@@ -4365,7 +4369,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
43654369
return false;
43664370
}
43674371
// Space in __attribute__((attr)) ::type.
4368-
if (Left.is(TT_AttributeParen) && Right.is(tok::coloncolon))
4372+
if (Left.is(TT_AttributeRParen) && Right.is(tok::coloncolon))
43694373
return true;
43704374

43714375
if (Left.is(tok::kw_operator))
@@ -5194,7 +5198,7 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
51945198
}
51955199

51965200
// Ensure wrapping after __attribute__((XX)) and @interface etc.
5197-
if (Left.is(TT_AttributeParen) && Right.is(TT_ObjCDecl))
5201+
if (Left.is(TT_AttributeRParen) && Right.is(TT_ObjCDecl))
51985202
return true;
51995203

52005204
if (Left.is(TT_LambdaLBrace)) {
@@ -5556,8 +5560,8 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
55565560
!Style.Cpp11BracedListStyle) {
55575561
return false;
55585562
}
5559-
if (Left.is(tok::l_paren) &&
5560-
Left.isOneOf(TT_AttributeParen, TT_TypeDeclarationParen)) {
5563+
if (Left.is(TT_AttributeLParen) ||
5564+
(Left.is(tok::l_paren) && Left.is(TT_TypeDeclarationParen))) {
55615565
return false;
55625566
}
55635567
if (Left.is(tok::l_paren) && Left.Previous &&

clang/unittests/Format/TokenAnnotatorTest.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,6 +2072,15 @@ TEST_F(TokenAnnotatorTest, UnderstandsJavaScript) {
20722072
EXPECT_TOKEN(Tokens[11], tok::r_brace, TT_Unknown);
20732073
}
20742074

2075+
TEST_F(TokenAnnotatorTest, UnderstandsAttributes) {
2076+
auto Tokens = annotate("bool foo __attribute__((unused));");
2077+
ASSERT_EQ(Tokens.size(), 10u) << Tokens;
2078+
EXPECT_TOKEN(Tokens[3], tok::l_paren, TT_AttributeLParen);
2079+
EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_Unknown);
2080+
EXPECT_TOKEN(Tokens[6], tok::r_paren, TT_Unknown);
2081+
EXPECT_TOKEN(Tokens[7], tok::r_paren, TT_AttributeRParen);
2082+
}
2083+
20752084
} // namespace
20762085
} // namespace format
20772086
} // namespace clang

compiler-rt/test/profile/instrprof-darwin-exports.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
//
2323
// RUN: %clang_pgogen -Werror -o %t.default %s
2424
// RUN: nm -jUg %t.default | grep -v __mh_execute_header > %t.default.exports
25-
// RUN: nm -jUg %t > %t.clang.exports
25+
// RUN: nm -jUg %t | grep -v __mh_execute_header > %t.clang.exports
2626
// RUN: diff %t.default.exports %t.clang.exports
2727

2828
// 4) Ditto (3), but for GCOV.

compiler-rt/test/sanitizer_common/TestCases/Linux/internal_symbolizer.cpp

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
// RUN: %clangxx %s -o %t -g && %run %t 2>&1 | FileCheck %s
1+
// FIXME: Remove -hwasan-globals=0 when implemented.
2+
// RUN: %clangxx %s -o %t -g -mllvm -hwasan-globals=0 && %run %t 2>&1 | FileCheck %s
23

34
// REQUIRES: internal_symbolizer
45

56
#include <assert.h>
67
#include <dlfcn.h>
78
#include <link.h>
9+
#include <sanitizer/hwasan_interface.h>
810
#include <sanitizer/msan_interface.h>
911
#include <string.h>
1012

@@ -72,9 +74,12 @@ __attribute__((noinline)) FrameInfo A<0>::RecursiveTemplateFunction(const T &) {
7274
}
7375

7476
__attribute__((no_sanitize_memory)) std::pair<const char *, uint64_t>
75-
GetModuleAndOffset(void *address) {
77+
GetModuleAndOffset(const void *address) {
7678
Dl_info di;
7779
link_map *lm = nullptr;
80+
#if __has_feature(hwaddress_sanitizer)
81+
address = __hwasan_tag_pointer(address, 0);
82+
#endif
7883
assert(
7984
dladdr1(address, &di, reinterpret_cast<void **>(&lm), RTLD_DL_LINKMAP));
8085
return {di.dli_fname, reinterpret_cast<uint64_t>(address) - lm->l_addr};
@@ -98,7 +103,7 @@ void TestInline() {
98103
auto frame = InlineFunction();
99104
fprintf(stderr, "%s: %s\n", __FUNCTION__, Symbolize(frame).c_str());
100105
// CHECK-LABEL: TestInline: InlineFunction()
101-
// CHECK-NEXT: internal_symbolizer.cpp:[[# @LINE - 55]]
106+
// CHECK-NEXT: internal_symbolizer.cpp:[[# @LINE - 58]]
102107
// CHECK-NEXT: TestInline()
103108
// CHECK-NEXT: internal_symbolizer.cpp:[[# @LINE - 5]]
104109
}
@@ -107,14 +112,14 @@ void TestNoInline() {
107112
auto frame = NoInlineFunction();
108113
fprintf(stderr, "%s: %s\n", __FUNCTION__, Symbolize(frame).c_str());
109114
// CHECK-LABEL: TestNoInline: NoInlineFunction()
110-
// CHECK-NEXT: internal_symbolizer.cpp:[[# @LINE - 58]]
115+
// CHECK-NEXT: internal_symbolizer.cpp:[[# @LINE - 61]]
111116
}
112117

113118
void TestLongFunctionNames() {
114119
auto frame = A<10>().RecursiveTemplateFunction(0);
115120
fprintf(stderr, "%s: %s\n", __FUNCTION__, Symbolize(frame).c_str());
116121
// CHECK-LABEL: TestLongFunctionNames: NoInlineFunction()
117-
// CHECK-NEXT: internal_symbolizer.cpp:[[# @LINE - 65]]
122+
// CHECK-NEXT: internal_symbolizer.cpp:[[# @LINE - 68]]
118123
}
119124

120125
std::string SymbolizeStaticVar() {
@@ -134,8 +139,8 @@ void TestData() {
134139
// CHECK-NEXT: internal_symbolizer.cpp:[[# @LINE - 13]]
135140
}
136141

137-
__attribute__((noinline)) std::string SymbolizeLocalVars(FrameInfo frame) {
138-
auto modul_offset = GetModuleAndOffset(frame.address);
142+
__attribute__((noinline)) std::string SymbolizeLocalVars(const void *pc) {
143+
auto modul_offset = GetModuleAndOffset(pc);
139144
char buffer[1024] = {};
140145
ScopedInSymbolizer in_symbolizer;
141146
__sanitizer_symbolize_frame(modul_offset.first, modul_offset.second, buffer,
@@ -145,26 +150,19 @@ __attribute__((noinline)) std::string SymbolizeLocalVars(FrameInfo frame) {
145150

146151
__attribute__((
147152
noinline,
148-
no_sanitize_address /* Asan merges allocas destroying variable DI*/)) void
153+
no_sanitize_address /* Asan merges allocas destroying variable DI */)) void
149154
TestFrame() {
150155
volatile int var = 1;
151156
void *address = GetPC();
152157
fprintf(stderr, "%s: %s\n", __FUNCTION__,
153-
SymbolizeLocalVars({
154-
0,
155-
"",
156-
"",
157-
reinterpret_cast<void *>(
158-
reinterpret_cast<uintptr_t>(address)),
159-
})
160-
.c_str());
158+
SymbolizeLocalVars(address).c_str());
161159
// CHECK-LABEL: TestFrame: TestFrame
162160
// CHECK-NEXT: var
163-
// CHECK-NEXT: internal_symbolizer.cpp:[[# @LINE - 13]]
161+
// CHECK-NEXT: internal_symbolizer.cpp:[[# @LINE - 6]]
164162
// CHECK-NEXT: {{-?[0-9]+ +[0-9]+}}
165163
// CHECK-NEXT: TestFrame
166164
// CHECK-NEXT: address
167-
// CHECK-NEXT: internal_symbolizer.cpp:[[# @LINE - 16]]
165+
// CHECK-NEXT: internal_symbolizer.cpp:[[# @LINE - 9]]
168166
// CHECK-NEXT: {{-?[0-9]+ +[0-9]+}}
169167
}
170168

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 476037
19+
#define LLVM_MAIN_REVISION 476043
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ class VectorLegalizer {
173173
/// result is truncated back to the original scalar type.
174174
void PromoteReduction(SDNode *Node, SmallVectorImpl<SDValue> &Results);
175175

176+
/// Implements vector setcc operation promotion.
177+
///
178+
/// All vector operands are promoted to a vector type with larger element
179+
/// type.
180+
void PromoteSETCC(SDNode *Node, SmallVectorImpl<SDValue> &Results);
181+
176182
public:
177183
VectorLegalizer(SelectionDAG& dag) :
178184
DAG(dag), TLI(dag.getTargetLoweringInfo()) {}
@@ -603,6 +609,31 @@ void VectorLegalizer::PromoteReduction(SDNode *Node,
603609
Results.push_back(Res);
604610
}
605611

612+
void VectorLegalizer::PromoteSETCC(SDNode *Node,
613+
SmallVectorImpl<SDValue> &Results) {
614+
MVT VecVT = Node->getOperand(0).getSimpleValueType();
615+
MVT NewVecVT = TLI.getTypeToPromoteTo(Node->getOpcode(), VecVT);
616+
617+
unsigned ExtOp = VecVT.isFloatingPoint() ? ISD::FP_EXTEND : ISD::ANY_EXTEND;
618+
619+
SDLoc DL(Node);
620+
SmallVector<SDValue, 5> Operands(Node->getNumOperands());
621+
622+
Operands[0] = DAG.getNode(ExtOp, DL, NewVecVT, Node->getOperand(0));
623+
Operands[1] = DAG.getNode(ExtOp, DL, NewVecVT, Node->getOperand(1));
624+
Operands[2] = Node->getOperand(2);
625+
626+
if (Node->getOpcode() == ISD::VP_SETCC) {
627+
Operands[3] = Node->getOperand(3); // mask
628+
Operands[4] = Node->getOperand(4); // evl
629+
}
630+
631+
SDValue Res = DAG.getNode(Node->getOpcode(), DL, Node->getSimpleValueType(0),
632+
Operands, Node->getFlags());
633+
634+
Results.push_back(Res);
635+
}
636+
606637
void VectorLegalizer::Promote(SDNode *Node, SmallVectorImpl<SDValue> &Results) {
607638
// For a few operations there is a specific concept for promotion based on
608639
// the operand's type.
@@ -638,6 +669,11 @@ void VectorLegalizer::Promote(SDNode *Node, SmallVectorImpl<SDValue> &Results) {
638669
// Promote the operation by extending the operand.
639670
PromoteReduction(Node, Results);
640671
return;
672+
case ISD::VP_SETCC:
673+
case ISD::SETCC:
674+
// Promote the operation by extending the operand.
675+
PromoteSETCC(Node, Results);
676+
return;
641677
case ISD::FP_ROUND:
642678
case ISD::FP_EXTEND:
643679
// These operations are used to do promotion so they can't be promoted

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -822,11 +822,11 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
822822

823823
// TODO: support more ops.
824824
static const unsigned ZvfhminPromoteOps[] = {
825-
ISD::FMINNUM, ISD::FMAXNUM, ISD::FADD, ISD::FSUB,
826-
ISD::FMUL, ISD::FMA, ISD::FDIV, ISD::FSQRT,
827-
ISD::FABS, ISD::FNEG, ISD::FCOPYSIGN, ISD::FCEIL,
828-
ISD::FFLOOR, ISD::FROUND, ISD::FROUNDEVEN, ISD::FRINT,
829-
ISD::FNEARBYINT, ISD::IS_FPCLASS, ISD::SPLAT_VECTOR};
825+
ISD::FMINNUM, ISD::FMAXNUM, ISD::FADD, ISD::FSUB,
826+
ISD::FMUL, ISD::FMA, ISD::FDIV, ISD::FSQRT,
827+
ISD::FABS, ISD::FNEG, ISD::FCOPYSIGN, ISD::FCEIL,
828+
ISD::FFLOOR, ISD::FROUND, ISD::FROUNDEVEN, ISD::FRINT,
829+
ISD::FNEARBYINT, ISD::IS_FPCLASS, ISD::SPLAT_VECTOR, ISD::SETCC};
830830

831831
// TODO: support more vp ops.
832832
static const unsigned ZvfhminPromoteVPOps[] = {
@@ -837,7 +837,7 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
837837
ISD::VP_FMINNUM, ISD::VP_FMAXNUM, ISD::VP_FCEIL,
838838
ISD::VP_FFLOOR, ISD::VP_FROUND, ISD::VP_FROUNDEVEN,
839839
ISD::VP_FCOPYSIGN, ISD::VP_FROUNDTOZERO, ISD::VP_FRINT,
840-
ISD::VP_FNEARBYINT};
840+
ISD::VP_FNEARBYINT, ISD::VP_SETCC};
841841

842842
// Sets common operation actions on RVV floating-point vector types.
843843
const auto SetCommonVFPActions = [&](MVT VT) {
@@ -5392,6 +5392,11 @@ static SDValue SplitVPOp(SDValue Op, SelectionDAG &DAG) {
53925392
DAG.SplitEVL(Op.getOperand(j), Op.getValueType(), DL);
53935393
continue;
53945394
}
5395+
if (!Op.getOperand(j).getValueType().isVector()) {
5396+
LoOperands[j] = Op.getOperand(j);
5397+
HiOperands[j] = Op.getOperand(j);
5398+
continue;
5399+
}
53955400
std::tie(LoOperands[j], HiOperands[j]) =
53965401
DAG.SplitVector(Op.getOperand(j), DL);
53975402
}
@@ -6079,6 +6084,11 @@ SDValue RISCVTargetLowering::LowerOperation(SDValue Op,
60796084
return DAG.getSetCC(DL, VT, RHS, LHS, CCVal);
60806085
}
60816086

6087+
if (Op.getOperand(0).getSimpleValueType() == MVT::nxv32f16 &&
6088+
(Subtarget.hasVInstructionsF16Minimal() &&
6089+
!Subtarget.hasVInstructionsF16()))
6090+
return SplitVectorOp(Op, DAG);
6091+
60826092
return lowerFixedLengthVectorSetccToRVV(Op, DAG);
60836093
}
60846094
case ISD::ADD:
@@ -6246,6 +6256,10 @@ SDValue RISCVTargetLowering::LowerOperation(SDValue Op,
62466256
case ISD::VP_FP_TO_UINT:
62476257
return lowerVPFPIntConvOp(Op, DAG);
62486258
case ISD::VP_SETCC:
6259+
if (Op.getOperand(0).getSimpleValueType() == MVT::nxv32f16 &&
6260+
(Subtarget.hasVInstructionsF16Minimal() &&
6261+
!Subtarget.hasVInstructionsF16()))
6262+
return SplitVPOp(Op, DAG);
62496263
if (Op.getOperand(0).getSimpleValueType().getVectorElementType() == MVT::i1)
62506264
return lowerVPSetCCMaskOp(Op, DAG);
62516265
[[fallthrough]];

0 commit comments

Comments
 (0)