Skip to content

Commit 5f71256

Browse files
SC llvm teamSC llvm team
SC llvm team
authored and
SC llvm team
committed
Merged main:8daba2c13dc3 into amd-gfx:2432d11e497d
Local branch amd-gfx 2432d11 Merged main:dd577c05ad0d into amd-gfx:7e1b5aab3054 Remote branch main 8daba2c Skip negative length while inferring initializes attr (llvm#120874)
2 parents 2432d11 + 8daba2c commit 5f71256

35 files changed

+110
-105
lines changed

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 522261
19+
#define LLVM_MAIN_REVISION 522271
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

llvm/include/llvm/ExecutionEngine/Orc/LazyReexports.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ class LazyReexportsManager : public ResourceManager {
230230
EmitTrampolinesFn EmitTrampolines;
231231
RedirectableSymbolManager &RSMgr;
232232

233-
DenseMap<ResourceKey, std::vector<ExecutorAddr>> KeyToReentryAddr;
233+
DenseMap<ResourceKey, std::vector<ExecutorAddr>> KeyToReentryAddrs;
234234
DenseMap<ExecutorAddr, CallThroughInfo> CallThroughs;
235235
};
236236

llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,5 +642,39 @@ COFFLinkGraphBuilder::exportCOMDATSymbol(COFFSymbolIndex SymIndex,
642642
return GSym;
643643
}
644644

645+
Symbol *GetImageBaseSymbol::operator()(LinkGraph &G) {
646+
if (ImageBase)
647+
return *ImageBase;
648+
649+
auto IBN = G.intern(ImageBaseName);
650+
651+
// Check external symbols for image base.
652+
for (auto *Sym : G.external_symbols()) {
653+
if (Sym->getName() == IBN) {
654+
ImageBase = Sym;
655+
return Sym;
656+
}
657+
}
658+
659+
// Check absolute symbols (unexpected, but legal).
660+
for (auto *Sym : G.absolute_symbols()) {
661+
if (Sym->getName() == IBN) {
662+
ImageBase = Sym;
663+
return Sym;
664+
}
665+
}
666+
667+
// Finally, check defined symbols.
668+
for (auto *Sym : G.defined_symbols()) {
669+
if (Sym->hasName() && Sym->getName() == IBN) {
670+
ImageBase = Sym;
671+
return Sym;
672+
}
673+
}
674+
675+
ImageBase = nullptr;
676+
return nullptr;
677+
}
678+
645679
} // namespace jitlink
646680
} // namespace llvm

llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ class COFFLinkGraphBuilder {
7979
return GraphBlocks[SecIndex];
8080
}
8181

82+
Symbol &addImageBaseSymbol(StringRef Name = "__ImageBase") {
83+
auto &ImageBase = G->addExternalSymbol(G->intern(Name), 0, true);
84+
ImageBase.setLive(true);
85+
return ImageBase;
86+
}
87+
8288
object::COFFObjectFile::section_iterator_range sections() const {
8389
return Obj.sections();
8490
}
@@ -216,6 +222,18 @@ Error COFFLinkGraphBuilder::forEachRelocation(const object::SectionRef &RelSec,
216222
return Error::success();
217223
}
218224

225+
class GetImageBaseSymbol {
226+
public:
227+
GetImageBaseSymbol(StringRef ImageBaseName = "__ImageBase")
228+
: ImageBaseName(ImageBaseName) {}
229+
Symbol *operator()(LinkGraph &G);
230+
void reset() { ImageBase = std::nullopt; }
231+
232+
private:
233+
StringRef ImageBaseName;
234+
std::optional<Symbol *> ImageBase;
235+
};
236+
219237
} // end namespace jitlink
220238
} // end namespace llvm
221239

llvm/lib/ExecutionEngine/JITLink/COFF_x86_64.cpp

