From cf6aafa47c3771e4f353bfbdeb8157347b305339 Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Thu, 19 Dec 2019 12:01:51 -0800 Subject: [PATCH] [FaultMaps] Make label formation a bit more explicit [NFC] This is in advance of assembler padding directives support where we'll need to bundle the label w/the corresponding faulting instruction to avoid padding being inserted between. --- llvm/include/llvm/CodeGen/FaultMaps.h | 3 ++- llvm/lib/CodeGen/FaultMaps.cpp | 4 +--- llvm/lib/Target/X86/X86MCInstLower.cpp | 6 +++++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/llvm/include/llvm/CodeGen/FaultMaps.h b/llvm/include/llvm/CodeGen/FaultMaps.h index a1e2349c413e..da56c4dd13ab 100644 --- a/llvm/include/llvm/CodeGen/FaultMaps.h +++ b/llvm/include/llvm/CodeGen/FaultMaps.h @@ -36,7 +36,8 @@ public: static const char *faultTypeToString(FaultKind); - void recordFaultingOp(FaultKind FaultTy, const MCSymbol *HandlerLabel); + void recordFaultingOp(FaultKind FaultTy, const MCSymbol *FaultingLabel, + const MCSymbol *HandlerLabel); void serializeToFaultMapSection(); void reset() { FunctionInfos.clear(); diff --git a/llvm/lib/CodeGen/FaultMaps.cpp b/llvm/lib/CodeGen/FaultMaps.cpp index 600f72d320eb..de0b4fa87098 100644 --- a/llvm/lib/CodeGen/FaultMaps.cpp +++ b/llvm/lib/CodeGen/FaultMaps.cpp @@ -28,11 +28,9 @@ const char *FaultMaps::WFMP = "Fault Maps: "; FaultMaps::FaultMaps(AsmPrinter &AP) : AP(AP) {} void FaultMaps::recordFaultingOp(FaultKind FaultTy, + const MCSymbol *FaultingLabel, const MCSymbol *HandlerLabel) { MCContext &OutContext = AP.OutStreamer->getContext(); - MCSymbol *FaultingLabel = OutContext.createTempSymbol(); - - AP.OutStreamer->EmitLabel(FaultingLabel); const MCExpr *FaultingOffset = MCBinaryExpr::createSub( MCSymbolRefExpr::create(FaultingLabel, OutContext), diff --git a/llvm/lib/Target/X86/X86MCInstLower.cpp b/llvm/lib/Target/X86/X86MCInstLower.cpp index e869aa64a1ee..4876df50766d 100644 --- a/llvm/lib/Target/X86/X86MCInstLower.cpp +++ b/llvm/lib/Target/X86/X86MCInstLower.cpp @@ -1209,8 +1209,12 @@ void X86AsmPrinter::LowerFAULTING_OP(const MachineInstr &FaultingMI, unsigned Opcode = FaultingMI.getOperand(3).getImm(); unsigned OperandsBeginIdx = 4; + auto &Ctx = OutStreamer->getContext(); + MCSymbol *FaultingLabel = Ctx.createTempSymbol(); + OutStreamer->EmitLabel(FaultingLabel); + assert(FK < FaultMaps::FaultKindMax && "Invalid Faulting Kind!"); - FM.recordFaultingOp(FK, HandlerLabel); + FM.recordFaultingOp(FK, FaultingLabel, HandlerLabel); MCInst MI; MI.setOpcode(Opcode);