Skip to content

Commit e8069a8

Browse files
authored
merge main into amd-staging (llvm#2441)
2 parents 0848dcc + e630724 commit e8069a8

File tree

9 files changed

+44
-48
lines changed

9 files changed

+44
-48
lines changed

clang/lib/Sema/SemaRISCV.cpp

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,10 @@ bool SemaRISCV::CheckLMUL(CallExpr *TheCall, unsigned ArgNum) {
545545
<< Arg->getSourceRange();
546546
}
547547

548-
static bool CheckInvalidVLENandLMUL(const TargetInfo &TI, CallExpr *TheCall,
549-
Sema &S, QualType Type, int EGW) {
548+
static bool CheckInvalidVLENandLMUL(const TargetInfo &TI,
549+
llvm::StringMap<bool> &FunctionFeatureMap,
550+
CallExpr *TheCall, Sema &S, QualType Type,
551+
int EGW) {
550552
assert((EGW == 128 || EGW == 256) && "EGW can only be 128 or 256 bits");
551553

552554
// LMUL * VLEN >= EGW
@@ -567,7 +569,7 @@ static bool CheckInvalidVLENandLMUL(const TargetInfo &TI, CallExpr *TheCall,
567569
// Vscale is VLEN/RVVBitsPerBlock.
568570
unsigned MinRequiredVLEN = VScaleFactor * llvm::RISCV::RVVBitsPerBlock;
569571
std::string RequiredExt = "zvl" + std::to_string(MinRequiredVLEN) + "b";
570-
if (!TI.hasFeature(RequiredExt))
572+
if (!TI.hasFeature(RequiredExt) && !FunctionFeatureMap.lookup(RequiredExt))
571573
return S.Diag(TheCall->getBeginLoc(),
572574
diag::err_riscv_type_requires_extension)
573575
<< Type << RequiredExt;
@@ -579,6 +581,10 @@ bool SemaRISCV::CheckBuiltinFunctionCall(const TargetInfo &TI,
579581
unsigned BuiltinID,
580582
CallExpr *TheCall) {
581583
ASTContext &Context = getASTContext();
584+
const FunctionDecl *FD = SemaRef.getCurFunctionDecl();
585+
llvm::StringMap<bool> FunctionFeatureMap;
586+
Context.getFunctionFeatureMap(FunctionFeatureMap, FD);
587+
582588
// vmulh.vv, vmulh.vx, vmulhu.vv, vmulhu.vx, vmulhsu.vv, vmulhsu.vx,
583589
// vsmul.vv, vsmul.vx are not included for EEW=64 in Zve64*.
584590
switch (BuiltinID) {
@@ -635,10 +641,6 @@ bool SemaRISCV::CheckBuiltinFunctionCall(const TargetInfo &TI,
635641
ASTContext::BuiltinVectorTypeInfo Info = Context.getBuiltinVectorTypeInfo(
636642
TheCall->getType()->castAs<BuiltinType>());
637643

638-
const FunctionDecl *FD = SemaRef.getCurFunctionDecl();
639-
llvm::StringMap<bool> FunctionFeatureMap;
640-
Context.getFunctionFeatureMap(FunctionFeatureMap, FD);
641-
642644
if (Context.getTypeSize(Info.ElementType) == 64 && !TI.hasFeature("v") &&
643645
!FunctionFeatureMap.lookup("v"))
644646
return Diag(TheCall->getBeginLoc(),
@@ -714,20 +716,24 @@ bool SemaRISCV::CheckBuiltinFunctionCall(const TargetInfo &TI,
714716
case RISCVVector::BI__builtin_rvv_vsm4k_vi_tu: {
715717
QualType Arg0Type = TheCall->getArg(0)->getType();
716718
QualType Arg1Type = TheCall->getArg(1)->getType();
717-
return CheckInvalidVLENandLMUL(TI, TheCall, SemaRef, Arg0Type, 128) ||
718-
CheckInvalidVLENandLMUL(TI, TheCall, SemaRef, Arg1Type, 128) ||
719+
return CheckInvalidVLENandLMUL(TI, FunctionFeatureMap, TheCall, SemaRef,
720+
Arg0Type, 128) ||
721+
CheckInvalidVLENandLMUL(TI, FunctionFeatureMap, TheCall, SemaRef,
722+
Arg1Type, 128) ||
719723
SemaRef.BuiltinConstantArgRange(TheCall, 2, 0, 31);
720724
}
721725
case RISCVVector::BI__builtin_rvv_vsm3c_vi_tu:
722726
case RISCVVector::BI__builtin_rvv_vsm3c_vi: {
723727
QualType Arg0Type = TheCall->getArg(0)->getType();
724-
return CheckInvalidVLENandLMUL(TI, TheCall, SemaRef, Arg0Type, 256) ||
728+
return CheckInvalidVLENandLMUL(TI, FunctionFeatureMap, TheCall, SemaRef,
729+
Arg0Type, 256) ||
725730
SemaRef.BuiltinConstantArgRange(TheCall, 2, 0, 31);
726731
}
727732
case RISCVVector::BI__builtin_rvv_vaeskf1_vi:
728733
case RISCVVector::BI__builtin_rvv_vsm4k_vi: {
729734
QualType Arg0Type = TheCall->getArg(0)->getType();
730-
return CheckInvalidVLENandLMUL(TI, TheCall, SemaRef, Arg0Type, 128) ||
735+
return CheckInvalidVLENandLMUL(TI, FunctionFeatureMap, TheCall, SemaRef,
736+
Arg0Type, 128) ||
731737
SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 31);
732738
}
733739
case RISCVVector::BI__builtin_rvv_vaesdf_vv:
@@ -754,8 +760,10 @@ bool SemaRISCV::CheckBuiltinFunctionCall(const TargetInfo &TI,
754760
case RISCVVector::BI__builtin_rvv_vsm4r_vs_tu: {
755761
QualType Arg0Type = TheCall->getArg(0)->getType();
756762
QualType Arg1Type = TheCall->getArg(1)->getType();
757-
return CheckInvalidVLENandLMUL(TI, TheCall, SemaRef, Arg0Type, 128) ||
758-
CheckInvalidVLENandLMUL(TI, TheCall, SemaRef, Arg1Type, 128);
763+
return CheckInvalidVLENandLMUL(TI, FunctionFeatureMap, TheCall, SemaRef,
764+
Arg0Type, 128) ||
765+
CheckInvalidVLENandLMUL(TI, FunctionFeatureMap, TheCall, SemaRef,
766+
Arg1Type, 128);
759767
}
760768
case RISCVVector::BI__builtin_rvv_vsha2ch_vv:
761769
case RISCVVector::BI__builtin_rvv_vsha2cl_vv:
@@ -769,17 +777,18 @@ bool SemaRISCV::CheckBuiltinFunctionCall(const TargetInfo &TI,
769777
ASTContext::BuiltinVectorTypeInfo Info =
770778
Context.getBuiltinVectorTypeInfo(Arg0Type->castAs<BuiltinType>());
771779
uint64_t ElemSize = Context.getTypeSize(Info.ElementType);
772-
if (ElemSize == 64 && !TI.hasFeature("zvknhb"))
780+
if (ElemSize == 64 && !TI.hasFeature("zvknhb") &&
781+
!FunctionFeatureMap.lookup("zvknhb"))
773782
return Diag(TheCall->getBeginLoc(),
774783
diag::err_riscv_builtin_requires_extension)
775784
<< /* IsExtension */ true << TheCall->getSourceRange() << "zvknhb";
776785

777-
return CheckInvalidVLENandLMUL(TI, TheCall, SemaRef, Arg0Type,
778-
ElemSize * 4) ||
779-
CheckInvalidVLENandLMUL(TI, TheCall, SemaRef, Arg1Type,
780-
ElemSize * 4) ||
781-
CheckInvalidVLENandLMUL(TI, TheCall, SemaRef, Arg2Type,
782-
ElemSize * 4);
786+
return CheckInvalidVLENandLMUL(TI, FunctionFeatureMap, TheCall, SemaRef,
787+
Arg0Type, ElemSize * 4) ||
788+
CheckInvalidVLENandLMUL(TI, FunctionFeatureMap, TheCall, SemaRef,
789+
Arg1Type, ElemSize * 4) ||
790+
CheckInvalidVLENandLMUL(TI, FunctionFeatureMap, TheCall, SemaRef,
791+
Arg2Type, ElemSize * 4);
783792
}
784793

785794
case RISCVVector::BI__builtin_rvv_sf_vc_i_se:
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// REQUIRES: riscv-registered-target
2+
// RUN: %clang_cc1 -triple riscv64 -target-feature +zvknha %s -fsyntax-only -verify
3+
4+
#include <riscv_vector.h>
5+
6+
// expected-no-diagnostics
7+
8+
__attribute__((target("arch=+zvl128b")))
9+
void test_zvk_features(vuint32m1_t vd, vuint32m1_t vs2, vuint32m1_t vs1, size_t vl) {
10+
__riscv_vsha2ch_vv_u32m1(vd, vs2, vs1, vl);
11+
}

lldb/tools/lldb-dap/Handler/SetBreakpointsRequestHandler.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "DAP.h"
10-
#include "EventHelper.h"
11-
#include "JSONUtils.h"
1210
#include "Protocol/ProtocolRequests.h"
1311
#include "RequestHandler.h"
1412
#include <vector>
@@ -22,7 +20,7 @@ namespace lldb_dap {
2220
llvm::Expected<protocol::SetBreakpointsResponseBody>
2321
SetBreakpointsRequestHandler::Run(
2422
const protocol::SetBreakpointsArguments &args) const {
25-
const auto response_breakpoints =
23+
std::vector<protocol::Breakpoint> response_breakpoints =
2624
dap.SetSourceBreakpoints(args.source, args.breakpoints);
2725
return protocol::SetBreakpointsResponseBody{std::move(response_breakpoints)};
2826
}

llvm/include/llvm/MC/MCFragment.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ class MCFragment {
5050
FT_CVInlineLines,
5151
FT_CVDefRange,
5252
FT_PseudoProbe,
53-
FT_Dummy
5453
};
5554

5655
private:
@@ -111,13 +110,6 @@ class MCFragment {
111110
void dump() const;
112111
};
113112

114-
class MCDummyFragment : public MCFragment {
115-
public:
116-
explicit MCDummyFragment() : MCFragment(FT_Dummy, false) {}
117-
118-
static bool classof(const MCFragment *F) { return F->getKind() == FT_Dummy; }
119-
};
120-
121113
/// Interface implemented by fragments that contain encoded instructions and/or
122114
/// data.
123115
///

llvm/include/llvm/MC/MCSection.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ class MCSection {
111111
/// offset between two locations may not be fully resolved.
112112
bool LinkerRelaxable : 1;
113113

114-
MCDummyFragment DummyFragment;
115-
116114
// Mapping from subsection number to fragment list. At layout time, the
117115
// subsection 0 list is replaced with concatenated fragments from all
118116
// subsections.
@@ -182,8 +180,7 @@ class MCSection {
182180
bool isLinkerRelaxable() const { return LinkerRelaxable; }
183181
void setLinkerRelaxable() { LinkerRelaxable = true; }
184182

185-
const MCDummyFragment &getDummyFragment() const { return DummyFragment; }
186-
MCDummyFragment &getDummyFragment() { return DummyFragment; }
183+
MCFragment &getDummyFragment() { return *Subsections[0].second.Head; }
187184

188185
FragList *curFragList() const { return CurFragList; }
189186
iterator begin() const { return iterator(CurFragList->Head); }

llvm/lib/MC/MCAssembler.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,6 @@ uint64_t MCAssembler::computeFragmentSize(const MCFragment &F) const {
300300
return cast<MCCVDefRangeFragment>(F).getContents().size();
301301
case MCFragment::FT_PseudoProbe:
302302
return cast<MCPseudoProbeAddrFragment>(F).getContents().size();
303-
case MCFragment::FT_Dummy:
304-
llvm_unreachable("Should not have been added");
305303
}
306304

307305
llvm_unreachable("invalid fragment kind");
@@ -767,8 +765,6 @@ static void writeFragment(raw_ostream &OS, const MCAssembler &Asm,
767765
OS << PF.getContents();
768766
break;
769767
}
770-
case MCFragment::FT_Dummy:
771-
llvm_unreachable("Should not have been added");
772768
}
773769

774770
assert(OS.tell() - Start == FragmentSize &&
@@ -846,7 +842,7 @@ void MCAssembler::layout() {
846842

847843
// Chain together fragments from all subsections.
848844
if (Sec.Subsections.size() > 1) {
849-
MCDummyFragment Dummy;
845+
MCDataFragment Dummy;
850846
MCFragment *Tail = &Dummy;
851847
for (auto &[_, List] : Sec.Subsections) {
852848
assert(List.Head);

llvm/lib/MC/MCFragment.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ void MCFragment::destroy() {
7272
case FT_PseudoProbe:
7373
cast<MCPseudoProbeAddrFragment>(this)->~MCPseudoProbeAddrFragment();
7474
return;
75-
case FT_Dummy:
76-
cast<MCDummyFragment>(this)->~MCDummyFragment();
77-
return;
7875
}
7976
}
8077

@@ -119,7 +116,6 @@ LLVM_DUMP_METHOD void MCFragment::dump() const {
119116
case MCFragment::FT_PseudoProbe:
120117
OS << "MCPseudoProbe";
121118
break;
122-
case MCFragment::FT_Dummy: OS << "MCDummyFragment"; break;
123119
}
124120

125121
OS << "<MCFragment " << (const void *)this << " LayoutOrder:" << LayoutOrder
@@ -241,8 +237,6 @@ LLVM_DUMP_METHOD void MCFragment::dump() const {
241237
OS << " AddrDelta:" << OF->getAddrDelta();
242238
break;
243239
}
244-
case MCFragment::FT_Dummy:
245-
break;
246240
}
247241
OS << ">";
248242
}

llvm/lib/MC/MCSection.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ MCSection::MCSection(SectionVariant V, StringRef Name, bool IsText,
2424
: Begin(Begin), BundleGroupBeforeFirstInst(false), HasInstructions(false),
2525
HasLayout(false), IsRegistered(false), IsText(IsText),
2626
IsVirtual(IsVirtual), LinkerRelaxable(false), Name(Name), Variant(V) {
27-
DummyFragment.setParent(this);
2827
// The initial subsection number is 0. Create a fragment list.
2928
CurFragList = &Subsections.emplace_back(0u, FragList{}).second;
3029
}

llvm/lib/MC/MCSymbol.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
using namespace llvm;
2323

2424
// Only the address of this fragment is ever actually used.
25-
static MCDummyFragment SentinelFragment;
25+
static MCDataFragment SentinelFragment;
2626

2727
// Sentinel value for the absolute pseudo fragment.
2828
MCFragment *MCSymbol::AbsolutePseudoFragment = &SentinelFragment;

0 commit comments

Comments
 (0)