Skip to content

Commit e9b3d79

Browse files
authored
merge main into amd-staging (#615)
2 parents 3f0aa69 + 81da1c3 commit e9b3d79

File tree

192 files changed

+10779
-1569
lines changed

Some content is hidden

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

192 files changed

+10779
-1569
lines changed

clang/include/clang/Basic/BuiltinsX86.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4117,15 +4117,15 @@ let Features = "avx512f", Attributes = [NoThrow, Const, Constexpr, RequiredVecto
41174117
def selectpd_512 : X86Builtin<"_Vector<8, double>(unsigned char, _Vector<8, double>, _Vector<8, double>)">;
41184118
}
41194119

4120-
let Features = "avx512fp16", Attributes = [NoThrow, Const, RequiredVectorWidth<128>] in {
4120+
let Features = "avx512fp16", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
41214121
def selectsh_128 : X86Builtin<"_Vector<8, _Float16>(unsigned char, _Vector<8, _Float16>, _Vector<8, _Float16>)">;
41224122
}
41234123

4124-
let Features = "avx512bf16", Attributes = [NoThrow, Const, RequiredVectorWidth<128>] in {
4124+
let Features = "avx512bf16", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
41254125
def selectsbf_128 : X86Builtin<"_Vector<8, __bf16>(unsigned char, _Vector<8, __bf16>, _Vector<8, __bf16>)">;
41264126
}
41274127

4128-
let Features = "avx512f", Attributes = [NoThrow, Const, RequiredVectorWidth<128>] in {
4128+
let Features = "avx512f", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
41294129
def selectss_128 : X86Builtin<"_Vector<4, float>(unsigned char, _Vector<4, float>, _Vector<4, float>)">;
41304130
def selectsd_128 : X86Builtin<"_Vector<2, double>(unsigned char, _Vector<2, double>, _Vector<2, double>)">;
41314131
}

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,23 @@ def err_drv_bad_offload_arch_combo : Error<
129129
"invalid offload arch combinations: '%0' and '%1' (for a specific processor, "
130130
"a feature should either exist in all offload archs, or not exist in any "
131131
"offload archs)">;
132+
def err_drv_unsupported_option_for_offload_arch_req_feature : Error<
133+
"'%0' option for offload arch '%1' is not currently supported "
134+
"there. Use it with an offload arch containing '%2' instead">;
132135
def warn_drv_unsupported_option_for_offload_arch_req_feature : Warning<
133136
"ignoring '%0' option for offload arch '%1' as it is not currently supported "
134137
"there. Use it with an offload arch containing '%2' instead">,
135138
InGroup<OptionIgnored>;
136139
def warn_drv_unsupported_option_for_target : Warning<
137140
"ignoring '%0' option as it is not currently supported for target '%1'">,
138141
InGroup<OptionIgnored>;
142+
def err_drv_unsupported_option_for_target : Error<
143+
"'%0' option is not currently supported for target '%1'">;
144+
def warn_drv_unsupported_option_part_for_target : Warning<
145+
"ignoring '%0' in '%1' option as it is not currently supported for target '%2'">,
146+
InGroup<OptionIgnored>;
147+
def err_drv_unsupported_option_part_for_target : Error<
148+
"'%0' in '%1' option is not currently supported for target '%2'">;
139149
def warn_drv_invalid_argument_for_flang : Warning<
140150
"'%0' is not valid for Fortran">,
141151
InGroup<OptionIgnored>;

clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,14 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
131131
return cir::IntType::get(getContext(), n, false);
132132
}
133133

134+
static unsigned getCIRIntOrFloatBitWidth(mlir::Type eltTy) {
135+
if (auto intType = mlir::dyn_cast<cir::IntTypeInterface>(eltTy))
136+
return intType.getWidth();
137+
if (auto floatType = mlir::dyn_cast<cir::FPTypeInterface>(eltTy))
138+
return floatType.getWidth();
139+
140+
llvm_unreachable("Unsupported type in getCIRIntOrFloatBitWidth");
141+
}
134142
cir::IntType getSIntNTy(int n) {
135143
return cir::IntType::get(getContext(), n, true);
136144
}
@@ -565,6 +573,16 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
565573
return cir::CmpOp::create(*this, loc, getBoolTy(), kind, lhs, rhs);
566574
}
567575

