blob: 19ff49cd8f789fcfc7657db5d8f08896eed8d2c6 [file] [log] [blame]
Daniel Dunbarbadeace2009-06-23 23:39:15 +00001//===- lib/MC/MCContext.cpp - Machine Code Context ------------------------===//
Daniel Dunbarca29e4d2009-06-23 22:01:43 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "llvm/MC/MCContext.h"
Chris Lattner86dfd732009-10-19 22:49:00 +000011#include "llvm/ADT/SmallString.h"
12#include "llvm/ADT/Twine.h"
Chandler Carruthed0881b2012-12-03 16:50:05 +000013#include "llvm/MC/MCAsmInfo.h"
14#include "llvm/MC/MCDwarf.h"
15#include "llvm/MC/MCLabel.h"
16#include "llvm/MC/MCObjectFileInfo.h"
17#include "llvm/MC/MCRegisterInfo.h"
18#include "llvm/MC/MCSectionCOFF.h"
19#include "llvm/MC/MCSectionELF.h"
20#include "llvm/MC/MCSectionMachO.h"
21#include "llvm/MC/MCSymbol.h"
Rafael Espindolaaea49582011-01-23 04:28:49 +000022#include "llvm/Support/ELF.h"
Jim Grosbachb18b4092012-01-26 23:20:11 +000023#include "llvm/Support/ErrorHandling.h"
Jim Grosbachb18b4092012-01-26 23:20:11 +000024#include "llvm/Support/Signals.h"
Chandler Carruthed0881b2012-12-03 16:50:05 +000025#include "llvm/Support/SourceMgr.h"
Daniel Dunbarca29e4d2009-06-23 22:01:43 +000026using namespace llvm;
27
Chris Lattner20731122010-04-08 20:30:37 +000028typedef StringMap<const MCSectionMachO*> MachOUniqueMapTy;
Chris Lattner5418dd52010-04-08 21:26:26 +000029typedef StringMap<const MCSectionELF*> ELFUniqueMapTy;
Chris Lattner87cffa92010-05-07 17:17:41 +000030typedef StringMap<const MCSectionCOFF*> COFFUniqueMapTy;
Chris Lattner20731122010-04-08 20:30:37 +000031
32
Evan Chengd60fa58b2011-07-18 20:57:22 +000033MCContext::MCContext(const MCAsmInfo &mai, const MCRegisterInfo &mri,
Pedro Artigase84b13f2012-12-06 22:12:44 +000034 const MCObjectFileInfo *mofi, const SourceMgr *mgr,
Pedro Artigas7212ee42012-12-12 22:59:46 +000035 bool DoAutoReset ) :
Jim Grosbachdfc5b552012-01-26 23:20:05 +000036 SrcMgr(mgr), MAI(mai), MRI(mri), MOFI(mofi),
Eli Friedman0e402082011-04-18 05:02:31 +000037 Allocator(), Symbols(Allocator), UsedNames(Allocator),
Pedro Artigas7212ee42012-12-12 22:59:46 +000038 NextUniqueID(0),
39 CurrentDwarfLoc(0,0,0,DWARF2_FLAG_IS_STMT,0,0),
40 DwarfLocSeen(false), GenDwarfForAssembly(false), GenDwarfFileNumber(0),
41 AllowTemporaryLabels(true), AutoReset(DoAutoReset) {
42
Chris Lattner20731122010-04-08 20:30:37 +000043 MachOUniquingMap = 0;
Chris Lattner5418dd52010-04-08 21:26:26 +000044 ELFUniquingMap = 0;
Chris Lattner87cffa92010-05-07 17:17:41 +000045 COFFUniquingMap = 0;
Kevin Enderbye233dda2010-06-28 21:45:58 +000046
47 SecureLogFile = getenv("AS_SECURE_LOG_FILE");
48 SecureLog = 0;
49 SecureLogUsed = false;
Pedro Artigase84b13f2012-12-06 22:12:44 +000050}
51
52MCContext::~MCContext() {
53
Pedro Artigas7212ee42012-12-12 22:59:46 +000054 if (AutoReset)
55 reset();
Pedro Artigase84b13f2012-12-06 22:12:44 +000056
57 // NOTE: The symbols are all allocated out of a bump pointer allocator,
58 // we don't need to free them here.
59
60 // If the stream for the .secure_log_unique directive was created free it.
61 delete (raw_ostream*)SecureLog;
62}
63
64//===----------------------------------------------------------------------===//
65// Module Lifetime Management
66//===----------------------------------------------------------------------===//
67
Pedro Artigas7212ee42012-12-12 22:59:46 +000068void MCContext::reset() {
Pedro Artigase84b13f2012-12-06 22:12:44 +000069 UsedNames.clear();
70 Symbols.clear();
71 Allocator.Reset();
72 Instances.clear();
73 MCDwarfFiles.clear();
74 MCDwarfDirs.clear();
75 MCGenDwarfLabelEntries.clear();
76 DwarfDebugFlags = StringRef();
77 MCLineSections.clear();
78 MCLineSectionOrder.clear();
79 CurrentDwarfLoc = MCDwarfLoc(0,0,0,DWARF2_FLAG_IS_STMT,0,0);
Michael J. Spencerf13f4422010-11-26 04:16:08 +000080
Chris Lattner20731122010-04-08 20:30:37 +000081 // If we have the MachO uniquing map, free it.
82 delete (MachOUniqueMapTy*)MachOUniquingMap;
Chris Lattner5418dd52010-04-08 21:26:26 +000083 delete (ELFUniqueMapTy*)ELFUniquingMap;
Chris Lattner87cffa92010-05-07 17:17:41 +000084 delete (COFFUniqueMapTy*)COFFUniquingMap;
Pedro Artigase84b13f2012-12-06 22:12:44 +000085 MachOUniquingMap = 0;
86 ELFUniquingMap = 0;
87 COFFUniquingMap = 0;
Pedro Artigas7212ee42012-12-12 22:59:46 +000088
89 NextUniqueID = 0;
90 AllowTemporaryLabels = true;
91 DwarfLocSeen = false;
92 GenDwarfForAssembly = false;
93 GenDwarfFileNumber = 0;
Daniel Dunbarca29e4d2009-06-23 22:01:43 +000094}
95
Chris Lattner20731122010-04-08 20:30:37 +000096//===----------------------------------------------------------------------===//
97// Symbol Manipulation
98//===----------------------------------------------------------------------===//
99
Chris Lattner98970432010-03-30 18:10:53 +0000100MCSymbol *MCContext::GetOrCreateSymbol(StringRef Name) {
Chris Lattnerb973ea82010-03-10 01:29:27 +0000101 assert(!Name.empty() && "Normal symbols cannot be unnamed!");
Michael J. Spencerf13f4422010-11-26 04:16:08 +0000102
Chris Lattner13348762010-03-15 06:15:35 +0000103 // Do the lookup and get the entire StringMapEntry. We want access to the
104 // key if we are creating the entry.
105 StringMapEntry<MCSymbol*> &Entry = Symbols.GetOrCreateValue(Name);
Rafael Espindola5fe5f452010-12-01 20:46:11 +0000106 MCSymbol *Sym = Entry.getValue();
107
108 if (Sym)
109 return Sym;
110
111 Sym = CreateSymbol(Name);
112 Entry.setValue(Sym);
113 return Sym;
114}
115
116MCSymbol *MCContext::CreateSymbol(StringRef Name) {
Daniel Dunbar4ee0d032011-03-28 22:49:15 +0000117 // Determine whether this is an assembler temporary or normal label, if used.
118 bool isTemporary = false;
119 if (AllowTemporaryLabels)
120 isTemporary = Name.startswith(MAI.getPrivateGlobalPrefix());
Rafael Espindola5fe5f452010-12-01 20:46:11 +0000121
122 StringMapEntry<bool> *NameEntry = &UsedNames.GetOrCreateValue(Name);
123 if (NameEntry->getValue()) {
124 assert(isTemporary && "Cannot rename non temporary symbols");
Benjamin Kramer2b6c96b2011-04-09 11:26:27 +0000125 SmallString<128> NewName = Name;
Rafael Espindola5fe5f452010-12-01 20:46:11 +0000126 do {
Benjamin Kramer2b6c96b2011-04-09 11:26:27 +0000127 NewName.resize(Name.size());
128 raw_svector_ostream(NewName) << NextUniqueID++;
129 NameEntry = &UsedNames.GetOrCreateValue(NewName);
Rafael Espindola5fe5f452010-12-01 20:46:11 +0000130 } while (NameEntry->getValue());
131 }
132 NameEntry->setValue(true);
Chris Lattner3f5738d2009-06-24 04:31:49 +0000133
Chris Lattner13348762010-03-15 06:15:35 +0000134 // Ok, the entry doesn't already exist. Have the MCSymbol object itself refer
Rafael Espindola5fe5f452010-12-01 20:46:11 +0000135 // to the copy of the string that is embedded in the UsedNames entry.
136 MCSymbol *Result = new (*this) MCSymbol(NameEntry->getKey(), isTemporary);
137
138 return Result;
Chris Lattner3f5738d2009-06-24 04:31:49 +0000139}
140
Chris Lattner98970432010-03-30 18:10:53 +0000141MCSymbol *MCContext::GetOrCreateSymbol(const Twine &Name) {
Chris Lattner86dfd732009-10-19 22:49:00 +0000142 SmallString<128> NameSV;
143 Name.toVector(NameSV);
Chris Lattner98970432010-03-30 18:10:53 +0000144 return GetOrCreateSymbol(NameSV.str());
Chris Lattner86dfd732009-10-19 22:49:00 +0000145}
146
Chris Lattner073d8172010-03-14 08:23:30 +0000147MCSymbol *MCContext::CreateTempSymbol() {
Rafael Espindola5fe5f452010-12-01 20:46:11 +0000148 SmallString<128> NameSV;
Benjamin Kramer2b6c96b2011-04-09 11:26:27 +0000149 raw_svector_ostream(NameSV)
150 << MAI.getPrivateGlobalPrefix() << "tmp" << NextUniqueID++;
Rafael Espindola5fe5f452010-12-01 20:46:11 +0000151 return CreateSymbol(NameSV);
Chris Lattner073d8172010-03-14 08:23:30 +0000152}
153
Kevin Enderby0510b482010-05-17 23:08:19 +0000154unsigned MCContext::NextInstance(int64_t LocalLabelVal) {
Benjamin Kramerab7be752010-05-18 12:15:34 +0000155 MCLabel *&Label = Instances[LocalLabelVal];
156 if (!Label)
157 Label = new (*this) MCLabel(0);
158 return Label->incInstance();
Kevin Enderby0510b482010-05-17 23:08:19 +0000159}
160
161unsigned MCContext::GetInstance(int64_t LocalLabelVal) {
Benjamin Kramerab7be752010-05-18 12:15:34 +0000162 MCLabel *&Label = Instances[LocalLabelVal];
163 if (!Label)
164 Label = new (*this) MCLabel(0);
165 return Label->getInstance();
Kevin Enderby0510b482010-05-17 23:08:19 +0000166}
167
168MCSymbol *MCContext::CreateDirectionalLocalSymbol(int64_t LocalLabelVal) {
169 return GetOrCreateSymbol(Twine(MAI.getPrivateGlobalPrefix()) +
170 Twine(LocalLabelVal) +
171 "\2" +
Duncan Sands41b4a6b2010-07-12 08:16:59 +0000172 Twine(NextInstance(LocalLabelVal)));
Kevin Enderby0510b482010-05-17 23:08:19 +0000173}
174MCSymbol *MCContext::GetDirectionalLocalSymbol(int64_t LocalLabelVal,
175 int bORf) {
176 return GetOrCreateSymbol(Twine(MAI.getPrivateGlobalPrefix()) +
177 Twine(LocalLabelVal) +
178 "\2" +
Duncan Sands41b4a6b2010-07-12 08:16:59 +0000179 Twine(GetInstance(LocalLabelVal) + bORf));
Kevin Enderby0510b482010-05-17 23:08:19 +0000180}
181
Daniel Dunbarad36e8a2009-11-06 10:58:06 +0000182MCSymbol *MCContext::LookupSymbol(StringRef Name) const {
Daniel Dunbarca29e4d2009-06-23 22:01:43 +0000183 return Symbols.lookup(Name);
184}
Chris Lattner20731122010-04-08 20:30:37 +0000185
Roman Divacky0be33592012-09-18 17:10:37 +0000186MCSymbol *MCContext::LookupSymbol(const Twine &Name) const {
187 SmallString<128> NameSV;
188 Name.toVector(NameSV);
189 return LookupSymbol(NameSV.str());
190}
191
Chris Lattner20731122010-04-08 20:30:37 +0000192//===----------------------------------------------------------------------===//
193// Section Management
194//===----------------------------------------------------------------------===//
195
196const MCSectionMachO *MCContext::
197getMachOSection(StringRef Segment, StringRef Section,
198 unsigned TypeAndAttributes,
199 unsigned Reserved2, SectionKind Kind) {
Michael J. Spencerf13f4422010-11-26 04:16:08 +0000200
Chris Lattner20731122010-04-08 20:30:37 +0000201 // We unique sections by their segment/section pair. The returned section
202 // may not have the same flags as the requested section, if so this should be
203 // diagnosed by the client as an error.
Michael J. Spencerf13f4422010-11-26 04:16:08 +0000204
Chris Lattner20731122010-04-08 20:30:37 +0000205 // Create the map if it doesn't already exist.
206 if (MachOUniquingMap == 0)
207 MachOUniquingMap = new MachOUniqueMapTy();
208 MachOUniqueMapTy &Map = *(MachOUniqueMapTy*)MachOUniquingMap;
Michael J. Spencerf13f4422010-11-26 04:16:08 +0000209
Chris Lattner20731122010-04-08 20:30:37 +0000210 // Form the name to look up.
211 SmallString<64> Name;
212 Name += Segment;
213 Name.push_back(',');
214 Name += Section;
Michael J. Spencerf13f4422010-11-26 04:16:08 +0000215
Chris Lattner20731122010-04-08 20:30:37 +0000216 // Do the lookup, if we have a hit, return it.
217 const MCSectionMachO *&Entry = Map[Name.str()];
218 if (Entry) return Entry;
Michael J. Spencerf13f4422010-11-26 04:16:08 +0000219
Chris Lattner20731122010-04-08 20:30:37 +0000220 // Otherwise, return a new section.
Chris Lattner5418dd52010-04-08 21:26:26 +0000221 return Entry = new (*this) MCSectionMachO(Segment, Section, TypeAndAttributes,
222 Reserved2, Kind);
Chris Lattner20731122010-04-08 20:30:37 +0000223}
Chris Lattner5418dd52010-04-08 21:26:26 +0000224
Rafael Espindola36ef57d2010-11-10 19:05:07 +0000225const MCSectionELF *MCContext::
Chris Lattner5418dd52010-04-08 21:26:26 +0000226getELFSection(StringRef Section, unsigned Type, unsigned Flags,
Rafael Espindolaa3e9a222010-11-11 18:13:52 +0000227 SectionKind Kind) {
228 return getELFSection(Section, Type, Flags, Kind, 0, "");
229}
230
231const MCSectionELF *MCContext::
232getELFSection(StringRef Section, unsigned Type, unsigned Flags,
233 SectionKind Kind, unsigned EntrySize, StringRef Group) {
Chris Lattner5418dd52010-04-08 21:26:26 +0000234 if (ELFUniquingMap == 0)
235 ELFUniquingMap = new ELFUniqueMapTy();
236 ELFUniqueMapTy &Map = *(ELFUniqueMapTy*)ELFUniquingMap;
Michael J. Spencerf13f4422010-11-26 04:16:08 +0000237
Chris Lattner5418dd52010-04-08 21:26:26 +0000238 // Do the lookup, if we have a hit, return it.
239 StringMapEntry<const MCSectionELF*> &Entry = Map.GetOrCreateValue(Section);
240 if (Entry.getValue()) return Entry.getValue();
Michael J. Spencerf13f4422010-11-26 04:16:08 +0000241
Jan Wen Voungefbdbe52010-09-30 05:59:22 +0000242 // Possibly refine the entry size first.
243 if (!EntrySize) {
244 EntrySize = MCSectionELF::DetermineEntrySize(Kind);
245 }
Rafael Espindolaa3e9a222010-11-11 18:13:52 +0000246
247 MCSymbol *GroupSym = NULL;
248 if (!Group.empty())
249 GroupSym = GetOrCreateSymbol(Group);
250
Chris Lattner5418dd52010-04-08 21:26:26 +0000251 MCSectionELF *Result = new (*this) MCSectionELF(Entry.getKey(), Type, Flags,
Rafael Espindolaa3e9a222010-11-11 18:13:52 +0000252 Kind, EntrySize, GroupSym);
Chris Lattner5418dd52010-04-08 21:26:26 +0000253 Entry.setValue(Result);
254 return Result;
255}
256
Rafael Espindolaa3e9a222010-11-11 18:13:52 +0000257const MCSectionELF *MCContext::CreateELFGroupSection() {
258 MCSectionELF *Result =
Rafael Espindolaaea49582011-01-23 04:28:49 +0000259 new (*this) MCSectionELF(".group", ELF::SHT_GROUP, 0,
Rafael Espindolaa3e9a222010-11-11 18:13:52 +0000260 SectionKind::getReadOnly(), 4, NULL);
261 return Result;
262}
263
Chris Lattner02844932010-05-07 21:49:09 +0000264const MCSection *MCContext::getCOFFSection(StringRef Section,
265 unsigned Characteristics,
266 int Selection,
267 SectionKind Kind) {
Chris Lattner87cffa92010-05-07 17:17:41 +0000268 if (COFFUniquingMap == 0)
269 COFFUniquingMap = new COFFUniqueMapTy();
270 COFFUniqueMapTy &Map = *(COFFUniqueMapTy*)COFFUniquingMap;
Michael J. Spencerf13f4422010-11-26 04:16:08 +0000271
Chris Lattner87cffa92010-05-07 17:17:41 +0000272 // Do the lookup, if we have a hit, return it.
273 StringMapEntry<const MCSectionCOFF*> &Entry = Map.GetOrCreateValue(Section);
274 if (Entry.getValue()) return Entry.getValue();
Michael J. Spencerf13f4422010-11-26 04:16:08 +0000275
Chris Lattner02844932010-05-07 21:49:09 +0000276 MCSectionCOFF *Result = new (*this) MCSectionCOFF(Entry.getKey(),
277 Characteristics,
278 Selection, Kind);
Michael J. Spencerf13f4422010-11-26 04:16:08 +0000279
Chris Lattner87cffa92010-05-07 17:17:41 +0000280 Entry.setValue(Result);
281 return Result;
282}
Kevin Enderbye5930f12010-07-28 20:55:35 +0000283
284//===----------------------------------------------------------------------===//
285// Dwarf Management
286//===----------------------------------------------------------------------===//
287
288/// GetDwarfFile - takes a file name an number to place in the dwarf file and
289/// directory tables. If the file number has already been allocated it is an
290/// error and zero is returned and the client reports the error, else the
291/// allocated file number is returned. The file numbers may be in any order.
Nick Lewycky40f8f2f2011-10-17 23:05:28 +0000292unsigned MCContext::GetDwarfFile(StringRef Directory, StringRef FileName,
293 unsigned FileNumber) {
Kevin Enderbye5930f12010-07-28 20:55:35 +0000294 // TODO: a FileNumber of zero says to use the next available file number.
295 // Note: in GenericAsmParser::ParseDirectiveFile() FileNumber was checked
296 // to not be less than one. This needs to be change to be not less than zero.
297
298 // Make space for this FileNumber in the MCDwarfFiles vector if needed.
299 if (FileNumber >= MCDwarfFiles.size()) {
300 MCDwarfFiles.resize(FileNumber + 1);
301 } else {
302 MCDwarfFile *&ExistingFile = MCDwarfFiles[FileNumber];
303 if (ExistingFile)
304 // It is an error to use see the same number more than once.
305 return 0;
306 }
307
308 // Get the new MCDwarfFile slot for this FileNumber.
309 MCDwarfFile *&File = MCDwarfFiles[FileNumber];
310
Nick Lewycky40f8f2f2011-10-17 23:05:28 +0000311 if (Directory.empty()) {
312 // Separate the directory part from the basename of the FileName.
NAKAMURA Takumi30396ba2012-07-03 03:59:29 +0000313 StringRef tFileName = sys::path::filename(FileName);
314 if (!tFileName.empty()) {
315 Directory = sys::path::parent_path(FileName);
316 if (!Directory.empty())
NAKAMURA Takumi09e35102012-07-03 06:01:27 +0000317 FileName = tFileName;
Kevin Enderby82ed3be2011-11-01 23:39:05 +0000318 }
Nick Lewycky40f8f2f2011-10-17 23:05:28 +0000319 }
Kevin Enderbye5930f12010-07-28 20:55:35 +0000320
321 // Find or make a entry in the MCDwarfDirs vector for this Directory.
Kevin Enderbye5930f12010-07-28 20:55:35 +0000322 // Capture directory name.
Nick Lewycky40f8f2f2011-10-17 23:05:28 +0000323 unsigned DirIndex;
324 if (Directory.empty()) {
325 // For FileNames with no directories a DirIndex of 0 is used.
326 DirIndex = 0;
Kevin Enderbye5930f12010-07-28 20:55:35 +0000327 } else {
Nick Lewyckyf895efa2011-10-12 20:20:48 +0000328 DirIndex = 0;
329 for (unsigned End = MCDwarfDirs.size(); DirIndex < End; DirIndex++) {
Benjamin Kramerbccfec62010-07-29 13:53:19 +0000330 if (Directory == MCDwarfDirs[DirIndex])
Kevin Enderbyd94dacf2010-08-31 22:55:11 +0000331 break;
Kevin Enderbye5930f12010-07-28 20:55:35 +0000332 }
333 if (DirIndex >= MCDwarfDirs.size()) {
Benjamin Kramerbccfec62010-07-29 13:53:19 +0000334 char *Buf = static_cast<char *>(Allocate(Directory.size()));
335 memcpy(Buf, Directory.data(), Directory.size());
336 MCDwarfDirs.push_back(StringRef(Buf, Directory.size()));
Kevin Enderbye5930f12010-07-28 20:55:35 +0000337 }
Kevin Enderby7221b762010-08-09 22:52:14 +0000338 // The DirIndex is one based, as DirIndex of 0 is used for FileNames with
339 // no directories. MCDwarfDirs[] is unlike MCDwarfFiles[] in that the
Nick Lewycky40f8f2f2011-10-17 23:05:28 +0000340 // directory names are stored at MCDwarfDirs[DirIndex-1] where FileNames
341 // are stored at MCDwarfFiles[FileNumber].Name .
Kevin Enderby7221b762010-08-09 22:52:14 +0000342 DirIndex++;
Kevin Enderbye5930f12010-07-28 20:55:35 +0000343 }
Michael J. Spencerf13f4422010-11-26 04:16:08 +0000344
Kevin Enderbye5930f12010-07-28 20:55:35 +0000345 // Now make the MCDwarfFile entry and place it in the slot in the MCDwarfFiles
346 // vector.
Nick Lewycky40f8f2f2011-10-17 23:05:28 +0000347 char *Buf = static_cast<char *>(Allocate(FileName.size()));
348 memcpy(Buf, FileName.data(), FileName.size());
349 File = new (*this) MCDwarfFile(StringRef(Buf, FileName.size()), DirIndex);
Kevin Enderbye5930f12010-07-28 20:55:35 +0000350
351 // return the allocated FileNumber.
352 return FileNumber;
353}
Kevin Enderby1264b7c2010-08-24 20:32:42 +0000354
Kevin Enderbya68d0042010-10-04 20:17:24 +0000355/// isValidDwarfFileNumber - takes a dwarf file number and returns true if it
Kevin Enderby1264b7c2010-08-24 20:32:42 +0000356/// currently is assigned and false otherwise.
Kevin Enderbya68d0042010-10-04 20:17:24 +0000357bool MCContext::isValidDwarfFileNumber(unsigned FileNumber) {
Kevin Enderby1264b7c2010-08-24 20:32:42 +0000358 if(FileNumber == 0 || FileNumber >= MCDwarfFiles.size())
359 return false;
360
Kevin Enderbya68d0042010-10-04 20:17:24 +0000361 return MCDwarfFiles[FileNumber] != 0;
Kevin Enderby1264b7c2010-08-24 20:32:42 +0000362}
Jim Grosbachb18b4092012-01-26 23:20:11 +0000363
364void MCContext::FatalError(SMLoc Loc, const Twine &Msg) {
365 // If we have a source manager and a location, use it. Otherwise just
366 // use the generic report_fatal_error().
367 if (!SrcMgr || Loc == SMLoc())
368 report_fatal_error(Msg);
369
370 // Use the source manager to print the message.
371 SrcMgr->PrintMessage(Loc, SourceMgr::DK_Error, Msg);
372
373 // If we reached here, we are failing ungracefully. Run the interrupt handlers
374 // to make sure any special cleanups get done, in particular that we remove
375 // files registered with RemoveFileOnSignal.
376 sys::RunInterruptHandlers();
377 exit(1);
378}