Skip to content

Commit a91c839

Browse files
committed
[MC] Move -save-temp-labels from llvm-mc to MCTargetOptionsCommandFlags
so that tools like llc can use the option as well. ca91538 is a prerequisite.
1 parent ca91538 commit a91c839

File tree

6 files changed

+40
-13
lines changed

6 files changed

+40
-13
lines changed

llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ bool getNoDeprecatedWarn();
4949

5050
bool getNoTypeCheck();
5151

52+
bool getSaveTempLabels();
53+
5254
bool getX86RelaxRelocations();
5355

5456
std::string getABIName();

llvm/lib/MC/MCTargetOptionsCommandFlags.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ MCOPT(bool, FatalWarnings)
4646
MCOPT(bool, NoWarn)
4747
MCOPT(bool, NoDeprecatedWarn)
4848
MCOPT(bool, NoTypeCheck)
49+
MCOPT(bool, SaveTempLabels)
4950
MCOPT(bool, X86RelaxRelocations)
5051
MCOPT(std::string, ABIName)
5152
MCOPT(std::string, AsSecureLogFile)
@@ -123,6 +124,10 @@ llvm::mc::RegisterMCTargetOptionsFlags::RegisterMCTargetOptionsFlags() {
123124
"no-type-check", cl::desc("Suppress type errors (Wasm)"));
124125
MCBINDOPT(NoTypeCheck);
125126

127+
static cl::opt<bool> SaveTempLabels(
128+
"save-temp-labels", cl::desc("Don't discard temporary labels"));
129+
MCBINDOPT(SaveTempLabels);
130+
126131
static cl::opt<bool> X86RelaxRelocations(
127132
"x86-relax-relocations",
128133
cl::desc(
@@ -156,6 +161,7 @@ MCTargetOptions llvm::mc::InitMCTargetOptionsFromFlags() {
156161
Options.MCNoWarn = getNoWarn();
157162
Options.MCNoDeprecatedWarn = getNoDeprecatedWarn();
158163
Options.MCNoTypeCheck = getNoTypeCheck();
164+
Options.MCSaveTempLabels = getSaveTempLabels();
159165
Options.X86RelaxRelocations = getX86RelaxRelocations();
160166
Options.EmitDwarfUnwind = getEmitDwarfUnwind();
161167
Options.EmitCompactUnwindNonCanonical = getEmitCompactUnwindNonCanonical();

llvm/test/CodeGen/X86/asm-label.ll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
; CHECK: jmp LBB0_9
88
; CHECK: LBB0_9: ## %cleanup
99

10+
; RUN: llc -filetype=obj -mtriple=x86_64 -O0 -save-temp-labels < %s | llvm-objdump -d - | FileCheck %s --check-prefix=SAVETEMP
11+
12+
; SAVETEMP: jne {{.*}} <.LBB0_1>
13+
; SAVETEMP-LABEL: <.LBB0_1>:
14+
1015
define void @foo() {
1116
entry:
1217
br i1 undef, label %land.lhs.true, label %if.end11

llvm/test/MC/ELF/empty-twice.ll

Lines changed: 0 additions & 6 deletions
This file was deleted.

llvm/test/MC/ELF/twice.ll

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
; Check that there is no persistent state in the ELF emitter that crashes us
2+
; when we try to reuse the pass manager
3+
; RUN: llc -compile-twice -filetype=obj %s -o -
4+
5+
; RUN: llc -compile-twice -filetype=obj -save-temp-labels %s -o - | llvm-objdump -d - | FileCheck %s
6+
7+
; CHECK-LABEL: <foo>:
8+
; CHECK: je {{.*}} <.LBB0_2>
9+
; CHECK-LABEL: <.LBB0_2>:
10+
11+
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
12+
target triple = "i386-pc-linux-gnu"
13+
14+
@var = external local_unnamed_addr global i32
15+
16+
define dso_local void @foo(i32 %a) {
17+
entry:
18+
%tobool.not = icmp eq i32 %a, 0
19+
br i1 %tobool.not, label %if.end, label %if.then
20+
21+
if.then: ; preds = %entry
22+
store i32 1, ptr @var
23+
br label %if.end
24+
25+
if.end: ; preds = %if.then, %entry
26+
ret void
27+
}

llvm/tools/llvm-mc/llvm-mc.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,6 @@ static cl::opt<std::string> MainFileName(
183183
cl::desc("Specifies the name we should consider the input file"),
184184
cl::cat(MCCategory));
185185

186-
static cl::opt<bool> SaveTempLabels("save-temp-labels",
187-
cl::desc("Don't discard temporary labels"),
188-
cl::cat(MCCategory));
189-
190186
static cl::opt<bool> LexMasmIntegers(
191187
"masm-integers",
192188
cl::desc("Enable binary and hex masm integers (0b110 and 0ABCh)"),
@@ -428,9 +424,6 @@ int main(int argc, char **argv) {
428424
TheTarget->createMCObjectFileInfo(Ctx, PIC, LargeCodeModel));
429425
Ctx.setObjectFileInfo(MOFI.get());
430426

431-
if (SaveTempLabels)
432-
Ctx.setAllowTemporaryLabels(false);
433-
434427
Ctx.setGenDwarfForAssembly(GenDwarfForAssembly);
435428
// Default to 4 for dwarf version.
436429
unsigned DwarfVersion = MCOptions.DwarfVersion ? MCOptions.DwarfVersion : 4;

0 commit comments

Comments
 (0)