[x86] fix assert with horizontal math + broadcast of vector (PR43402)
[llvm-core.git] / lib / CodeGen / AsmPrinter / WinCFGuard.cpp
blob290be81c6baabef6155607701111e0406aed5b72
1 //===-- CodeGen/AsmPrinter/WinCFGuard.cpp - Control Flow Guard Impl ------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains support for writing Win64 exception info into asm files.
11 //===----------------------------------------------------------------------===//
13 #include "WinCFGuard.h"
14 #include "llvm/CodeGen/AsmPrinter.h"
15 #include "llvm/CodeGen/MachineFunction.h"
16 #include "llvm/CodeGen/MachineModuleInfo.h"
17 #include "llvm/CodeGen/MachineOperand.h"
18 #include "llvm/IR/Constants.h"
19 #include "llvm/IR/Metadata.h"
20 #include "llvm/MC/MCAsmInfo.h"
21 #include "llvm/MC/MCObjectFileInfo.h"
22 #include "llvm/MC/MCStreamer.h"
24 #include <vector>
26 using namespace llvm;
28 WinCFGuard::WinCFGuard(AsmPrinter *A) : AsmPrinterHandler(), Asm(A) {}
30 WinCFGuard::~WinCFGuard() {}
32 void WinCFGuard::endModule() {
33 const Module *M = Asm->MMI->getModule();
34 std::vector<const Function *> Functions;
35 for (const Function &F : *M)
36 if (F.hasAddressTaken())
37 Functions.push_back(&F);
38 if (Functions.empty())
39 return;
40 auto &OS = *Asm->OutStreamer;
41 OS.SwitchSection(Asm->OutContext.getObjectFileInfo()->getGFIDsSection());
42 for (const Function *F : Functions)
43 OS.EmitCOFFSymbolIndex(Asm->getSymbol(F));