Skip to content

Commit 8ad092f

Browse files
committed
[cc1as] Respect -mrelax-all
So that `clang -c -mrelax-all a.s` sets MCRelaxAll and assembles JMP/JCC to a near jump instead of silently ignoring `-mrelax-all`.
1 parent a1aea37 commit 8ad092f

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

clang/test/Misc/cc1as-relax-all.s

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// REQUIRES: x86-registered-target
2+
// RUN: %clang -cc1as -triple x86_64 -filetype obj -mrelax-all %s -o %t.o
3+
// RUN: llvm-objdump -d %t.o | FileCheck %s
4+
5+
// CHECK: <.text>:
6+
// CHECK-NEXT: 0: e9 06 00 00 00 jmp 0xb <foo>
7+
// CHECK-NEXT: 5: 0f 84 00 00 00 00 je 0xb <foo>
8+
// CHECK-EMPTY:
9+
10+
jmp foo
11+
je foo
12+
13+
foo: ret

clang/tools/driver/cc1as_main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
426426
assert(MRI && "Unable to create target register info!");
427427

428428
MCTargetOptions MCOptions;
429+
MCOptions.MCRelaxAll = Opts.RelaxAll;
429430
MCOptions.EmitDwarfUnwind = Opts.EmitDwarfUnwind;
430431
MCOptions.EmitCompactUnwindNonCanonical = Opts.EmitCompactUnwindNonCanonical;
431432
MCOptions.X86RelaxRelocations = Opts.RelaxELFRelocations;

0 commit comments

Comments
 (0)