llvm-project/llvm/utils
Atmn Patel 1e55cf77f3 [LangRef] Define mustprogress attribute
LLVM IR currently assumes some form of forward progress. This form is
not explicitly defined anywhere, and is the cause of miscompilations
in most languages that are not C++11 or later. This implicit forward progress
guarantee can not be opted out of on a function level nor on a loop
level. Languages such as C (C11 and later), C++ (pre-C++11), and Rust
have different forward progress requirements and this needs to be
evident in the IR.

Specifically, C11 and onwards (6.8.5, Paragraph 6) states that "An
iteration statement whose controlling expression is not a constant
expression, that performs no input/output operations, does not access
volatile objects, and performs no synchronization or atomic operations
in its body, controlling expression, or (in the case of for statement)
its expression-3, may be assumed by the implementation to terminate."
C++11 and onwards does not have this assumption, and instead assumes
that every thread must make progress as defined in [intro.progress] when
it comes to scheduling.

This was initially brought up in [0] as a bug, a solution was presented
in [1] which is the current workaround, and the predecessor to this
change was [2].

After defining a notion of forward progress for IR, there are two
options to address this:
1) Set the default to assuming Forward Progress and provide an opt-out for functions and an opt-in for loops.
2) Set the default to not assuming Forward Progress and provide an opt-in for functions, and an opt-in for loops.

Option 2) has been selected because only C++11 and onwards have a
forward progress requirement and it makes sense for them to opt-into it
via the defined `mustprogress` function attribute.  The `mustprogress`
function attribute indicates that the function is required to make
forward progress as defined. This is sharply in contrast to the status
quo where this is implicitly assumed. In addition, `willreturn` implies `mustprogress`.

The background for why this definition was chosen is in [3] and for why
the option was chosen is in [4] and the corresponding thread(s). The implementation is in D85393, the
clang patch is in D86841, the LoopDeletion patch is in D86844, the
Inliner patches are in D87180 and D87262, and there will be more
incoming.

[0] https://bugs.llvm.org/show_bug.cgi?id=965#c25
[1] https://lists.llvm.org/pipermail/llvm-dev/2017-October/118558.html
[2] https://reviews.llvm.org/D65718
[3] https://lists.llvm.org/pipermail/llvm-dev/2020-September/144919.html
[4] https://lists.llvm.org/pipermail/llvm-dev/2020-September/145023.html

Reviewed By: jdoerfert, efriedma, nikic