576+
cir::VecCmpOp createVecCompare(mlir::Location loc, cir::CmpOpKind kind,
577+
mlir::Value lhs, mlir::Value rhs) {
578+
VectorType vecCast = mlir::cast<VectorType>(lhs.getType());
579+
IntType integralTy =
580+
getSIntNTy(getCIRIntOrFloatBitWidth(vecCast.getElementType()));
581+
VectorType integralVecTy =
582+
VectorType::get(context, integralTy, vecCast.getSize());
583+
return cir::VecCmpOp::create(*this, loc, integralVecTy, kind, lhs, rhs);
584+
}
585+
568586
mlir::Value createIsNaN(mlir::Location loc, mlir::Value operand) {
569587
return createCompare(loc, cir::CmpOpKind::ne, operand, operand);
570588
}

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ struct MissingFeatures {
259259
static bool emitBranchThroughCleanup() { return false; }
260260
static bool emitCheckedInBoundsGEP() { return false; }
261261
static bool emitCondLikelihoodViaExpectIntrinsic() { return false; }
262+
static bool emitConstrainedFPCall() { return false; }
262263
static bool emitLifetimeMarkers() { return false; }
263264
static bool emitLValueAlignmentAssumption() { return false; }
264265
static bool emitNullCheckForDeleteCalls() { return false; }

clang/include/clang/Options/Options.td

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ def hlsl_Group : OptionGroup<"<HLSL group>">, Group<f_Group>,
201201
DocName<"HLSL options">,
202202
Visibility<[ClangOption]>;
203203

204+
def fsan_cov_Group : OptionGroup<"<-fsanitize-coverage group>">,
205+
Group<f_clang_Group>,
206+
DocName<"Sanitizer Coverage options">;
207+
204208
// Feature groups - these take command line options that correspond directly to
205209
// target specific features and can be translated directly from command line
206210
// options.
@@ -2413,26 +2417,26 @@ def : Flag<["-"], "fno-sanitize-blacklist">,
24132417
Group<f_clang_Group>, Flags<[HelpHidden]>, Alias<fno_sanitize_ignorelist>;
24142418

24152419
def fsanitize_coverage : CommaJoined<["-"], "fsanitize-coverage=">,
2416-
Group<f_clang_Group>,
2420+
Group<fsan_cov_Group>,
24172421
HelpText<"Specify the type of coverage instrumentation for Sanitizers">;
24182422
def fno_sanitize_coverage : CommaJoined<["-"], "fno-sanitize-coverage=">,
2419-
Group<f_clang_Group>, Visibility<[ClangOption, CLOption]>,
2423+
Group<fsan_cov_Group>, Visibility<[ClangOption, CLOption]>,
24202424
HelpText<"Disable features of coverage instrumentation for Sanitizers">,
24212425
Values<"func,bb,edge,indirect-calls,trace-bb,trace-cmp,trace-div,trace-gep,"
24222426
"8bit-counters,trace-pc,trace-pc-guard,no-prune,inline-8bit-counters,"
24232427
"inline-bool-flag">;
24242428
def fsanitize_coverage_allowlist : Joined<["-"], "fsanitize-coverage-allowlist=">,
2425-
Group<f_clang_Group>, Visibility<[ClangOption, CLOption]>,
2429+
Group<fsan_cov_Group>, Visibility<[ClangOption, CLOption]>,
24262430
HelpText<"Restrict sanitizer coverage instrumentation exclusively to modules and functions that match the provided special case list, except the blocked ones">,
24272431
MarshallingInfoStringVector<CodeGenOpts<"SanitizeCoverageAllowlistFiles">>;
24282432
def fsanitize_coverage_ignorelist : Joined<["-"], "fsanitize-coverage-ignorelist=">,
2429-
Group<f_clang_Group>, Visibility<[ClangOption, CLOption]>,
2433+
Group<fsan_cov_Group>, Visibility<[ClangOption, CLOption]>,
24302434
HelpText<"Disable sanitizer coverage instrumentation for modules and functions "
24312435
"that match the provided special case list, even the allowed ones">,
24322436
MarshallingInfoStringVector<CodeGenOpts<"SanitizeCoverageIgnorelistFiles">>;
24332437
def fsanitize_coverage_stack_depth_callback_min_EQ
24342438
: Joined<["-"], "fsanitize-coverage-stack-depth-callback-min=">,
2435-
Group<f_clang_Group>,
2439+
Group<fsan_cov_Group>,
24362440
MetaVarName<"<M>">,
24372441
HelpText<"Use callback for max stack depth tracing with minimum stack "
24382442
"depth M">,
@@ -8068,70 +8072,87 @@ def linker_option : Joined<["--"], "linker-option=">,
80688072
HelpText<"Add linker option">,
80698073
MarshallingInfoStringVector<CodeGenOpts<"LinkerOptions">>;
80708074
def fsanitize_coverage_type : Joined<["-"], "fsanitize-coverage-type=">,
8075+
Group<fsan_cov_Group>,
80718076
HelpText<"Sanitizer coverage type">,
80728077
MarshallingInfoInt<CodeGenOpts<"SanitizeCoverageType">>;
80738078
def fsanitize_coverage_indirect_calls
80748079
: Flag<["-"], "fsanitize-coverage-indirect-calls">,
8080+
Group<fsan_cov_Group>,
80758081
HelpText<"Enable sanitizer coverage for indirect calls">,
80768082
MarshallingInfoFlag<CodeGenOpts<"SanitizeCoverageIndirectCalls">>;
80778083
def fsanitize_coverage_trace_bb
80788084
: Flag<["-"], "fsanitize-coverage-trace-bb">,
8085+
Group<fsan_cov_Group>,
80798086
HelpText<"Enable basic block tracing in sanitizer coverage">,
80808087
MarshallingInfoFlag<CodeGenOpts<"SanitizeCoverageTraceBB">>;
80818088
def fsanitize_coverage_trace_cmp
80828089
: Flag<["-"], "fsanitize-coverage-trace-cmp">,
8090+
Group<fsan_cov_Group>,
80838091
HelpText<"Enable cmp instruction tracing in sanitizer coverage">,
80848092
MarshallingInfoFlag<CodeGenOpts<"SanitizeCoverageTraceCmp">>;
80858093
def fsanitize_coverage_trace_div
80868094
: Flag<["-"], "fsanitize-coverage-trace-div">,
8095+
Group<fsan_cov_Group>,
80878096
HelpText<"Enable div instruction tracing in sanitizer coverage">,
80888097
MarshallingInfoFlag<CodeGenOpts<"SanitizeCoverageTraceDiv">>;
80898098
def fsanitize_coverage_trace_gep
80908099
: Flag<["-"], "fsanitize-coverage-trace-gep">,
8100+
Group<fsan_cov_Group>,
80918101
HelpText<"Enable gep instruction tracing in sanitizer coverage">,
80928102
MarshallingInfoFlag<CodeGenOpts<"SanitizeCoverageTraceGep">>;
80938103
def fsanitize_coverage_8bit_counters
80948104
: Flag<["-"], "fsanitize-coverage-8bit-counters">,
8105+
Group<fsan_cov_Group>,
80958106
HelpText<"Enable frequency counters in sanitizer coverage">,
80968107
MarshallingInfoFlag<CodeGenOpts<"SanitizeCoverage8bitCounters">>;
80978108
def fsanitize_coverage_inline_8bit_counters
80988109
: Flag<["-"], "fsanitize-coverage-inline-8bit-counters">,
8110+
Group<fsan_cov_Group>,
80998111
HelpText<"Enable inline 8-bit counters in sanitizer coverage">,
81008112
MarshallingInfoFlag<CodeGenOpts<"SanitizeCoverageInline8bitCounters">>;
81018113
def fsanitize_coverage_inline_bool_flag
81028114
: Flag<["-"], "fsanitize-coverage-inline-bool-flag">,
8115+
Group<fsan_cov_Group>,
81038116
HelpText<"Enable inline bool flag in sanitizer coverage">,
81048117
MarshallingInfoFlag<CodeGenOpts<"SanitizeCoverageInlineBoolFlag">>;
81058118
def fsanitize_coverage_pc_table
81068119
: Flag<["-"], "fsanitize-coverage-pc-table">,
8120+
Group<fsan_cov_Group>,
81078121
HelpText<"Create a table of coverage-instrumented PCs">,
81088122
MarshallingInfoFlag<CodeGenOpts<"SanitizeCoveragePCTable">>;
81098123
def fsanitize_coverage_control_flow
81108124
: Flag<["-"], "fsanitize-coverage-control-flow">,
8125+
Group<fsan_cov_Group>,
81118126
HelpText<"Collect control flow of function">,
81128127
MarshallingInfoFlag<CodeGenOpts<"SanitizeCoverageControlFlow">>;
81138128
def fsanitize_coverage_trace_pc
81148129
: Flag<["-"], "fsanitize-coverage-trace-pc">,
8130+
Group<fsan_cov_Group>,
81158131
HelpText<"Enable PC tracing in sanitizer coverage">,
81168132
MarshallingInfoFlag<CodeGenOpts<"SanitizeCoverageTracePC">>;
81178133
def fsanitize_coverage_trace_pc_guard
81188134
: Flag<["-"], "fsanitize-coverage-trace-pc-guard">,
8135+
Group<fsan_cov_Group>,
81198136
HelpText<"Enable PC tracing with guard in sanitizer coverage">,
81208137
MarshallingInfoFlag<CodeGenOpts<"SanitizeCoverageTracePCGuard">>;
81218138
def fsanitize_coverage_no_prune
81228139
: Flag<["-"], "fsanitize-coverage-no-prune">,
8140+
Group<fsan_cov_Group>,
81238141
HelpText<"Disable coverage pruning (i.e. instrument all blocks/edges)">,
81248142
MarshallingInfoFlag<CodeGenOpts<"SanitizeCoverageNoPrune">>;
81258143
def fsanitize_coverage_stack_depth
81268144
: Flag<["-"], "fsanitize-coverage-stack-depth">,
8145+
Group<fsan_cov_Group>,
81278146
HelpText<"Enable max stack depth tracing">,
81288147
MarshallingInfoFlag<CodeGenOpts<"SanitizeCoverageStackDepth">>;
81298148
def fsanitize_coverage_trace_loads
81308149
: Flag<["-"], "fsanitize-coverage-trace-loads">,
8150+
Group<fsan_cov_Group>,
81318151
HelpText<"Enable tracing of loads">,
81328152
MarshallingInfoFlag<CodeGenOpts<"SanitizeCoverageTraceLoads">>;
81338153
def fsanitize_coverage_trace_stores
81348154
: Flag<["-"], "fsanitize-coverage-trace-stores">,
8155+
Group<fsan_cov_Group>,
81358156
HelpText<"Enable tracing of stores">,
81368157
MarshallingInfoFlag<CodeGenOpts<"SanitizeCoverageTraceStores">>;
81378158
def fexperimental_sanitize_metadata_EQ_covered

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6057,13 +6057,15 @@ bool Compiler<Emitter>::visitSwitchStmt(const SwitchStmt *S) {
60576057
DefaultLabel);
60586058
if (!this->visitStmt(S->getBody()))
60596059
return false;
6060+
this->fallthrough(EndLabel);
60606061
this->emitLabel(EndLabel);
60616062

60626063
return LS.destroyLocals();
60636064
}
60646065

