Skip to content

Commit ba30e37

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#3411)
2 parents 7d8d6d7 + c1d06f2 commit ba30e37

File tree

113 files changed

+1561
-1320
lines changed

Some content is hidden

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

113 files changed

+1561
-1320
lines changed

clang/lib/Analysis/LifetimeSafety.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,8 @@ class DataflowAnalysis {
603603
OutStates[B] = StateOut;
604604
Visited.set(B->getBlockID());
605605
for (const CFGBlock *AdjacentB : isForward() ? B->succs() : B->preds()) {
606+
if (!AdjacentB)
607+
continue;
606608
Lattice OldInState = getInState(AdjacentB);
607609
Lattice NewInState = D.join(OldInState, StateOut);
608610
// Enqueue the adjacent block if its in-state has changed or if we have

clang/unittests/Analysis/LifetimeSafetyTest.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,25 @@ TEST_F(LifetimeAnalysisTest, PointersAndExpirationInACycle) {
512512
EXPECT_THAT(LoansTo({"temp"}), AreExpiredAt("after_loop"));
513513
}
514514

515+
TEST_F(LifetimeAnalysisTest, InfiniteLoopPrunesEdges) {
516+
SetupTest(R"(
517+
void target(MyObj out) {
518+
MyObj *p = &out;
519+
POINT(before_loop);
520+
521+
for (;;) {
522+
POINT(begin);
523+
MyObj in;
524+
p = ∈
525+
POINT(end);
526+
}
527+
}
528+
)");
529+
EXPECT_THAT(Origin("p"), HasLoansTo({"out"}, "before_loop"));
530+
EXPECT_THAT(Origin("p"), HasLoansTo({"in", "out"}, "begin"));
531+
EXPECT_THAT(Origin("p"), HasLoansTo({"in"}, "end"));
532+
}
533+
515534
TEST_F(LifetimeAnalysisTest, NestedScopes) {
516535
SetupTest(R"(
517536
void target() {

lld/ELF/Relocations.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2151,15 +2151,14 @@ static int getHexagonPacketOffset(const InputSection &isec,
21512151
for (unsigned i = 0;; i++) {
21522152
if (i == 3 || rel.offset < (i + 1) * 4)
21532153
return i * 4;
2154-
uint32_t instWord = 0;
2155-
const ArrayRef<uint8_t> instWordContents =
2156-
data.drop_front(rel.offset - (i + 1) * 4);
2157-
memcpy(&instWord, instWordContents.data(), sizeof(instWord));
2154+
uint32_t instWord =
2155+
read32(isec.getCtx(), data.data() + (rel.offset - (i + 1) * 4));
21582156
if (((instWord & HEXAGON_MASK_END_PACKET) == HEXAGON_END_OF_PACKET) ||
21592157
((instWord & HEXAGON_MASK_END_PACKET) == HEXAGON_END_OF_DUPLEX))
21602158
return i * 4;
21612159
}
21622160
}
2161+
21632162
static int64_t getPCBias(Ctx &ctx, const InputSection &isec,
21642163
const Relocation &rel) {
21652164
if (ctx.arg.emachine == EM_ARM) {

llvm/include/llvm/IR/RuntimeLibcalls.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,6 @@ struct RuntimeLibcallsInfo {
137137
LLVM_ABI RTLIB::LibcallImpl getSupportedLibcallImpl(StringRef FuncName) const;
138138

139139
private:
140-
static const RTLIB::LibcallImpl
141-
DefaultLibcallImpls[RTLIB::UNKNOWN_LIBCALL + 1];
142-
143140
/// Stores the implementation choice for each each libcall.
144141
RTLIB::LibcallImpl LibcallImpls[RTLIB::UNKNOWN_LIBCALL + 1] = {
145142
RTLIB::Unsupported};
@@ -197,8 +194,6 @@ struct RuntimeLibcallsInfo {
197194
return hasSinCos(TT) || TT.isPS();
198195
}
199196

200-
LLVM_ABI void initDefaultLibCallImpls();
201-
202197
/// Generated by tablegen.
203198
void setTargetRuntimeLibcallSets(const Triple &TT,
204199
FloatABI::ABIType FloatABI);

llvm/include/llvm/IR/RuntimeLibcalls.td

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,7 +1610,9 @@ def HexagonSystemLibrary
16101610
(add (sub DefaultLibcallImpls32,
16111611
__adddf3, __divsf3, __udivsi3, __udivdi3,
16121612
__umoddi3, __divdf3, __muldf3, __divsi3, __subdf3, sqrtf,
1613-
__divdi3, __umodsi3, __moddi3, __modsi3), HexagonLibcalls)>;
1613+
__divdi3, __umodsi3, __moddi3, __modsi3), HexagonLibcalls,
1614+
LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
1615+
exp10f, exp10, exp10l_f128)>;
16141616

16151617
//===----------------------------------------------------------------------===//
16161618
// Lanai Runtime Libcalls
@@ -1823,6 +1825,7 @@ defvar MSP430DefaultOptOut = [
18231825
def MSP430SystemLibrary
18241826
: SystemRuntimeLibrary<isMSP430,
18251827
(add (sub DefaultRuntimeLibcallImpls, MSP430DefaultOptOut),
1828+
exp10f, exp10, exp10l_f128,
18261829

18271830
// Floating point conversions - EABI Table 6
18281831
__mspabi_cvtdf,
@@ -2168,8 +2171,12 @@ def __memcpy_4 : RuntimeLibcallImpl<MEMCPY_ALIGN_4>;
21682171

21692172
def isXCore : RuntimeLibcallPredicate<"TT.getArch() == Triple::xcore">;
21702173
def XCoreSystemLibrary
2171-
: SystemRuntimeLibrary<isXCore, (add DefaultRuntimeLibcallImpls,
2172-
__memcpy_4)>;
2174+
: SystemRuntimeLibrary<isXCore,
2175+
(add DefaultRuntimeLibcallImpls,
2176+
exp10f, exp10, exp10l_f128,
2177+
__memcpy_4,
2178+
LibcallImpls<(add LibmF128Libcalls, LibmF128FiniteLibcalls), isGNUEnvironment>
2179+
)>;
21732180

21742181
//===----------------------------------------------------------------------===//
21752182
// ZOS Runtime Libcalls
@@ -2286,3 +2293,26 @@ def WasmSystemLibrary
22862293
CompilerRTOnlyInt64Libcalls, CompilerRTOnlyInt128Libcalls,
22872294
exp10f, exp10,
22882295
emscripten_return_address)>;
2296+
2297+
//===----------------------------------------------------------------------===//
2298+
// Legacy Default Runtime Libcalls
2299+
//===----------------------------------------------------------------------===//
2300+
2301+
// TODO: Should make every target explicit.
2302+
def isDefaultLibcallArch : RuntimeLibcallPredicate<[{
2303+
TT.isMIPS() || TT.isLoongArch() || TT.isVE() || TT.isBPF() ||
2304+
TT.getArch() == Triple::csky || TT.getArch() == Triple::arc ||
2305+
TT.getArch() == Triple::m68k || TT.getArch() == Triple::xtensa ||
2306+
(TT.isSystemZ() && !TT.isOSzOS())
2307+
}]>;
2308+
2309+
2310+
def isArch64Bit : RuntimeLibcallPredicate<[{TT.isArch64Bit()}]>;
2311+
def LegacyDefaultSystemLibrary
2312+
: SystemRuntimeLibrary<isDefaultLibcallArch,
2313+
(add DefaultRuntimeLibcallImpls,
2314+
LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
2315+
exp10f, exp10, exp10l_f128,
2316+
__powisf2, __powidf2, __powitf2_f128,
2317+
LibcallImpls<(add Int128RTLibcalls), isArch64Bit>
2318+
)>;

llvm/include/llvm/MC/MCCodeView.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ class CodeViewContext {
203203
void encodeInlineLineTable(const MCAssembler &Asm,
204204
MCCVInlineLineTableFragment &F);
205205

206-
MCFragment *
206+
void
207207
emitDefRange(MCObjectStreamer &OS,
208208
ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
209209
StringRef FixedSizePortion);

llvm/include/llvm/MC/MCContext.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,9 @@ class MCContext {
390390
LLVM_ABI ~MCContext();
391391

392392
Environment getObjectFileType() const { return Env; }
393+
bool isELF() const { return Env == IsELF; }
394+
bool isMachO() const { return Env == IsMachO; }
395+
bool isXCOFF() const { return Env == IsXCOFF; }
393396

394397
const StringRef &getSwift5ReflectionSegmentName() const {
395398
return Swift5ReflectionSegmentName;
@@ -434,11 +437,6 @@ class MCContext {
434437
/// Create and return a new MC instruction.
435438
LLVM_ABI MCInst *createMCInst();
436439

437-
template <typename F, typename... Args> F *allocFragment(Args &&...args) {
438-
return new (FragmentAllocator.Allocate(sizeof(F), alignof(F)))
439-
F(std::forward<Args>(args)...);
440-
}
441-
442440
/// \name Symbol Management
443441
/// @{
444442

llvm/include/llvm/MC/MCObjectStreamer.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ class MCObjectStreamer : public MCStreamer {
5555
SmallVector<std::unique_ptr<uint8_t[]>, 0> FragStorage;
5656
// Available bytes in the current block for trailing data or new fragments.
5757
size_t FragSpace = 0;
58+
// Used to allocate special fragments that do not use MCFragment's fixed-size
59+
// part.
60+
BumpPtrAllocator SpecialFragAllocator;
5861

62+
void addSpecialFragment(MCFragment *F);
5963
void emitInstToData(const MCInst &Inst, const MCSubtargetInfo &);
6064
void emitCFIStartProcImpl(MCDwarfFrameInfo &Frame) override;
6165
void emitCFIEndProcImpl(MCDwarfFrameInfo &Frame) override;
@@ -85,16 +89,23 @@ class MCObjectStreamer : public MCStreamer {
8589
/// \name MCStreamer Interface
8690
/// @{
8791

88-
// Add a fragment with a variable-size tail and start a new empty fragment.
89-
void insert(MCFragment *F);
90-
9192
uint8_t *getCurFragEnd() const {
9293
return reinterpret_cast<uint8_t *>(CurFrag + 1) + CurFrag->getFixedSize();
9394
}
9495
MCFragment *allocFragSpace(size_t Headroom);
9596
// Add a new fragment to the current section without a variable-size tail.
9697
void newFragment();
9798

99+
// Add a new special fragment to the current section and start a new empty
100+
// fragment.
101+
template <typename FT, typename... Args>
102+
FT *newSpecialFragment(Args &&...args) {
103+
auto *F = new (SpecialFragAllocator.Allocate(sizeof(FT), alignof(FT)))
104+
FT(std::forward<Args>(args)...);
105+
addSpecialFragment(F);
106+
return F;
107+
}
108+
98109
void ensureHeadroom(size_t Headroom);
99110
void appendContents(ArrayRef<char> Contents);
100111
void appendContents(size_t Num, uint8_t Elt);

llvm/include/llvm/MC/MCSymbol.h

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,6 @@ class raw_ostream;
4141
/// it is a reference to an external entity, it has a null section.
4242
class MCSymbol {
4343
protected:
44-
/// The kind of the symbol. If it is any value other than unset then this
45-
/// class is actually one of the appropriate subclasses of MCSymbol.
46-
enum SymbolKind {
47-
SymbolKindUnset,
48-
SymbolKindCOFF,
49-
SymbolKindELF,
50-
SymbolKindGOFF,
51-
SymbolKindMachO,
52-
SymbolKindWasm,
53-
SymbolKindXCOFF,
54-
};
55-
5644
/// A symbol can contain an Offset, or Value, or be Common, but never more
5745
/// than one of these.
5846
enum Contents : uint8_t {
@@ -103,10 +91,6 @@ class MCSymbol {
10391
/// This symbol is weak external.
10492
mutable unsigned IsWeakExternal : 1;
10593

106-
/// LLVM RTTI discriminator. This is actually a SymbolKind enumerator, but is
107-
/// unsigned to avoid sign extension and achieve better bitpacking with MSVC.
108-
unsigned Kind : 3;
109-
11094
/// True if we have created a relocation that uses this symbol.
11195
mutable unsigned IsUsedInReloc : 1;
11296

@@ -162,11 +146,11 @@ class MCSymbol {
162146
uint64_t AlignmentPadding;
163147
};
164148

165-
MCSymbol(SymbolKind Kind, const MCSymbolTableEntry *Name, bool isTemporary)
149+
MCSymbol(const MCSymbolTableEntry *Name, bool isTemporary)
166150
: IsTemporary(isTemporary), IsRedefinable(false), IsRegistered(false),
167151
IsExternal(false), IsPrivateExtern(false), IsWeakExternal(false),
168-
Kind(Kind), IsUsedInReloc(false), IsResolving(0),
169-
SymbolContents(SymContentsUnset), CommonAlignLog2(0), Flags(0) {
152+
IsUsedInReloc(false), IsResolving(0), SymbolContents(SymContentsUnset),
153+
CommonAlignLog2(0), Flags(0) {
170154
Offset = 0;
171155
HasName = !!Name;
172156
if (Name)
@@ -281,18 +265,6 @@ class MCSymbol {
281265
/// Mark the symbol as undefined.
282266
void setUndefined() { Fragment = nullptr; }
283267

284-
bool isELF() const { return Kind == SymbolKindELF; }
285-
286-
bool isCOFF() const { return Kind == SymbolKindCOFF; }
287-
288-
bool isGOFF() const { return Kind == SymbolKindGOFF; }
289-
290-
bool isMachO() const { return Kind == SymbolKindMachO; }
291-
292-
bool isWasm() const { return Kind == SymbolKindWasm; }
293-
294-
bool isXCOFF() const { return Kind == SymbolKindXCOFF; }
295-
296268
/// @}
297269
/// \name Variable Symbols
298270
/// @{

llvm/include/llvm/MC/MCSymbolCOFF.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class MCSymbolCOFF : public MCSymbol {
3131

3232
public:
3333
MCSymbolCOFF(const MCSymbolTableEntry *Name, bool isTemporary)
34-
: MCSymbol(SymbolKindCOFF, Name, isTemporary) {}
34+
: MCSymbol(Name, isTemporary) {}
3535

3636
uint16_t getType() const {
3737
return Type;
@@ -65,8 +65,6 @@ class MCSymbolCOFF : public MCSymbol {
6565
void setIsSafeSEH() const {
6666
modifyFlags(SF_SafeSEH, SF_SafeSEH);
6767
}
68-
69-
static bool classof(const MCSymbol *S) { return S->isCOFF(); }
7068
};
7169

7270
} // end namespace llvm

0 commit comments

Comments
 (0)