Differential Revision: https://reviews.llvm.org/D86233
2020-10-19 13:34:27 -04:00
..
FileCheck Internalize functions from various tools. NFC 2020-09-26 15:57:13 -07:00
KillTheDoctor [KillTheDoctor/CMake] Add missing keyword PRIVATE in target_link_libraries 2020-09-07 16:08:55 +03:00
LLVMVisualizers Add MSVC natvis visualisation of llvm::Type 2020-05-15 09:38:37 -04:00
Misc
PerfectShuffle revert parts of d7888149aa that several bots do not like 2020-03-25 14:05:07 -04:00
Reviewing
TableGen [ARM][SchedModels] Convert IsPredicatedPred to MCSchedPredicate 2020-10-19 11:37:54 +03:00
Target/ARM
UpdateTestChecks clang: Make changes in 7c8bb409f3 py2.7-compatible 2020-09-18 16:15:37 -04:00
benchmark [M680x0] Add google/benchmark's CycleTimer support for M68K 2020-10-07 14:58:36 -07:00
bugpoint
count
crosstool
docker Harmonize Python shebang 2020-07-16 21:53:45 +02:00
emacs [LangRef] Define mustprogress attribute 2020-10-19 13:34:27 -04:00
fpcmp
gdb-scripts Change to individual pretty printer classes, remove generic `make_printer`. 2020-03-11 15:04:03 +01:00
git Add a git hook script that can be manually setup to run some checks on every push 2020-06-24 21:13:43 +00:00
gn [gn build] Port 6154c4115c 2020-10-19 04:23:08 +00:00
jedit
kate [LangRef] Define mustprogress attribute 2020-10-19 13:34:27 -04:00
lint Harmonize Python shebang 2020-07-16 21:53:45 +02:00
lit [lit] Avoid calling realpath() for every printed message 2020-10-19 16:21:34 +01:00
llvm-build Use configure depends to trigger reconfiguration when LLVMBuild files change 2020-05-26 16:30:20 +01:00
llvm-lit Execute llvm-lit with the python found by CMake by default 2020-08-03 10:51:35 +01:00
llvm-locstats [llvm-dwarfdump][Stats] Clean up 2020-05-04 09:35:40 +02:00
not PrintStackTrace: don't symbolize if LLVM_DISABLE_SYMBOLIZATION is set 2020-08-21 11:27:13 -07:00
release Add flang to export.sh to it gets source tarballs in releases 2020-07-31 17:22:57 +02:00
sanitizers
testgen Harmonize Python shebang 2020-07-16 21:53:45 +02:00
textmate
unittest [cmake] Make gtest include directories a part of the library interface 2020-08-27 15:35:57 +02:00
valgrind
vim [LangRef] Define mustprogress attribute 2020-10-19 13:34:27 -04:00
vscode [LangRef] Define mustprogress attribute 2020-10-19 13:34:27 -04:00
yaml-bench
DSAclean.py Harmonize Python shebang 2020-07-16 21:53:45 +02:00
DSAextract.py Harmonize Python shebang 2020-07-16 21:53:45 +02:00
GenLibDeps.pl
GetSourceVersion
LLVMBuild.txt
UpdateCMakeLists.pl
abtest.py
add_argument_names.py
bisect
bisect-skip-count
bugpoint_gisel_reducer.py
check-each-file
check_ninja_deps.py [utils] New script `check_ninja_deps.py` 2020-07-14 14:54:08 +01:00
chunk-print-before-all.py [Tools] Fixed bug with llvm/utils/chunk-print-before-all.py script. 2020-04-09 22:24:55 +00:00
clang-parse-diagnostics-file utils: Tweak clang-parse-diagnostics-file for modules includes 2020-04-02 14:16:26 -07:00
codegen-diff
collect_and_build_with_pgo.py
convert-constraint-log-to-z3.py Recommit "[ConstraintSystem] Add helpers to deal with linear constraints." 2020-09-15 12:07:26 +01:00
countloc.sh
create_ladder_graph.py
demangle_tree.py
extract_symbols.py [AIX] Make sure we use export lists for plugins 2020-05-08 14:00:25 -04:00
extract_vplan.py [utils] Fix regexp in llvm/utils/extract_vplan.py to extract VPlans. 2020-08-19 08:57:12 +01:00
findmisopt
findoptdiff Recommit "[IPConstProp] Remove and move tests to SCCP." 2020-08-02 22:23:54 +01:00
findsym.pl
getsrcs.sh
indirect_calls.py
lldbDataFormatters.py Bring llvm::Optional data formatter back in sync with the implementation. 2020-08-26 15:10:39 -07:00
llvm-compilers-check
llvm-gisel-cov.py
llvm-native-gxx
llvm.grm [LangRef] Define mustprogress attribute 2020-10-19 13:34:27 -04:00
llvmdo
llvmgrep
merge-stats.py [NFC] Add utility to sum/merge stats files 2020-08-07 19:02:42 +02:00
prepare-code-coverage-artifact.py
schedcover.py Harmonize Python shebang 2020-07-16 21:53:45 +02:00
shuffle_fuzz.py
shuffle_select_fuzz_tester.py
sort_includes.py
unicode-case-fold.py
update_analyze_test_checks.py Update update_analyze_test_checks.py to support API changes from D83004 2020-09-21 16:09:05 +01:00
update_cc_test_checks.py [UpdateCCTestChecks] Include generated functions if asked 2020-09-18 06:34:59 -05:00
update_llc_test_checks.py [UpdateCCTestChecks] Include generated functions if asked 2020-09-18 06:34:59 -05:00
update_mca_test_checks.py
update_mir_test_checks.py
update_test_checks.py [UpdateCCTestChecks] Include generated functions if asked 2020-09-18 06:34:59 -05:00
wciia.py