aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCStreamer.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2024-07-07 12:41:13 -0700
committerGitHub <noreply@github.com>2024-07-07 12:41:13 -0700
commit2718654c542c742e2dd18dcda8b93de1d4d3b640 (patch)
treeb9646a7fa5aea75d3e78c3921a7a5bdf2edaf2e6 /llvm/lib/MC/MCStreamer.cpp
parentf13463ee52cf95c76867d0dafe6bff16cb9e3009 (diff)
downloadllvm-2718654c542c742e2dd18dcda8b93de1d4d3b640.zip
llvm-2718654c542c742e2dd18dcda8b93de1d4d3b640.tar.gz
llvm-2718654c542c742e2dd18dcda8b93de1d4d3b640.tar.bz2
[MC] Support .cfi_label
GNU assembler 2.26 introduced the .cfi_label directive. It does not expand to any CFI instructions, but defines a label in .eh_frame/.debug_frame, which can be used by runtime patching code to locate the FDE. .cfi_label is not allowed for CIE's initial instructions, and can therefore be used to force the next instruction to be placed in a FDE instead of a CIE. In glibc since 2018, sysdeps/riscv/start.S utilizes .cfi_label to force DW_CFA_undefined to be placed in a FDE. arc/csky/loongarch ports have copied this use. ``` .cfi_startproc // DW_CFA_undefined is allowed for CIE's initial instructions. // Without .cfi_label, gas would place DW_CFA_undefined in a CIE. .cfi_label .Ldummy .cfi_undefined ra .cfi_endproc ``` No CFI instruction is associated with .cfi_label, so the `case MCCFIInstruction::OpLabel:` code in BOLT is unreachable and onlt to make -Wswitch happy. Close #97222 Pull Request: https://github.com/llvm/llvm-project/pull/97922
Diffstat (limited to 'llvm/lib/MC/MCStreamer.cpp')
-rw-r--r--llvm/lib/MC/MCStreamer.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp
index a3f6794..1594bd3 100644
--- a/llvm/lib/MC/MCStreamer.cpp
+++ b/llvm/lib/MC/MCStreamer.cpp
@@ -689,6 +689,13 @@ void MCStreamer::emitCFIReturnColumn(int64_t Register) {
CurFrame->RAReg = Register;
}
+void MCStreamer::emitCFILabelDirective(SMLoc Loc, StringRef Name) {
+ MCSymbol *Label = emitCFILabel();
+ MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
+ if (MCDwarfFrameInfo *F = getCurrentDwarfFrameInfo())
+ F->Instructions.push_back(MCCFIInstruction::createLabel(Label, Sym, Loc));
+}
+
WinEH::FrameInfo *MCStreamer::EnsureValidWinFrameInfo(SMLoc Loc) {
const MCAsmInfo *MAI = Context.getAsmInfo();
if (!MAI->usesWindowsCFI()) {