NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
toolchain/52253: clang seems to unconditionally emits frame pointer code
>Number: 52253
>Category: toolchain
>Synopsis: clang seems to unconditionally emits frame pointer code
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: toolchain-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue May 23 01:25:00 +0000 2017
>Originator: coypu
>Release: NetBSD 7.99.71
>Organization:
>Environment:
NetBSD loggy 7.99.71 NetBSD 7.99.71 (SAFE) #0: Sat May 13 15:28:53 IDT 2017 fly@loggy:/usr/src/sys/arch/amd64/compile/SAFE amd64
>Description:
While experimenting with compiling to mips, I noticed frame pointer code is always emitted, even if -On is used. I believe this is the case for all architectures (I see a difference in x86
with clang 4.0.0 from pkgsrc, compare:
$ clang --target=mipsel--netbsd7.99 -nostdlib -o test test.c -O3
/usr/bin/ld: warning: cannot find entry symbol __start; defaulting to 0x20000
$ llvm-objdump -d test
test: file format ELF32-mips
Disassembly of section .text:
main:
20000: f8 ff bd 27 addiu $sp, $sp, -8
20004: 04 00 be af sw $fp, 4($sp)
20008: 25 f0 a0 03 move $fp, $sp
2000c: 00 00 02 24 addiu $2, $zero, 0
20010: 25 e8 c0 03 move $sp, $fp
20014: 04 00 be 8f lw $fp, 4($sp)
20018: 08 00 e0 03 jr $ra
2001c: 08 00 bd 27 addiu $sp, $sp, 8
$ clang --target=mipsel--netbsd7.99 -nostdlib -o test test.c -O3 -fomit-frame-pointer
/usr/bin/ld: warning: cannot find entry symbol __start; defaulting to 0x20000
$ llvm-objdump -d test
test: file format ELF32-mips
Disassembly of section .text:
main:
20000: 08 00 e0 03 jr $ra
20004: 00 00 02 24 addiu $2, $zero, 0
>How-To-Repeat:
>Fix:
Presumably the following untested patch, but it needs to undergo some level of testing / architecture specific limitations.
This file has moved in clang upstream, and the code is now located in:
https://github.com/llvm-mirror/clang/blob/master/lib/Driver/ToolChains/Clang.cpp#L520-L570
Index: Tools.cpp
===================================================================
RCS file: /cvsroot/src/external/bsd/llvm/dist/clang/lib/Driver/Tools.cpp,v
retrieving revision 1.1.1.14
diff -u -p -r1.1.1.14 Tools.cpp
--- Tools.cpp 9 Feb 2017 17:38:05 -0000 1.1.1.14
+++ Tools.cpp 23 May 2017 01:05:09 -0000
@@ -3467,6 +3467,10 @@ static bool useFramePointerForTargetByDe
}
}
+ if (Triple.isOSNetBSD()) {
+ return !areOptimizationsEnabled(Args);
+ }
+
return true;
}
Home |
Main Index |
Thread Index |
Old Index