Skip to content

Commit ac276c9

Browse files
authored
Merge branch 'main' into ml-program-transforms-linked-libs
2 parents 735bb45 + 435a542 commit ac276c9

File tree

1,186 files changed

+51973
-50903
lines changed

Some content is hidden

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

1,186 files changed

+51973
-50903
lines changed

clang/include/clang/Basic/riscv_vector.td

Lines changed: 42 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class IsFloat<string type> {
2626

2727
let SupportOverloading = false,
2828
MaskedPolicyScheme = NonePolicy in {
29-
class RVVVLEMaskBuiltin : RVVOutBuiltin<"m", "mPCUe", "c"> {
29+
class RVVVLEMaskBuiltin : RVVOutOp0Builtin<"m", "mPCUe", "c"> {
3030
let Name = "vlm_v";
3131
let IRName = "vlm";
3232
let HasMasked = false;
@@ -40,9 +40,9 @@ let SupportOverloading = false,
4040
IRName = "vle",
4141
MaskedIRName ="vle_mask" in {
4242
foreach type = types in {
43-
def : RVVOutBuiltin<"v", "vPCe", type>;
43+
def : RVVOutOp0Builtin<"v", "vPCe", type>;
4444
if !not(IsFloat<type>.val) then {
45-
def : RVVOutBuiltin<"Uv", "UvPCUe", type>;
45+
def : RVVOutOp0Builtin<"Uv", "UvPCUe", type>;
4646
}
4747
}
4848
}
@@ -63,11 +63,11 @@ multiclass RVVVLEFFBuiltin<list<string> types> {
6363
if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
6464
Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
6565
Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
66-
IntrinsicTypes = {ResultType, Ops[4]->getType()};
66+
IntrinsicTypes = {ResultType, Ops[4]->getType(), Ops[2]->getType()};
6767
} else {
6868
if (PolicyAttrs & RVV_VTA)
6969
Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
70-
IntrinsicTypes = {ResultType, Ops[3]->getType()};
70+
IntrinsicTypes = {ResultType, Ops[3]->getType(), Ops[1]->getType()};
7171
}
7272
Value *NewVL = Ops[2];
7373
Ops.erase(Ops.begin() + 2);
@@ -102,9 +102,9 @@ multiclass RVVVLSEBuiltin<list<string> types> {
102102
SupportOverloading = false,
103103
UnMaskedPolicyScheme = HasPassthruOperand in {
104104
foreach type = types in {
105-
def : RVVOutBuiltin<"v", "vPCet", type>;
105+
def : RVVOutOp0Builtin<"v", "vPCet", type>;
106106
if !not(IsFloat<type>.val) then {
107-
def : RVVOutBuiltin<"Uv", "UvPCUet", type>;
107+
def : RVVOutOp0Builtin<"Uv", "UvPCUet", type>;
108108
}
109109
}
110110
}
@@ -120,9 +120,9 @@ multiclass RVVIndexedLoad<string op> {
120120
RequiredFeatures = !if(!eq(type, "x"), ["Zvfhmin"],
121121
!if(!eq(type, "y"), ["Zvfbfmin"],
122122
[]<string>)) in {
123-
def: RVVOutOp1Builtin<"v", "vPCe" # eew_type # "Uv", type>;
123+
def: RVVOutOp0Op1Builtin<"v", "vPCe" # eew_type # "Uv", type>;
124124
if !not(IsFloat<type>.val) then {
125-
def: RVVOutOp1Builtin<"Uv", "UvPCUe" # eew_type # "Uv", type>;
125+
def: RVVOutOp0Op1Builtin<"Uv", "UvPCUe" # eew_type # "Uv", type>;
126126
}
127127
}
128128
}
@@ -132,9 +132,9 @@ multiclass RVVIndexedLoad<string op> {
132132
RequiredFeatures = !if(!eq(type, "x"), ["Zvfhmin", "RV64"],
133133
!if(!eq(type, "y"), ["Zvfbfmin", "RV64"],
134134
["RV64"])) in {
135-
def: RVVOutOp1Builtin<"v", "vPCe" # eew64_type # "Uv", type>;
135+
def: RVVOutOp0Op1Builtin<"v", "vPCe" # eew64_type # "Uv", type>;
136136
if !not(IsFloat<type>.val) then {
137-
def: RVVOutOp1Builtin<"Uv", "UvPCUe" # eew64_type # "Uv", type>;
137+
def: RVVOutOp0Op1Builtin<"Uv", "UvPCUe" # eew64_type # "Uv", type>;
138138
}
139139
}
140140
}
@@ -152,9 +152,9 @@ let HasMaskedOffOperand = false,
152152
std::swap(Ops[0], Ops[1]);
153153
}
154154
if (IsMasked)
155-
IntrinsicTypes = {Ops[0]->getType(), Ops[3]->getType()};
155+
IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops[3]->getType()};
156156
else
157-
IntrinsicTypes = {Ops[0]->getType(), Ops[2]->getType()};
157+
IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops[2]->getType()};
158158
}] in {
159159
class RVVVSEMaskBuiltin : RVVBuiltin<"m", "0PUem", "c"> {
160160
let Name = "vsm_v";
@@ -190,9 +190,9 @@ multiclass RVVVSSEBuiltin<list<string> types> {
190190
std::rotate(Ops.begin(), Ops.begin() + 2, Ops.begin() + 3);
191191
}
192192
if (IsMasked)
193-
IntrinsicTypes = {Ops[0]->getType(), Ops[4]->getType()};
193+
IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops[4]->getType()};
194194
else
195-
IntrinsicTypes = {Ops[0]->getType(), Ops[3]->getType()};
195+
IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops[3]->getType()};
196196
}] in {
197197
foreach type = types in {
198198
def : RVVBuiltin<"v", "0Petv", type>;
@@ -215,9 +215,9 @@ multiclass RVVIndexedStore<string op> {
215215
std::rotate(Ops.begin(), Ops.begin() + 2, Ops.begin() + 3);
216216
}
217217
if (IsMasked)
218-
IntrinsicTypes = {Ops[0]->getType(), Ops[2]->getType(), Ops[4]->getType()};
218+
IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops[2]->getType(), Ops[4]->getType()};
219219
else
220-
IntrinsicTypes = {Ops[0]->getType(), Ops[2]->getType(), Ops[3]->getType()};
220+
IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops[2]->getType(), Ops[3]->getType()};
221221
}] in {
222222
foreach type = TypeList in {
223223
foreach eew_list = EEWList[0-2] in {
@@ -762,17 +762,18 @@ multiclass RVVUnitStridedSegLoadTuple<string op> {
762762
[]<string>)),
763763
ManualCodegen = [{
764764
{
765-
if (IsMasked)
766-
IntrinsicTypes = {ResultType, Ops[0]->getType(), Ops.back()->getType()};
767-
else
768-
IntrinsicTypes = {ResultType, Ops.back()->getType()};
769765
SmallVector<llvm::Value*, 6> Operands;
770766

771767
bool NoPassthru =
772768
(IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) |
773769
(!IsMasked && (PolicyAttrs & RVV_VTA));
774770
unsigned Offset = IsMasked ? NoPassthru ? 1 : 2 : NoPassthru ? 0 : 1;
775771

772+
if (IsMasked)
773+
IntrinsicTypes = {ResultType, Ops[Offset]->getType(), Ops[0]->getType(), Ops.back()->getType()};
774+
else
775+
IntrinsicTypes = {ResultType, Ops[Offset]->getType(), Ops.back()->getType()};
776+
776777
if (NoPassthru) { // Push poison into passthru
777778
Operands.push_back(llvm::PoisonValue::get(ResultType));
778779
} else { // Push intrinsics operands into passthru
@@ -845,9 +846,9 @@ multiclass RVVUnitStridedSegStoreTuple<string op> {
845846
Operands.push_back(ConstantInt::get(Ops.back()->getType(), SegInstSEW));
846847

847848
if (IsMasked)
848-
IntrinsicTypes = {Operands[0]->getType(), Ops[0]->getType(), Operands.back()->getType()};
849+
IntrinsicTypes = {Operands[0]->getType(), Ops[Offset]->getType(), Ops[0]->getType(), Operands.back()->getType()};
849850
else
850-
IntrinsicTypes = {Operands[0]->getType(), Operands.back()->getType()};
851+
IntrinsicTypes = {Operands[0]->getType(), Ops[Offset]->getType(), Operands.back()->getType()};
851852
llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
852853
return Builder.CreateCall(F, Operands, "");
853854
}
@@ -882,17 +883,18 @@ multiclass RVVUnitStridedSegLoadFFTuple<string op> {
882883
[]<string>)),
883884
ManualCodegen = [{
884885
{
885-
if (IsMasked)
886-
IntrinsicTypes = {ResultType, Ops.back()->getType(), Ops[0]->getType()};
887-
else
888-
IntrinsicTypes = {ResultType, Ops.back()->getType()};
889886
SmallVector<llvm::Value*, 6> Operands;
890887

891888
bool NoPassthru =
892889
(IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) |
893890
(!IsMasked && (PolicyAttrs & RVV_VTA));
894891
unsigned Offset = IsMasked ? NoPassthru ? 1 : 2 : NoPassthru ? 0 : 1;
895892

893+
if (IsMasked)
894+
IntrinsicTypes = {ResultType, Ops.back()->getType(), Ops[Offset]->getType(), Ops[0]->getType()};
895+
else
896+
IntrinsicTypes = {ResultType, Ops.back()->getType(), Ops[Offset]->getType()};
897+
896898
if (NoPassthru) { // Push poison into passthru
897899
Operands.push_back(llvm::PoisonValue::get(ResultType));
898900
} else { // Push intrinsics operands into passthru
@@ -957,17 +959,18 @@ multiclass RVVStridedSegLoadTuple<string op> {
957959
[]<string>)),
958960
ManualCodegen = [{
959961
{
960-
if (IsMasked)
961-
IntrinsicTypes = {ResultType, Ops.back()->getType(), Ops[0]->getType()};
962-
else
963-
IntrinsicTypes = {ResultType, Ops.back()->getType()};
964962
SmallVector<llvm::Value*, 7> Operands;
965963

966964
bool NoPassthru =
967965
(IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) |
968966
(!IsMasked && (PolicyAttrs & RVV_VTA));
969967
unsigned Offset = IsMasked ? NoPassthru ? 1 : 2 : NoPassthru ? 0 : 1;
970968

969+
if (IsMasked)
970+
IntrinsicTypes = {ResultType, Ops[Offset]->getType(), Ops.back()->getType(), Ops[0]->getType()};
971+
else
972+
IntrinsicTypes = {ResultType, Ops[Offset]->getType(), Ops.back()->getType()};
973+
971974
if (NoPassthru) { // Push poison into passthru
972975
Operands.push_back(llvm::PoisonValue::get(ResultType));
973976
} else { // Push intrinsics operands into passthru
@@ -1043,9 +1046,9 @@ multiclass RVVStridedSegStoreTuple<string op> {
10431046
Operands.push_back(ConstantInt::get(Ops.back()->getType(), SegInstSEW));
10441047

10451048
if (IsMasked)
1046-
IntrinsicTypes = {Operands[0]->getType(), Operands.back()->getType(), Ops[0]->getType()};
1049+
IntrinsicTypes = {Operands[0]->getType(), Operands[1]->getType(), Operands.back()->getType(), Ops[0]->getType()};
10471050
else
1048-
IntrinsicTypes = {Operands[0]->getType(), Operands.back()->getType()};
1051+
IntrinsicTypes = {Operands[0]->getType(), Operands[1]->getType(), Operands.back()->getType()};
10491052
llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
10501053
return Builder.CreateCall(F, Operands, "");
10511054
}
@@ -1099,11 +1102,13 @@ multiclass RVVIndexedSegLoadTuple<string op> {
10991102
Operands.push_back(ConstantInt::get(Ops.back()->getType(), SegInstSEW));
11001103

11011104
if (IsMasked)
1102-
IntrinsicTypes = {ResultType, Ops[Offset + 1]->getType(),
1105+
IntrinsicTypes = {ResultType, Ops[Offset]->getType(),
1106+
Ops[Offset + 1]->getType(),
11031107
Ops[0]->getType(),
11041108
Ops.back()->getType()};
11051109
else
1106-
IntrinsicTypes = {ResultType, Ops[Offset + 1]->getType(),
1110+
IntrinsicTypes = {ResultType, Ops[Offset]->getType(),
1111+
Ops[Offset + 1]->getType(),
11071112
Ops.back()->getType()};
11081113
llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
11091114
llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
@@ -1160,11 +1165,11 @@ multiclass RVVIndexedSegStoreTuple<string op> {
11601165
Operands.push_back(ConstantInt::get(Ops.back()->getType(), SegInstSEW));
11611166

11621167
if (IsMasked)
1163-
IntrinsicTypes = {Operands[0]->getType(), Ops[Offset + 1]->getType(),
1168+
IntrinsicTypes = {Operands[0]->getType(), Ops[Offset]->getType(), Ops[Offset + 1]->getType(),
11641169
Ops[0]->getType(),
11651170
Operands.back()->getType()};
11661171
else
1167-
IntrinsicTypes = {Operands[0]->getType(), Ops[Offset + 1]->getType(),
1172+
IntrinsicTypes = {Operands[0]->getType(), Ops[Offset]->getType(), Ops[Offset + 1]->getType(),
11681173
Operands.back()->getType()};
11691174
llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
11701175
return Builder.CreateCall(F, Operands, "");

clang/include/clang/Basic/riscv_vector_common.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,11 @@ class RVVOp0Builtin<string suffix, string prototype, string type_range>
266266
let IntrinsicTypes = [0];
267267
}
268268

269+
class RVVOutOp0Builtin<string suffix, string prototype, string type_range>
270+
: RVVBuiltin<suffix, prototype, type_range> {
271+
let IntrinsicTypes = [-1, 0];
272+
}
273+
269274
class RVVOutOp1Builtin<string suffix, string prototype, string type_range>
270275
: RVVBuiltin<suffix, prototype, type_range> {
271276
let IntrinsicTypes = [-1, 1];

clang/lib/CodeGen/CGClass.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,7 @@ void CodeGenFunction::EmitCtorPrologue(const CXXConstructorDecl *CD,
13381338
assert(!Member->isBaseInitializer());
13391339
assert(Member->isAnyMemberInitializer() &&
13401340
"Delegating initializer on non-delegating constructor");
1341+
ApplyAtomGroup Grp(getDebugInfo());
13411342
CM.addMemberInitializer(Member);
13421343
}
13431344
CM.finish();

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5981,6 +5981,15 @@ LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) {
59815981

59825982
assert(E->getOpcode() == BO_Assign && "unexpected binary l-value");
59835983

5984+
// Create a Key Instructions source location atom group that covers both
5985+
// LHS and RHS expressions. Nested RHS expressions may get subsequently
5986+
// separately grouped (1 below):
5987+
//
5988+
// 1. `a = b = c` -> Two atoms.
5989+
// 2. `x = new(1)` -> One atom (for both addr store and value store).
5990+
// 3. Complex and agg assignment -> One atom.
5991+
ApplyAtomGroup Grp(getDebugInfo());
5992+
59845993
// Note that in all of these cases, __block variables need the RHS
59855994
// evaluated first just in case the variable gets moved by the RHS.
59865995

clang/lib/CodeGen/CGExprScalar.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,7 @@ class ScalarExprEmitter
898898
return result; \
899899
} \
900900
Value *VisitBin##OP##Assign(const CompoundAssignOperator *E) { \
901+
ApplyAtomGroup Grp(CGF.getDebugInfo()); \
901902
return EmitCompoundAssign(E, &ScalarExprEmitter::Emit##OP); \
902903
}
903904
HANDLEBINOP(Mul)
@@ -3014,6 +3015,7 @@ class OMPLastprivateConditionalUpdateRAII {
30143015
llvm::Value *
30153016
ScalarExprEmitter::EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV,
30163017
bool isInc, bool isPre) {
3018+
ApplyAtomGroup Grp(CGF.getDebugInfo());
30173019
OMPLastprivateConditionalUpdateRAII OMPRegion(CGF, E);
30183020
QualType type = E->getSubExpr()->getType();
30193021
llvm::PHINode *atomicPHI = nullptr;
@@ -5067,6 +5069,7 @@ llvm::Value *CodeGenFunction::EmitWithOriginalRHSBitfieldAssignment(
50675069
}
50685070

50695071
Value *ScalarExprEmitter::VisitBinAssign(const BinaryOperator *E) {
5072+
ApplyAtomGroup Grp(CGF.getDebugInfo());
50705073
bool Ignore = TestAndClearIgnoreResultAssign();
50715074

50725075
Value *RHS;
@@ -5849,6 +5852,7 @@ LValue CodeGenFunction::EmitObjCIsaExpr(const ObjCIsaExpr *E) {
58495852

58505853
LValue CodeGenFunction::EmitCompoundAssignmentLValue(
58515854
const CompoundAssignOperator *E) {
5855+
ApplyAtomGroup Grp(getDebugInfo());
58525856
ScalarExprEmitter Scalar(*this);
58535857
Value *Result = nullptr;
58545858
switch (E->getOpcode()) {

clang/lib/Sema/SemaDecl.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9725,14 +9725,10 @@ static void checkIsValidOpenCLKernelParameter(
97259725
SmallVector<const FieldDecl *, 4> HistoryStack;
97269726
HistoryStack.push_back(nullptr);
97279727

9728-
// At this point we already handled everything except of a RecordType or
9729-
// an ArrayType of a RecordType.
9730-
assert((PT->isArrayType() || PT->isRecordType()) && "Unexpected type.");
9731-
const RecordType *RecTy =
9732-
PT->getPointeeOrArrayElementType()->getAs<RecordType>();
9733-
const RecordDecl *OrigRecDecl = RecTy->getDecl();
9734-
9735-
VisitStack.push_back(RecTy->getDecl());
9728+
// At this point we already handled everything except of a RecordType.
9729+
assert(PT->isRecordType() && "Unexpected type.");
9730+
const RecordDecl *PD = PT->castAs<RecordType>()->getDecl();
9731+
VisitStack.push_back(PD);
97369732
assert(VisitStack.back() && "First decl null?");
97379733

97389734
do {
@@ -9797,8 +9793,8 @@ static void checkIsValidOpenCLKernelParameter(
97979793
S.Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT;
97989794
}
97999795

9800-
S.Diag(OrigRecDecl->getLocation(), diag::note_within_field_of_type)
9801-
<< OrigRecDecl->getDeclName();
9796+
S.Diag(PD->getLocation(), diag::note_within_field_of_type)
9797+
<< PD->getDeclName();
98029798

98039799
// We have an error, now let's go back up through history and show where
98049800
// the offending field came from

0 commit comments

Comments
 (0)