Lines changed: 10 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,12 @@ class COFFLinkGraphBuilder_x86_64 : public COFFLinkGraphBuilder {
9393

9494
Edge::Kind Kind = Edge::Invalid;
9595
const char *FixupPtr = BlockToFix.getContent().data() + Offset;
96+
Symbol *ImageBase = GetImageBaseSymbol()(getGraph());
9697

9798
switch (Rel.getType()) {
9899
case COFF::RelocationTypeAMD64::IMAGE_REL_AMD64_ADDR32NB: {
100+
if (!ImageBase)
101+
ImageBase = &addImageBaseSymbol();
99102
Kind = EdgeKind_coff_x86_64::Pointer32NB;
100103
Addend = *reinterpret_cast<const support::little32_t *>(FixupPtr);
101104
break;
@@ -192,20 +195,15 @@ class COFFLinkGraphBuilder_x86_64 : public COFFLinkGraphBuilder {
192195

193196
class COFFLinkGraphLowering_x86_64 {
194197
public:
195-
COFFLinkGraphLowering_x86_64(std::shared_ptr<orc::SymbolStringPool> SSP)
196-
: SSP(std::move(SSP)) {
197-
ImageBaseName = this->SSP->intern("__ImageBase");
198-
}
199198
// Lowers COFF x86_64 specific edges to generic x86_64 edges.
200-
Error lowerCOFFRelocationEdges(LinkGraph &G, JITLinkContext &Ctx) {
199+
Error operator()(LinkGraph &G) {
201200
for (auto *B : G.blocks()) {
202201
for (auto &E : B->edges()) {
203202
switch (E.getKind()) {
204203
case EdgeKind_coff_x86_64::Pointer32NB: {
205-
auto ImageBase = getImageBaseAddress(G, Ctx);
206-
if (!ImageBase)
207-
return ImageBase.takeError();
208-
E.setAddend(E.getAddend() - ImageBase->getValue());
204+
auto ImageBase = GetImageBase(G);
205+
assert(ImageBase && "__ImageBase symbol must be defined");
206+
E.setAddend(E.getAddend() - ImageBase->getAddress().getValue());
209207
E.setKind(x86_64::Pointer32);
210208
break;
211209
}
@@ -237,61 +235,18 @@ class COFFLinkGraphLowering_x86_64 {
237235
}
238236

239237
private:
240-
const orc::SymbolStringPtr &getImageBaseSymbolName() const {
241-
return this->ImageBaseName;
242-
}
243-
244238
orc::ExecutorAddr getSectionStart(Section &Sec) {
245239
if (!SectionStartCache.count(&Sec)) {
246240
SectionRange Range(Sec);
247241
SectionStartCache[&Sec] = Range.getStart();
242+
return Range.getStart();
248243
}
249244
return SectionStartCache[&Sec];
250245
}
251246

252-
Expected<orc::ExecutorAddr> getImageBaseAddress(LinkGraph &G,
253-
JITLinkContext &Ctx) {
254-
if (this->ImageBase)
255-
return this->ImageBase;
256-
for (auto *S : G.defined_symbols())
257-
if (S->getName() == getImageBaseSymbolName()) {
258-
this->ImageBase = S->getAddress();
259-
return this->ImageBase;
260-
}
261-
262-
JITLinkContext::LookupMap Symbols;
263-
Symbols[getImageBaseSymbolName()] = SymbolLookupFlags::RequiredSymbol;
264-
orc::ExecutorAddr ImageBase;
265-
Error Err = Error::success();
266-
Ctx.lookup(Symbols,
267-
createLookupContinuation([&](Expected<AsyncLookupResult> LR) {
268-
ErrorAsOutParameter _(Err);
269-
if (!LR) {
270-
Err = LR.takeError();
271-
return;
272-
}
273-
ImageBase = LR->begin()->second.getAddress();
274-
}));
275-
if (Err)
276-
return std::move(Err);
277-
this->ImageBase = ImageBase;
278-
return ImageBase;
279-
}
280-
247+
GetImageBaseSymbol GetImageBase;
281248
DenseMap<Section *, orc::ExecutorAddr> SectionStartCache;
282-
orc::ExecutorAddr ImageBase;
283-
std::shared_ptr<orc::SymbolStringPool> SSP;
284-
orc::SymbolStringPtr ImageBaseName = nullptr;
285249
};
286-
287-
Error lowerEdges_COFF_x86_64(LinkGraph &G, JITLinkContext *Ctx) {
288-
LLVM_DEBUG(dbgs() << "Lowering COFF x86_64 edges:\n");
289-
COFFLinkGraphLowering_x86_64 GraphLowering(G.getSymbolStringPool());
290-
if (auto Err = GraphLowering.lowerCOFFRelocationEdges(G, *Ctx))
291-
return Err;
292-
293-
return Error::success();
294-
}
295250
} // namespace
296251

297252
namespace llvm {
@@ -349,9 +304,7 @@ void link_COFF_x86_64(std::unique_ptr<LinkGraph> G,
349304
Config.PrePrunePasses.push_back(markAllSymbolsLive);
350305

351306
// Add COFF edge lowering passes.
352-
JITLinkContext *CtxPtr = Ctx.get();
353-
Config.PreFixupPasses.push_back(
354-
[CtxPtr](LinkGraph &G) { return lowerEdges_COFF_x86_64(G, CtxPtr); });
307+
Config.PreFixupPasses.push_back(COFFLinkGraphLowering_x86_64());
355308
}
356309

357310
if (auto Err = Ctx->modifyPassConfig(*G, Config))

llvm/lib/ExecutionEngine/Orc/LazyReexports.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -294,14 +294,14 @@ LazyReexportsManager::Create(EmitTrampolinesFn EmitTrampolines,
294294

295295
Error LazyReexportsManager::handleRemoveResources(JITDylib &JD, ResourceKey K) {
296296
JD.getExecutionSession().runSessionLocked([&]() {
297-
auto I = KeyToReentryAddr.find(K);
298-
if (I != KeyToReentryAddr.end()) {
297+
auto I = KeyToReentryAddrs.find(K);
298+
if (I != KeyToReentryAddrs.end()) {
299299
auto &ReentryAddrs = I->second;
300300
for (auto &ReentryAddr : ReentryAddrs) {
301301
assert(CallThroughs.count(ReentryAddr) && "CallTrhough missing");
302302
CallThroughs.erase(ReentryAddr);
303303
}
304-
KeyToReentryAddr.erase(I);
304+
KeyToReentryAddrs.erase(I);
305305
}
306306
});
307307
return Error::success();
@@ -310,19 +310,18 @@ Error LazyReexportsManager::handleRemoveResources(JITDylib &JD, ResourceKey K) {
310310
void LazyReexportsManager::handleTransferResources(JITDylib &JD,
311311
ResourceKey DstK,
312312
ResourceKey SrcK) {
313-
auto I = KeyToReentryAddr.find(SrcK);
314-
if (I != KeyToReentryAddr.end()) {
315-
auto J = KeyToReentryAddr.find(DstK);
316-
if (J == KeyToReentryAddr.end()) {
313+
auto I = KeyToReentryAddrs.find(SrcK);
314+
if (I != KeyToReentryAddrs.end()) {
315+
auto J = KeyToReentryAddrs.find(DstK);
316+
if (J == KeyToReentryAddrs.end()) {
317317
auto Tmp = std::move(I->second);
318-
KeyToReentryAddr.erase(I);
319-
KeyToReentryAddr[DstK] = std::move(Tmp);
318+
KeyToReentryAddrs.erase(I);
319+
KeyToReentryAddrs[DstK] = std::move(Tmp);
320320
} else {
321-
auto &SrcReentryAddrs = I->second;
322-
auto &DstReentryAddrs = J->second;
323-
for (auto &ReentryAddr : SrcReentryAddrs)
324-
DstReentryAddrs.push_back(std::move(ReentryAddr));
325-
KeyToReentryAddr.erase(I);
321+
auto &SrcAddrs = I->second;
322+
auto &DstAddrs = J->second;
323+
DstAddrs.insert(DstAddrs.end(), SrcAddrs.begin(), SrcAddrs.end());
324+
KeyToReentryAddrs.erase(I);
326325
}
327326
}
328327
}
@@ -390,7 +389,7 @@ void LazyReexportsManager::emitRedirectableSymbols(
390389
const auto &ReentryPoint = (*ReentryPoints)[I++];
391390
CallThroughs[ReentryPoint.getAddress()] = {Name, AI.Aliasee,
392391
&MR->getTargetJITDylib()};
393-
KeyToReentryAddr[K].push_back(ReentryPoint.getAddress());
392+
KeyToReentryAddrs[K].push_back(ReentryPoint.getAddress());
394393
}
395394
})) {
396395
MR->getExecutionSession().reportError(std::move(Err));

llvm/lib/ExecutionEngine/Orc/TaskDispatch.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ void DynamicThreadPoolTaskDispatcher::dispatch(std::unique_ptr<Task> T) {
6868
if (IsMaterializationTask)
6969
--NumMaterializationThreads;
7070
--Outstanding;
71-
OutstandingCV.notify_all();
71+
if (Outstanding == 0)
72+
OutstandingCV.notify_all();
7273
return;
7374
}
7475
}

llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,6 +2108,10 @@ bool MipsAsmParser::processInstruction(MCInst &Inst, SMLoc IDLoc,
21082108
if ((Opcode == Mips::JAL || Opcode == Mips::JAL_MM) && inPicMode()) {
21092109
warnIfNoMacro(IDLoc);
21102110

2111+
if (!Inst.getOperand(0).isExpr()) {
2112+
return Error(IDLoc, "unsupported constant in relocation");
2113+
}
2114+
21112115
const MCExpr *JalExpr = Inst.getOperand(0).getExpr();
21122116

21132117
// We can do this expansion if there's only 1 symbol in the argument

llvm/lib/Transforms/IPO/FunctionAttrs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ ArgumentAccessInfo getArgmentAccessInfo(const Instruction *I,
633633
[](Value *Length,
634634
std::optional<int64_t> Offset) -> std::optional<ConstantRange> {
635635
auto *ConstantLength = dyn_cast<ConstantInt>(Length);
636-
if (ConstantLength && Offset)
636+
if (ConstantLength && Offset && !ConstantLength->isNegative())
637637
return ConstantRange(
638638
APInt(64, *Offset, true),
639639
APInt(64, *Offset + ConstantLength->getSExtValue(), true));

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1488,7 +1488,7 @@ static VPRecipeBase *createEVLRecipe(VPValue *HeaderMask,
14881488
})
14891489
.Case<VPWidenIntrinsicRecipe, VPWidenCastRecipe>(
14901490
[&](auto *CR) -> VPRecipeBase * {
1491-
Intrinsic::ID VPID;
1491+
Intrinsic::ID VPID = Intrinsic::not_intrinsic;
14921492
if (auto *CallR = dyn_cast<VPWidenIntrinsicRecipe>(CR))
14931493
VPID =
14941494
VPIntrinsic::getForIntrinsic(CallR->getVectorIntrinsicID());

llvm/test/MC/AArch64/armv8.3a-complex.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mattr=+complxnum,+fullfp16 -o - %s 2>%t | FileCheck %s
22
// RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mattr=+v8.3a,+fullfp16 -o - %s 2>%t | FileCheck %s
3+
.text
34
fcmla v0.4h, v1.4h, v2.4h, #0
45
fcmla v0.8h, v1.8h, v2.8h, #0
56
fcmla v0.2s, v1.2s, v2.2s, #0

llvm/test/MC/AArch64/armv8.3a-complex_nofp16.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: llvm-mc -triple aarch64-none-linux-gnu -show-encoding -mattr=+complxnum -o - %s 2>%t | FileCheck %s
2+
.text
23
fcmla v0.2s, v1.2s, v2.2s, #0
34
fcmla v0.4s, v1.4s, v2.4s, #0
45
fcmla v0.2d, v1.2d, v2.2d, #0

llvm/test/MC/AArch64/armv8.3a-pauth.s

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22

33
paciasp
44

5-
// CHECK: .text
65
// CHECK: paciasp // encoding: [0x3f,0x23,0x03,0xd5]

llvm/test/MC/AArch64/armv8.3a-signed-pointer.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// RUN: FileCheck --check-prefix=CHECK-REQ %s < %t.2
77

88
// ALL: .text
9+
.text
910
mrs x0, apiakeylo_el1
1011
mrs x0, apiakeyhi_el1
1112
mrs x0, apibkeylo_el1

llvm/test/MC/AArch64/armv8.4a-flagm.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
cfinv
44

5-
// CHECK: .text
6-
cfinv // encoding: [0x1f,0x40,0x00,0xd5]
5+
// CHECK: encoding: [0x1f,0x40,0x00,0xd5]
6+
cfinv

llvm/test/MC/AArch64/armv8.6a-amvs.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: llvm-mc -triple aarch64 -show-encoding -mattr=+amvs -o - %s | FileCheck %s
22
// RUN: llvm-mc -triple aarch64 -show-encoding -mattr=+v8.6a -o - %s | FileCheck %s
33
// RUN: not llvm-mc -triple aarch64 -show-encoding -o - %s 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
4+
.text
45
mrs x0, AMCG1IDR_EL0
56
msr AMEVCNTVOFF00_EL2, x0
67
msr AMEVCNTVOFF01_EL2, x0

llvm/test/MC/AArch64/armv9.6a-ras.s

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,5 @@ dc CIVAPS, x3
66
// NO-POPS: error: DC CIGDVAPS requires: pops
77
// NO-POPS: error: DC CIVAPS requires: pops
88

9-
# HAS-POPS: .text
10-
119
# HAS-POPS: dc cigdvaps, x3 // encoding: [0xa3,0x7f,0x08,0xd5]
1210
# HAS-POPS-NEXT: dc civaps, x3 // encoding: [0x23,0x7f,0x08,0xd5]

llvm/test/MC/AArch64/armv9.6a-rme-gpc3.s

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
mrs x3, GPCBW_EL3
66
msr GPCBW_EL3, x4
77

8-
# CHECK: .text
9-
# CHECK-NEXT: .func:
8+
# CHECK: .func:
109
# CHECK-NEXT: apas x0 // encoding: [0x1f,0x70,0x0e,0xd5]
1110
# CHECK-NEXT: mrs x3, GPCBW_EL3 // encoding: [0xa3,0x21,0x3e,0xd5]
1211
# CHECK-NEXT: msr GPCBW_EL3, x4 // encoding: [0xa4,0x21,0x1e,0xd5]

llvm/test/MC/ARM/directive-object_arch-3.s

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
.arch armv7
66
.object_arch armv4
77

8-
@ CHECK: .text
98
@ CHECK: .arch armv7
109
@ CHECK: .object_arch armv4
1110

llvm/test/MC/ARM/inst-directive-emit.s

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
emit_asm:
1010
.inst.w 0xf2400000, 0xf2c00000
1111

12-
@ CHECK: .text
1312
@ CHECK: .code 16
1413
@ CHECK: .p2align 2
1514
@ CHECK: .globl emit_asm

llvm/test/MC/Mips/dsp/valid.s

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# RUN: llvm-mc -show-encoding -triple=mips-unknown-unknown -mattr=dsp %s | FileCheck %s
22
#
3-
# CHECK: .text
43
.set noat
54
absq_s.ph $1, $2 # CHECK: absq_s.ph $1, $2 # encoding: [0x7c,0x02,0x0a,0x52]
65
absq_s.w $5, $6 # CHECK: absq_s.w $5, $6 # encoding: [0x7c,0x06,0x2c,0x52]

llvm/test/MC/Mips/dspr2/valid.s

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# RUN: llvm-mc -show-encoding -triple=mips-unknown-unknown -mattr=dspr2 %s | FileCheck %s
22
#
3-
# CHECK: .text
43
.set noat
54
absq_s.ph $1, $2 # CHECK: absq_s.ph $1, $2 # encoding: [0x7c,0x02,0x0a,0x52]
65
absq_s.qb $3, $4 # CHECK: absq_s.qb $3, $4 # encoding: [0x7c,0x04,0x18,0x52]

0 commit comments

Comments
 (0)