[clang] ca91538 - [MC] Move AllowTemporaryLabels setting to MCContext::MCContext
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 12 16:43:02 PDT 2024
Author: Fangrui Song
Date: 2024-06-12T16:42:58-07:00
New Revision: ca91538c9c6f5328f398ac849dcc4230824b007e
URL: https://github.com/llvm/llvm-project/commit/ca91538c9c6f5328f398ac849dcc4230824b007e
DIFF: https://github.com/llvm/llvm-project/commit/ca91538c9c6f5328f398ac849dcc4230824b007e.diff
LOG: [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.
Added:
Modified:
clang/tools/driver/cc1as_main.cpp
llvm/lib/CodeGen/LLVMTargetMachine.cpp
llvm/lib/MC/MCContext.cpp
llvm/tools/llvm-ml/llvm-ml.cpp
Removed:
################################################################################
diff --git a/clang/tools/driver/cc1as_main.cpp b/clang/tools/driver/cc1as_main.cpp
index 4eb753a7297a9..ce1e181042609 100644
--- a/clang/tools/driver/cc1as_main.cpp
+++ b/clang/tools/driver/cc1as_main.cpp
@@ -429,6 +429,7 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
MCOptions.MCRelaxAll = Opts.RelaxAll;
MCOptions.EmitDwarfUnwind = Opts.EmitDwarfUnwind;
MCOptions.EmitCompactUnwindNonCanonical = Opts.EmitCompactUnwindNonCanonical;
+ MCOptions.MCSaveTempLabels = Opts.SaveTemporaryLabels;
MCOptions.X86RelaxRelocations = Opts.RelaxELFRelocations;
MCOptions.CompressDebugSections = Opts.CompressDebugSections;
MCOptions.AsSecureLogFile = Opts.AsSecureLogFile;
@@ -483,8 +484,6 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
MOFI->setDarwinTargetVariantSDKVersion(Opts.DarwinTargetVariantSDKVersion);
Ctx.setObjectFileInfo(MOFI.get());
- if (Opts.SaveTemporaryLabels)
- Ctx.setAllowTemporaryLabels(false);
if (Opts.GenDwarfForAssembly)
Ctx.setGenDwarfForAssembly(true);
if (!Opts.DwarfDebugFlags.empty())
diff --git a/llvm/lib/CodeGen/LLVMTargetMachine.cpp b/llvm/lib/CodeGen/LLVMTargetMachine.cpp
index 94ab8ed442eb7..1d13173632833 100644
--- a/llvm/lib/CodeGen/LLVMTargetMachine.cpp
+++ b/llvm/lib/CodeGen/LLVMTargetMachine.cpp
@@ -150,9 +150,6 @@ bool LLVMTargetMachine::addAsmPrinter(PassManagerBase &PM,
Expected<std::unique_ptr<MCStreamer>> LLVMTargetMachine::createMCStreamer(
raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
MCContext &Context) {
- if (Options.MCOptions.MCSaveTempLabels)
- Context.setAllowTemporaryLabels(false);
-
const MCSubtargetInfo &STI = *getMCSubtargetInfo();
const MCAsmInfo &MAI = *getMCAsmInfo();
const MCRegisterInfo &MRI = *getMCRegisterInfo();
@@ -272,8 +269,6 @@ bool LLVMTargetMachine::addPassesToEmitMC(PassManagerBase &PM, MCContext *&Ctx,
// libunwind is unable to load compact unwind dynamically, so we must generate
// DWARF unwind info for the JIT.
Options.MCOptions.EmitDwarfUnwind = EmitDwarfUnwindType::Always;
- if (Options.MCOptions.MCSaveTempLabels)
- Ctx->setAllowTemporaryLabels(false);
// Create the code emitter for the target if it exists. If not, .o file
// emission fails.
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index 1590054717960..fa1b095d42a29 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -74,6 +74,7 @@ MCContext::MCContext(const Triple &TheTriple, const MCAsmInfo *mai,
InlineAsmUsedLabelNames(Allocator),
CurrentDwarfLoc(0, 0, 0, DWARF2_FLAG_IS_STMT, 0, 0),
AutoReset(DoAutoReset), TargetOptions(TargetOpts) {
+ AllowTemporaryLabels = !(TargetOptions && TargetOptions->MCSaveTempLabels);
SecureLogFile = TargetOptions ? TargetOptions->AsSecureLogFile : "";
if (SrcMgr && SrcMgr->getNumBuffers())
@@ -179,7 +180,6 @@ void MCContext::reset() {
ELFSeenGenericMergeableSections.clear();
NextID.clear();
- AllowTemporaryLabels = true;
DwarfLocSeen = false;
GenDwarfForAssembly = false;
GenDwarfFileNumber = 0;
diff --git a/llvm/tools/llvm-ml/llvm-ml.cpp b/llvm/tools/llvm-ml/llvm-ml.cpp
index f1f39af059aa4..24643bd4296be 100644
--- a/llvm/tools/llvm-ml/llvm-ml.cpp
+++ b/llvm/tools/llvm-ml/llvm-ml.cpp
@@ -263,6 +263,7 @@ int llvm_ml_main(int Argc, char **Argv, const llvm::ToolContext &) {
MCTargetOptions MCOptions;
MCOptions.AssemblyLanguage = "masm";
MCOptions.MCFatalWarnings = InputArgs.hasArg(OPT_fatal_warnings);
+ MCOptions.MCSaveTempLabels = InputArgs.hasArg(OPT_save_temp_labels);
Triple TheTriple = GetTriple(ProgName, InputArgs);
std::string Error;
@@ -330,9 +331,6 @@ int llvm_ml_main(int Argc, char **Argv, const llvm::ToolContext &) {
Ctx, /*PIC=*/false, /*LargeCodeModel=*/true));
Ctx.setObjectFileInfo(MOFI.get());
- if (InputArgs.hasArg(OPT_save_temp_labels))
- Ctx.setAllowTemporaryLabels(false);
-
// Set compilation information.
SmallString<128> CWD;
if (!sys::fs::current_path(CWD))
More information about the cfe-commits
mailing list