60656066
template <class Emitter>
60666067
bool Compiler<Emitter>::visitCaseStmt(const CaseStmt *S) {
6068+
this->fallthrough(CaseLabels[S]);
60676069
this->emitLabel(CaseLabels[S]);
60686070
return this->visitStmt(S->getSubStmt());
60696071
}

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2838,6 +2838,30 @@ static bool interp__builtin_select(InterpState &S, CodePtr OpPC,
28382838
return true;
28392839
}
28402840

2841+
/// Scalar variant of AVX512 predicated select:
2842+
/// Result[i] = (Mask bit 0) ? LHS[i] : RHS[i], but only element 0 may change.
2843+
/// All other elements are taken from RHS.
2844+
static bool interp__builtin_select_scalar(InterpState &S,
2845+
const CallExpr *Call) {
2846+
unsigned N =
2847+
Call->getArg(1)->getType()->getAs<VectorType>()->getNumElements();
2848+
2849+
const Pointer &W = S.Stk.pop<Pointer>();
2850+
const Pointer &A = S.Stk.pop<Pointer>();
2851+
APSInt U = popToAPSInt(S, Call->getArg(0));
2852+
const Pointer &Dst = S.Stk.peek<Pointer>();
2853+
2854+
bool TakeA0 = U.getZExtValue() & 1ULL;
2855+
2856+
for (unsigned I = TakeA0; I != N; ++I)
2857+
Dst.elem<Floating>(I) = W.elem<Floating>(I);
2858+
if (TakeA0)
2859+
Dst.elem<Floating>(0) = A.elem<Floating>(0);
2860+
2861+
Dst.initializeAllElements();
2862+
return true;
2863+
}
2864+
28412865
static bool interp__builtin_blend(InterpState &S, CodePtr OpPC,
28422866
const CallExpr *Call) {
28432867
APSInt Mask = popToAPSInt(S, Call->getArg(2));
@@ -4151,6 +4175,11 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
41514175
return APInt::getAllOnes(DstBits);
41524176
});
41534177

