Page MenuHomePhabricator

Annotate `` as `returns_twice`
Needs ReviewPublic

Authored by xtkoba on Sep 3 2021, 10:40 AM.



In LLVM, some optimizations are disabled for functions that return twice. For instance, register coalescing in those functions is disabled by D77767. Currently, this does not apply to __builtin_setjmp, because the intrinsic function is not annotated as returns_twice.

In the proposed change, we annotate as returns_twice. This fixes PR50234.

Diff Detail

Unit TestsFailed

121,540 msx64 debian > AddressSanitizer-x86_64-linux-dynamic.TestCases/Linux::uar_signals.cpp
Script: -- : 'RUN: at line 3'; /var/lib/buildkite-agent/builds/llvm-project/build/./bin/clang --driver-mode=g++ -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only -m64 -shared-libasan -std=c++11 -O1 /var/lib/buildkite-agent/builds/llvm-project/compiler-rt/test/asan/TestCases/Linux/uar_signals.cpp -o /var/lib/buildkite-agent/builds/llvm-project/build/projects/compiler-rt/test/asan/X86_64LinuxDynamicConfig/TestCases/Linux/Output/uar_signals.cpp.tmp -pthread && /var/lib/buildkite-agent/builds/llvm-project/build/projects/compiler-rt/test/asan/X86_64LinuxDynamicConfig/TestCases/Linux/Output/uar_signals.cpp.tmp

Event Timeline

xtkoba requested review of this revision.Sep 3 2021, 10:40 AM
xtkoba created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptSep 3 2021, 10:40 AM
xtkoba updated this revision to Diff 370642.Sep 3 2021, 12:18 PM
  • Tests revised.
  • Reformatted.
xtkoba added a comment.Sep 3 2021, 9:14 PM

It has been revealed that this also fixes PR51729.

xtkoba updated this revision to Diff 370725.Sep 4 2021, 3:25 AM

Diff context extended

dim added a subscriber: dim.Sep 5 2021, 10:36 AM

I'm not a reviewer, but this looks good to me. (At first I thought that the required tablegen additions were missing, but they were at the end of the list of files so I missed them :) )

LG, but I'd prefer an explicit IR test. There should be some, if not add a new one to verify we add returns twice properly.