Skip to content

Commit 34cf263

Browse files
rorthtru
authored andcommitted
[sanitizer_common] Remove hacks for __builtin_return_address abuse on SPARC
As detailed in Issue llvm#57624, the introduction of `__builtin_extract_return_address` to `GET_CALLER_PC` in 4248f32 <https://reviews.llvm.org/rG4248f32b9ebe87c7af8ee53911efd47c2652f488> broke `TestCases/Misc/missing_return.cpp` on Solaris/SPARC. Unlike most other targets, the builtin isn't a no-op on SPARC and thus has always been necessary. Its lack had previously been worked around by calls to `GetNextInstructionPc` in `sanitizer_stacktrace_sparc.cpp` (`BufferedStackTrace::UnwindFast`) and `sanitizer_unwind_linux_libcdep.cpp` (`BufferedStackTrace::UnwindSlow`). However, those calls are superfluous now and actually harmful. This patch removes those hacks, fixing the failure. Tested on `sparcv9-sun-solaris2.11` and on `sparc-sun-solaris2.11` in the GCC tree. On the latter, several more testcase failures had been caused by this issue since ASan actually works with `gcc` on SPARC, unlike `clang`. Differential Revision: https://reviews.llvm.org/D156504 (cherry picked from commit 679c076)
1 parent e67ec17 commit 34cf263

File tree

2 files changed

+0
-12
lines changed

2 files changed

+0
-12
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_sparc.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,7 @@ void BufferedStackTrace::UnwindFast(uptr pc, uptr bp, uptr stack_top,
3030
// TODO(yln): add arg sanity check for stack_top/stack_bottom
3131
CHECK_GE(max_depth, 2);
3232
const uptr kPageSize = GetPageSizeCached();
33-
#if defined(__GNUC__)
34-
// __builtin_return_address returns the address of the call instruction
35-
// on the SPARC and not the return address, so we need to compensate.
36-
trace_buffer[0] = GetNextInstructionPc(pc);
37-
#else
3833
trace_buffer[0] = pc;
39-
#endif
4034
size = 1;
4135
if (stack_top < 4096) return; // Sanity check for stack top.
4236
// Flush register windows to memory

compiler-rt/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,7 @@ void BufferedStackTrace::UnwindSlow(uptr pc, u32 max_depth) {
139139
if (to_pop == 0 && size > 1)
140140
to_pop = 1;
141141
PopStackFrames(to_pop);
142-
#if defined(__GNUC__) && defined(__sparc__)
143-
// __builtin_return_address returns the address of the call instruction
144-
// on the SPARC and not the return address, so we need to compensate.
145-
trace_buffer[0] = GetNextInstructionPc(pc);
146-
#else
147142
trace_buffer[0] = pc;
148-
#endif
149143
}
150144

151145
void BufferedStackTrace::UnwindSlow(uptr pc, void *context, u32 max_depth) {

0 commit comments

Comments
 (0)