4178+
case clang::X86::BI__builtin_ia32_selectss_128:
4179+
case clang::X86::BI__builtin_ia32_selectsd_128:
4180+
case clang::X86::BI__builtin_ia32_selectsh_128:
4181+
case clang::X86::BI__builtin_ia32_selectsbf_128:
4182+
return interp__builtin_select_scalar(S, Call);
41544183
case clang::X86::BI__builtin_ia32_vprotbi:
41554184
case clang::X86::BI__builtin_ia32_vprotdi:
41564185
case clang::X86::BI__builtin_ia32_vprotqi:

clang/lib/AST/ExprConstant.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12202,6 +12202,24 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) {
1220212202
return Success(APValue(ResultElements.data(), SourceLen), E);
1220312203
};
1220412204

12205+
auto EvalSelectScalar = [&](unsigned Len) -> bool {
12206+
APSInt Mask;
12207+
APValue AVal, WVal;
12208+
if (!EvaluateInteger(E->getArg(0), Mask, Info) ||
12209+
!EvaluateAsRValue(Info, E->getArg(1), AVal) ||
12210+
!EvaluateAsRValue(Info, E->getArg(2), WVal))
12211+
return false;
12212+
12213+
bool TakeA0 = (Mask.getZExtValue() & 1u) != 0;
12214+
SmallVector<APValue, 4> Res;
12215+
Res.reserve(Len);
12216+
Res.push_back(TakeA0 ? AVal.getVectorElt(0) : WVal.getVectorElt(0));
12217+
for (unsigned I = 1; I < Len; ++I)
12218+
Res.push_back(WVal.getVectorElt(I));
12219+
APValue V(Res.data(), Res.size());
12220+
return Success(V, E);
12221+
};
12222+
1220512223
switch (E->getBuiltinCallee()) {
1220612224
default:
1220712225
return false;
@@ -12505,6 +12523,13 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) {
1250512523
return APInt((Src).trunc(DstBits));
1250612524
return APInt::getAllOnes(DstBits);
1250712525
});
12526+
case clang::X86::BI__builtin_ia32_selectss_128:
12527+
return EvalSelectScalar(4);
12528+
case clang::X86::BI__builtin_ia32_selectsd_128:
12529+
return EvalSelectScalar(2);
12530+
case clang::X86::BI__builtin_ia32_selectsh_128:
12531+
case clang::X86::BI__builtin_ia32_selectsbf_128:
12532+
return EvalSelectScalar(8);
1250812533
case clang::X86::BI__builtin_ia32_pmuldq128:
1250912534
case clang::X86::BI__builtin_ia32_pmuldq256:
1251012535
case clang::X86::BI__builtin_ia32_pmuldq512:

0 commit comments

Comments
 (0)