Skip to content

Commit f5c9be1

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merge llvm/main into amd-debug
2 parents 62f9c3f + 5050a15 commit f5c9be1

File tree

56 files changed

+1438
-599
lines changed

Some content is hidden

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

56 files changed

+1438
-599
lines changed

clang/docs/LanguageExtensions.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,14 @@ of different sizes and signs is forbidden in binary and ternary builtins.
848848
semantics, see `LangRef
849849
<http://llvm.org/docs/LangRef.html#llvm-min-intrinsics-comparation>`_
850850
for the comparison.
851+
T __builtin_elementwise_maximumnum(T x, T y) return x or y, whichever is larger. Follows IEEE 754-2019 floating point types
852+
semantics, see `LangRef
853+
<http://llvm.org/docs/LangRef.html#llvm-min-intrinsics-comparation>`_
854+
for the comparison.
855+
T __builtin_elementwise_minimumnum(T x, T y) return x or y, whichever is smaller. Follows IEEE 754-2019 floating point types
856+
semantics, see `LangRef
857+
<http://llvm.org/docs/LangRef.html#llvm-min-intrinsics-comparation>`_
858+
for the comparison.
851859
============================================== ====================================================================== =========================================
852860

853861

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ Non-comprehensive list of changes in this release
344344
- Added `__builtin_elementwise_exp10`.
345345
- For AMDPGU targets, added `__builtin_v_cvt_off_f32_i4` that maps to the `v_cvt_off_f32_i4` instruction.
346346
- Added `__builtin_elementwise_minnum` and `__builtin_elementwise_maxnum`.
347+
- Added `__builtin_elementwise_minnumnum` and `__builtin_elementwise_maxnumnum`.
347348
- No longer crashing on invalid Objective-C categories and extensions when
348349
dumping the AST as JSON. (#GH137320)
349350
- Clang itself now uses split stacks instead of threads for allocating more

clang/include/clang/Basic/Builtins.td

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,18 @@ def ElementwiseMinimum : Builtin {
13341334
let Prototype = "void(...)";
13351335
}
13361336

1337+
def ElementwiseMaximumNum : Builtin {
1338+
let Spellings = ["__builtin_elementwise_maximumnum"];
1339+
let Attributes = [NoThrow, Const, CustomTypeChecking];
1340+
let Prototype = "void(...)";
1341+
}
1342+
1343+
def ElementwiseMinimumNum : Builtin {
1344+
let Spellings = ["__builtin_elementwise_minimumnum"];
1345+
let Attributes = [NoThrow, Const, CustomTypeChecking];
1346+
let Prototype = "void(...)";
1347+
}
1348+
13371349
def ElementwiseCeil : Builtin {
13381350
let Spellings = ["__builtin_elementwise_ceil"];
13391351
let Attributes = [NoThrow, Const, CustomTypeChecking];

clang/include/clang/Basic/CodeGenOptions.def

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,10 @@ CODEGENOPT(SpeculativeLoadHardening, 1, 0, Benign) ///< Enable speculative load
313313
CODEGENOPT(FineGrainedBitfieldAccesses, 1, 0, Benign) ///< Enable fine-grained bitfield accesses.
314314
CODEGENOPT(StrictEnums , 1, 0, Benign) ///< Optimize based on strict enum definition.
315315
CODEGENOPT(StrictVTablePointers, 1, 0, Benign) ///< Optimize based on the strict vtable pointers
316-
CODEGENOPT(TimePasses , 1, 0, Benign) ///< Set when -ftime-report or -ftime-report= or -ftime-report-json is enabled.
316+
CODEGENOPT(TimePasses , 1, 0, Benign) ///< Set when -ftime-report, -ftime-report=, -ftime-report-json, or -stats-file-timers is enabled.
317317
CODEGENOPT(TimePassesPerRun , 1, 0, Benign) ///< Set when -ftime-report=per-pass-run is enabled.
318318
CODEGENOPT(TimePassesJson , 1, 0, Benign) ///< Set when -ftime-report-json is enabled.
319+
CODEGENOPT(TimePassesStatsFile , 1, 0, Benign) ///< Set when -stats-file-timers is enabled.
319320
CODEGENOPT(TimeTrace , 1, 0, Benign) ///< Set when -ftime-trace is enabled.
320321
VALUE_CODEGENOPT(TimeTraceGranularity, 32, 500, Benign) ///< Minimum time granularity (in microseconds),
321322
///< traced by time profiler

clang/include/clang/Driver/Options.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8278,6 +8278,9 @@ def stats_file : Joined<["-"], "stats-file=">,
82788278
def stats_file_append : Flag<["-"], "stats-file-append">,
82798279
HelpText<"If stats should be appended to stats-file instead of overwriting it">,
82808280
MarshallingInfoFlag<FrontendOpts<"AppendStats">>;
8281+
def stats_file_timers : Flag<["-"], "stats-file-timers">,
8282+
HelpText<"If stats should include timers.">,
8283+
MarshallingInfoFlag<CodeGenOpts<"TimePassesStatsFile">>;
82818284
def fdump_record_layouts_simple : Flag<["-"], "fdump-record-layouts-simple">,
82828285
HelpText<"Dump record layout information in a simple form used for testing">,
82838286
MarshallingInfoFlag<LangOpts<"DumpRecordLayoutsSimple">>;

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 50 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,34 +25,6 @@ using APSInt = llvm::APSInt;
2525
namespace clang {
2626
namespace interp {
2727

28-
static bool refersToUnion(const Expr *E) {
29-
for (;;) {
30-
if (const auto *ME = dyn_cast<MemberExpr>(E)) {
31-
if (const auto *FD = dyn_cast<FieldDecl>(ME->getMemberDecl());
32-
FD && FD->getParent()->isUnion())
33-
return true;
34-
E = ME->getBase();
35-
continue;
36-
}
37-
38-
if (const auto *ASE = dyn_cast<ArraySubscriptExpr>(E)) {
39-
E = ASE->getBase()->IgnoreImplicit();
40-
continue;
41-
}
42-
43-
if (const auto *ICE = dyn_cast<ImplicitCastExpr>(E);
44-
ICE && (ICE->getCastKind() == CK_NoOp ||
45-
ICE->getCastKind() == CK_DerivedToBase ||
46-
ICE->getCastKind() == CK_UncheckedDerivedToBase)) {
47-
E = ICE->getSubExpr();
48-
continue;
49-
}
50-
51-
break;
52-
}
53-
return false;
54-
}
55-
5628
static std::optional<bool> getBoolValue(const Expr *E) {
5729
if (const auto *CE = dyn_cast_if_present<ConstantExpr>(E);
5830
CE && CE->hasAPValueResult() &&
@@ -5401,6 +5373,53 @@ bool Compiler<Emitter>::maybeEmitDeferredVarInit(const VarDecl *VD) {
54015373
return true;
54025374
}
54035375

5376+
static bool hasTrivialDefaultCtorParent(const FieldDecl *FD) {
5377+
assert(FD);
5378+
assert(FD->getParent()->isUnion());
5379+
const auto *CXXRD = dyn_cast<CXXRecordDecl>(FD->getParent());
5380+
return !CXXRD || CXXRD->hasTrivialDefaultConstructor();
5381+
}
5382+
5383+
template <class Emitter> bool Compiler<Emitter>::refersToUnion(const Expr *E) {
5384+
for (;;) {
5385+
if (const auto *ME = dyn_cast<MemberExpr>(E)) {
5386+
if (const auto *FD = dyn_cast<FieldDecl>(ME->getMemberDecl());
5387+
FD && FD->getParent()->isUnion() && hasTrivialDefaultCtorParent(FD))
5388+
return true;
5389+
E = ME->getBase();
5390+
continue;
5391+
}
5392+
5393+
if (const auto *ASE = dyn_cast<ArraySubscriptExpr>(E)) {
5394+
E = ASE->getBase()->IgnoreImplicit();
5395+
continue;
5396+
}
5397+
5398+
if (const auto *ICE = dyn_cast<ImplicitCastExpr>(E);
5399+
ICE && (ICE->getCastKind() == CK_NoOp ||
5400+
ICE->getCastKind() == CK_DerivedToBase ||
5401+
ICE->getCastKind() == CK_UncheckedDerivedToBase)) {
5402+
E = ICE->getSubExpr();
5403+
continue;
5404+
}
5405+
5406+
if (const auto *This = dyn_cast<CXXThisExpr>(E)) {
5407+
const auto *ThisRecord =
5408+
This->getType()->getPointeeType()->getAsRecordDecl();
5409+
if (!ThisRecord->isUnion())
5410+
return false;
5411+
// Otherwise, always activate if we're in the ctor.
5412+
if (const auto *Ctor =
5413+
dyn_cast_if_present<CXXConstructorDecl>(CompilingFunction))
5414+
return Ctor->getParent() == ThisRecord;
5415+
return false;
5416+
}
5417+
5418+
break;
5419+
}
5420+
return false;
5421+
}
5422+
54045423
template <class Emitter>
54055424
bool Compiler<Emitter>::visitDeclStmt(const DeclStmt *DS,
54065425
bool EvaluateConditionDecl) {
@@ -5933,16 +5952,15 @@ bool Compiler<Emitter>::compileConstructor(const CXXConstructorDecl *Ctor) {
59335952
return false;
59345953

59355954
if (OptPrimType T = this->classify(InitExpr)) {
5955+
if (Activate && !this->emitActivateThisField(FieldOffset, InitExpr))
5956+
return false;
5957+
59365958
if (!this->visit(InitExpr))
59375959
return false;
59385960

59395961
bool BitField = F->isBitField();
5940-
if (BitField && Activate)
5941-
return this->emitInitThisBitFieldActivate(*T, F, FieldOffset, InitExpr);
59425962
if (BitField)
59435963
return this->emitInitThisBitField(*T, F, FieldOffset, InitExpr);
5944-
if (Activate)
5945-
return this->emitInitThisFieldActivate(*T, FieldOffset, InitExpr);
59465964
return this->emitInitThisField(*T, FieldOffset, InitExpr);
59475965
}
59485966
// Non-primitive case. Get a pointer to the field-to-initialize

clang/lib/AST/ByteCode/Compiler.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,8 @@ class Compiler : public ConstStmtVisitor<Compiler<Emitter>, bool>,
401401
bool checkLiteralType(const Expr *E);
402402
bool maybeEmitDeferredVarInit(const VarDecl *VD);
403403

404+
bool refersToUnion(const Expr *E);
405+
404406
protected:
405407
/// Variable to storage mapping.
406408
llvm::DenseMap<const ValueDecl *, Scope::Local> Locals;

clang/lib/AST/ByteCode/Interp.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1983,6 +1983,16 @@ static inline bool Activate(InterpState &S, CodePtr OpPC) {
19831983
return true;
19841984
}
19851985

1986+
static inline bool ActivateThisField(InterpState &S, CodePtr OpPC, uint32_t I) {
1987+
if (S.checkingPotentialConstantExpression())
1988+
return false;
1989+
1990+
const Pointer &Ptr = S.Current->getThis();
1991+
assert(Ptr.atField(I).canBeInitialized());
1992+
Ptr.atField(I).activate();
1993+
return true;
1994+
}
1995+
19861996
template <PrimType Name, class T = typename PrimConv<Name>::T>
19871997
bool StoreActivate(InterpState &S, CodePtr OpPC) {
19881998
const T &Value = S.Stk.pop<T>();

clang/lib/AST/ByteCode/Opcodes.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@ def StoreBitFieldActivate : StoreBitFieldOpcode {}
510510
def StoreBitFieldActivatePop : StoreBitFieldOpcode {}
511511

512512
def Activate : Opcode {}
513+
def ActivateThisField : Opcode { let Args = [ArgUint32]; }
513514

514515
// [Pointer, Value] -> []
515516
def Init : StoreOpcode {}

clang/lib/Basic/TargetInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : Triple(T) {
172172
ComplexLongDoubleUsesFP2Ret = false;
173173

174174
// Set the C++ ABI based on the triple.
175-
TheCXXABI.set(Triple.isKnownWindowsMSVCEnvironment()
175+
TheCXXABI.set(Triple.isKnownWindowsMSVCEnvironment() || Triple.isUEFI()
176176
? TargetCXXABI::Microsoft
177177
: TargetCXXABI::GenericItanium);
178178

0 commit comments

Comments
 (0)