mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-03 07:26:08 +00:00
Teach the backend to make references to swift_async_extendedFramePointerFlags weak if it emits it
When references to the symbol `swift_async_extendedFramePointerFlags` are emitted they have to be weak. References to the symbol `swift_async_extendedFramePointerFlags` get emitted only by frame lowering code. Therefore, the backend needs to track references to the symbol and mark them weak. Differential Revision: https://reviews.llvm.org/D115672
This commit is contained in:
parent
0dc339c870
commit
d87e617048
@ -799,6 +799,11 @@ private:
|
||||
|
||||
/// This method decides whether the specified basic block requires a label.
|
||||
bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const;
|
||||
|
||||
protected:
|
||||
virtual bool shouldEmitWeakSwiftAsyncExtendedFramePointerFlags() const {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
|
@ -1860,6 +1860,17 @@ bool AsmPrinter::doFinalization(Module &M) {
|
||||
continue;
|
||||
OutStreamer->emitSymbolAttribute(getSymbol(&GO), MCSA_WeakReference);
|
||||
}
|
||||
if (shouldEmitWeakSwiftAsyncExtendedFramePointerFlags()) {
|
||||
auto SymbolName = "swift_async_extendedFramePointerFlags";
|
||||
auto Global = M.getGlobalVariable(SymbolName);
|
||||
if (!Global) {
|
||||
auto Int8PtrTy = Type::getInt8PtrTy(M.getContext());
|
||||
Global = new GlobalVariable(M, Int8PtrTy, false,
|
||||
GlobalValue::ExternalWeakLinkage, nullptr,
|
||||
SymbolName);
|
||||
OutStreamer->emitSymbolAttribute(getSymbol(Global), MCSA_WeakReference);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Print aliases in topological order, that is, for each alias a = b,
|
||||
|
@ -73,6 +73,7 @@ class AArch64AsmPrinter : public AsmPrinter {
|
||||
StackMaps SM;
|
||||
FaultMaps FM;
|
||||
const AArch64Subtarget *STI;
|
||||
bool ShouldEmitWeakSwiftAsyncExtendedFramePointerFlags = false;
|
||||
|
||||
public:
|
||||
AArch64AsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer)
|
||||
@ -186,6 +187,10 @@ private:
|
||||
using MInstToMCSymbol = std::map<const MachineInstr *, MCSymbol *>;
|
||||
|
||||
MInstToMCSymbol LOHInstToLabel;
|
||||
|
||||
bool shouldEmitWeakSwiftAsyncExtendedFramePointerFlags() const override {
|
||||
return ShouldEmitWeakSwiftAsyncExtendedFramePointerFlags;
|
||||
}
|
||||
};
|
||||
|
||||
} // end anonymous namespace
|
||||
@ -1132,6 +1137,15 @@ void AArch64AsmPrinter::emitInstruction(const MachineInstr *MI) {
|
||||
if (emitPseudoExpansionLowering(*OutStreamer, MI))
|
||||
return;
|
||||
|
||||
if (MI->getOpcode() == AArch64::ADRP) {
|
||||
for (auto &Opd : MI->operands()) {
|
||||
if (Opd.isSymbol() && StringRef(Opd.getSymbolName()) ==
|
||||
"swift_async_extendedFramePointerFlags") {
|
||||
ShouldEmitWeakSwiftAsyncExtendedFramePointerFlags = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (AArch64FI->getLOHRelated().count(MI)) {
|
||||
// Generate a label for LOH related instruction
|
||||
MCSymbol *LOHLabel = createTempSymbol("loh");
|
||||
|
@ -31,6 +31,7 @@ class LLVM_LIBRARY_VISIBILITY X86AsmPrinter : public AsmPrinter {
|
||||
FaultMaps FM;
|
||||
std::unique_ptr<MCCodeEmitter> CodeEmitter;
|
||||
bool EmitFPOData = false;
|
||||
bool ShouldEmitWeakSwiftAsyncExtendedFramePointerFlags = false;
|
||||
|
||||
// This utility class tracks the length of a stackmap instruction's 'shadow'.
|
||||
// It is used by the X86AsmPrinter to ensure that the stackmap shadow
|
||||
@ -151,6 +152,10 @@ public:
|
||||
bool runOnMachineFunction(MachineFunction &MF) override;
|
||||
void emitFunctionBodyStart() override;
|
||||
void emitFunctionBodyEnd() override;
|
||||
|
||||
bool shouldEmitWeakSwiftAsyncExtendedFramePointerFlags() const override {
|
||||
return ShouldEmitWeakSwiftAsyncExtendedFramePointerFlags;
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
|
@ -2410,6 +2410,15 @@ void X86AsmPrinter::emitInstruction(const MachineInstr *MI) {
|
||||
const X86RegisterInfo *RI =
|
||||
MF->getSubtarget<X86Subtarget>().getRegisterInfo();
|
||||
|
||||
if (MI->getOpcode() == X86::OR64rm) {
|
||||
for (auto &Opd : MI->operands()) {
|
||||
if (Opd.isSymbol() && StringRef(Opd.getSymbolName()) ==
|
||||
"swift_async_extendedFramePointerFlags") {
|
||||
ShouldEmitWeakSwiftAsyncExtendedFramePointerFlags = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add a comment about EVEX-2-VEX compression for AVX-512 instrs that
|
||||
// are compressed from EVEX encoding to VEX encoding.
|
||||
if (TM.Options.MCOptions.ShowMCEncoding) {
|
||||
|
@ -23,11 +23,13 @@
|
||||
; CHECK-DYNAMIC: adrp x16, _swift_async_extendedFramePointerFlags@GOTPAGE
|
||||
; CHECK-DYNAMIC: ldr x16, [x16, _swift_async_extendedFramePointerFlags@GOTPAGEOFF]
|
||||
; CHECK-DYNAMIC: orr x29, x29, x16
|
||||
; CHECK-DYNAMIC: .weak_reference _swift_async_extendedFramePointerFlags
|
||||
|
||||
; CHECK-DYNAMIC-32-LABEL: foo:
|
||||
; CHECK-DYNAMIC-32: adrp x16, _swift_async_extendedFramePointerFlags@GOTPAGE
|
||||
; CHECK-DYNAMIC-32: ldr w16, [x16, _swift_async_extendedFramePointerFlags@GOTPAGEOFF]
|
||||
; CHECK-DYNAMIC-32: orr x29, x29, x16, lsl #32
|
||||
; CHECK-DYNAMIC-32: .weak_reference _swift_async_extendedFramePointerFlags
|
||||
|
||||
define void @foo(i8* swiftasync) "frame-pointer"="all" {
|
||||
ret void
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
; CHECK-DYNAMIC-LABEL: foo:
|
||||
; CHECK-DYNAMIC: orq _swift_async_extendedFramePointerFlags@GOTPCREL(%rip), %rbp
|
||||
; CHECK-DYNAMIC: .weak_reference _swift_async_extendedFramePointerFlags
|
||||
|
||||
; CHECK-NEVER-LABEL: foo:
|
||||
; CHECK-NEVER-NOT: btsq $60, %rbp
|
||||
|
Loading…
x
Reference in New Issue
Block a user