Skip to content

Commit ca91538

Browse files
committed
[MC] Move AllowTemporaryLabels setting to MCContext::MCContext
Also delete `AllowTemporaryLabels = true` from MCContext::reset: when llc supports -save-temp-labels in the next change, this assignment should be removed to support -compile-twice.
1 parent e80c595 commit ca91538

File tree

4 files changed

+3
-11
lines changed

4 files changed

+3
-11
lines changed

clang/tools/driver/cc1as_main.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
429429
MCOptions.MCRelaxAll = Opts.RelaxAll;
430430
MCOptions.EmitDwarfUnwind = Opts.EmitDwarfUnwind;
431431
MCOptions.EmitCompactUnwindNonCanonical = Opts.EmitCompactUnwindNonCanonical;
432+
MCOptions.MCSaveTempLabels = Opts.SaveTemporaryLabels;
432433
MCOptions.X86RelaxRelocations = Opts.RelaxELFRelocations;
433434
MCOptions.CompressDebugSections = Opts.CompressDebugSections;
434435
MCOptions.AsSecureLogFile = Opts.AsSecureLogFile;
@@ -483,8 +484,6 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
483484
MOFI->setDarwinTargetVariantSDKVersion(Opts.DarwinTargetVariantSDKVersion);
484485
Ctx.setObjectFileInfo(MOFI.get());
485486

486-
if (Opts.SaveTemporaryLabels)
487-
Ctx.setAllowTemporaryLabels(false);
488487
if (Opts.GenDwarfForAssembly)
489488
Ctx.setGenDwarfForAssembly(true);
490489
if (!Opts.DwarfDebugFlags.empty())

llvm/lib/CodeGen/LLVMTargetMachine.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,6 @@ bool LLVMTargetMachine::addAsmPrinter(PassManagerBase &PM,
150150
Expected<std::unique_ptr<MCStreamer>> LLVMTargetMachine::createMCStreamer(
151151
raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
152152
MCContext &Context) {
153-
if (Options.MCOptions.MCSaveTempLabels)
154-
Context.setAllowTemporaryLabels(false);
155-
156153
const MCSubtargetInfo &STI = *getMCSubtargetInfo();
157154
const MCAsmInfo &MAI = *getMCAsmInfo();
158155
const MCRegisterInfo &MRI = *getMCRegisterInfo();
@@ -272,8 +269,6 @@ bool LLVMTargetMachine::addPassesToEmitMC(PassManagerBase &PM, MCContext *&Ctx,
272269
// libunwind is unable to load compact unwind dynamically, so we must generate
273270
// DWARF unwind info for the JIT.
274271
Options.MCOptions.EmitDwarfUnwind = EmitDwarfUnwindType::Always;
275-
if (Options.MCOptions.MCSaveTempLabels)
276-
Ctx->setAllowTemporaryLabels(false);
277272

278273
// Create the code emitter for the target if it exists. If not, .o file
279274
// emission fails.

llvm/lib/MC/MCContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ MCContext::MCContext(const Triple &TheTriple, const MCAsmInfo *mai,
7474
InlineAsmUsedLabelNames(Allocator),
7575
CurrentDwarfLoc(0, 0, 0, DWARF2_FLAG_IS_STMT, 0, 0),
7676
AutoReset(DoAutoReset), TargetOptions(TargetOpts) {
77+
AllowTemporaryLabels = !(TargetOptions && TargetOptions->MCSaveTempLabels);
7778
SecureLogFile = TargetOptions ? TargetOptions->AsSecureLogFile : "";
7879

7980
if (SrcMgr && SrcMgr->getNumBuffers())
@@ -179,7 +180,6 @@ void MCContext::reset() {
179180
ELFSeenGenericMergeableSections.clear();
180181

181182
NextID.clear();
182-
AllowTemporaryLabels = true;
183183
DwarfLocSeen = false;
184184
GenDwarfForAssembly = false;
185185
GenDwarfFileNumber = 0;

llvm/tools/llvm-ml/llvm-ml.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ int llvm_ml_main(int Argc, char **Argv, const llvm::ToolContext &) {
263263
MCTargetOptions MCOptions;
264264
MCOptions.AssemblyLanguage = "masm";
265265
MCOptions.MCFatalWarnings = InputArgs.hasArg(OPT_fatal_warnings);
266+
MCOptions.MCSaveTempLabels = InputArgs.hasArg(OPT_save_temp_labels);
266267

267268
Triple TheTriple = GetTriple(ProgName, InputArgs);
268269
std::string Error;
@@ -330,9 +331,6 @@ int llvm_ml_main(int Argc, char **Argv, const llvm::ToolContext &) {
330331
Ctx, /*PIC=*/false, /*LargeCodeModel=*/true));
331332
Ctx.setObjectFileInfo(MOFI.get());
332333

333-
if (InputArgs.hasArg(OPT_save_temp_labels))
334-
Ctx.setAllowTemporaryLabels(false);
335-
336334
// Set compilation information.
337335
SmallString<128> CWD;
338336
if (!sys::fs::current_path(CWD))

0 commit comments

Comments
 (0)