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

70 msx64 debian > LLVM.CodeGen/PowerPC::sjlj.ll
Script: -- : 'RUN: at line 1'; /var/lib/buildkite-agent/builds/llvm-project/build/bin/llc < /var/lib/buildkite-agent/builds/llvm-project/llvm/test/CodeGen/PowerPC/sjlj.ll -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr7 -verify-machineinstrs | /var/lib/buildkite-agent/builds/llvm-project/build/bin/FileCheck /var/lib/buildkite-agent/builds/llvm-project/llvm/test/CodeGen/PowerPC/sjlj.ll
50 msx64 debian > LLVM.CodeGen/Thumb2::setjmp_longjmp.ll
Script: -- : 'RUN: at line 2'; /var/lib/buildkite-agent/builds/llvm-project/build/bin/llc /var/lib/buildkite-agent/builds/llvm-project/llvm/test/CodeGen/Thumb2/setjmp_longjmp.ll -o - | /var/lib/buildkite-agent/builds/llvm-project/build/bin/FileCheck /var/lib/buildkite-agent/builds/llvm-project/llvm/test/CodeGen/Thumb2/setjmp_longjmp.ll
40 msx64 debian > LLVM.CodeGen/X86::shadow-stack.ll
Script: -- : 'RUN: at line 2'; /var/lib/buildkite-agent/builds/llvm-project/build/bin/llc -mtriple x86_64-apple-macosx10.13.0 < /var/lib/buildkite-agent/builds/llvm-project/llvm/test/CodeGen/X86/shadow-stack.ll | /var/lib/buildkite-agent/builds/llvm-project/build/bin/FileCheck /var/lib/buildkite-agent/builds/llvm-project/llvm/test/CodeGen/X86/shadow-stack.ll --check-prefix=X86_64
160 msx64 windows > LLVM.CodeGen/PowerPC::sjlj.ll
Script: -- : 'RUN: at line 1'; c:\ws\w6\llvm-project\premerge-checks\build\bin\llc.exe < C:\ws\w6\llvm-project\premerge-checks\llvm\test\CodeGen\PowerPC\sjlj.ll -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr7 -verify-machineinstrs | c:\ws\w6\llvm-project\premerge-checks\build\bin\filecheck.exe C:\ws\w6\llvm-project\premerge-checks\llvm\test\CodeGen\PowerPC\sjlj.ll
60 msx64 windows > LLVM.CodeGen/Thumb2::setjmp_longjmp.ll
Script: -- : 'RUN: at line 2'; c:\ws\w6\llvm-project\premerge-checks\build\bin\llc.exe C:\ws\w6\llvm-project\premerge-checks\llvm\test\CodeGen\Thumb2\setjmp_longjmp.ll -o - | c:\ws\w6\llvm-project\premerge-checks\build\bin\filecheck.exe C:\ws\w6\llvm-project\premerge-checks\llvm\test\CodeGen\Thumb2\setjmp_longjmp.ll
View Full Test Results (6 Failed)

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.