[mlir][linalg] Add support for masked vectorization of `tensor.insert_slice` (1/N...
[llvm-project.git] / llvm / docs / DeveloperPolicy.rst
blobb125fcb0da7ab43d52f4db0367c8fba2e0201ddc
1 .. _developer_policy:
3 =====================
4 LLVM Developer Policy
5 =====================
7 .. contents::
8    :local:
10 Introduction
11 ============
13 This document contains the LLVM Developer Policy which defines the project's
14 policy towards developers and their contributions. The intent of this policy is
15 to eliminate miscommunication, rework, and confusion that might arise from the
16 distributed nature of LLVM's development.  By stating the policy in clear terms,
17 we hope each developer can know ahead of time what to expect when making LLVM
18 contributions.  This policy covers all llvm.org subprojects, including Clang,
19 LLDB, libc++, etc.
21 This policy is also designed to accomplish the following objectives:
23 #. Attract both users and developers to the LLVM project.
25 #. Make life as simple and easy for contributors as possible.
27 #. Keep the top of tree as stable as possible.
29 #. Establish awareness of the project's :ref:`copyright, license, and patent
30    policies <copyright-license-patents>` with contributors to the project.
32 This policy is aimed at frequent contributors to LLVM. People interested in
33 contributing one-off patches can do so in an informal way by sending them to the
34 `llvm-commits mailing list
35 <http://lists.llvm.org/mailman/listinfo/llvm-commits>`_ and engaging another
36 developer to see it through the process.
38 Developer Policies
39 ==================
41 This section contains policies that pertain to frequent LLVM developers.  We
42 always welcome `one-off patches`_ from people who do not routinely contribute to
43 LLVM, but we expect more from frequent contributors to keep the system as
44 efficient as possible for everyone.  Frequent LLVM contributors are expected to
45 meet the following requirements in order for LLVM to maintain a high standard of
46 quality.
48 Stay Informed
49 -------------
51 Developers should stay informed by reading the `LLVM Discourse forums`_ and subscribing
52 to the categories of interest for notifications.
54 Paying attention to changes being made by others is a good way to see what other people
55 are interested in and watching the flow of the project as a whole.
57 Contibutions to the project are made through :ref:`GitHub Pull Requests <github-reviews>`.
58 You can subscribe to notification for areas of the codebase by joining
59 one of the `pr-subscribers-* <https://github.com/orgs/llvm/teams?query=pr-subscribers>`_
60 GitHub teams. This `mapping <https://github.com/llvm/llvm-project/blob/main/.github/new-prs-labeler.yml>`_
61 indicates which team is associated with a particular paths in the repository.
63 You can also subscribe to the "commits" mailing list for a subproject you're interested in,
64 such as `llvm-commits
65 <http://lists.llvm.org/mailman/listinfo/llvm-commits>`_, `cfe-commits
66 <http://lists.llvm.org/mailman/listinfo/cfe-commits>`_, or `lldb-commits
67 <http://lists.llvm.org/mailman/listinfo/lldb-commits>`_.
69 Missing features and bugs are tracked through our `GitHub issue tracker <https://github.com/llvm/llvm-project/issues>`_
70 and assigned labels. We recommend that active developers monitor incoming issues.
71 You can subscribe for notification for specific components by joining
72 one of the `issue-subscribers-* <https://github.com/orgs/llvm/teams?query=issue-subscribers>`_
73 teams.
74 You may also subscribe to the `llvm-bugs
75 <http://lists.llvm.org/mailman/listinfo/llvm-bugs>`_ email list to keep track
76 of bugs and enhancements occurring in the entire project.  We really appreciate people
77 who are proactive at catching incoming bugs in their components and dealing with them
78 promptly.
80 Please be aware that all public LLVM mailing lists and discourse forums are public and archived, and
81 that notices of confidentiality or non-disclosure cannot be respected.
83 .. _patch:
84 .. _one-off patches:
86 Making and Submitting a Patch
87 -----------------------------
89 When making a patch for review, the goal is to make it as easy for the reviewer
90 to read it as possible.  As such, we recommend that you:
92 #. Make your patch against git main, not a branch, and not an old version
93    of LLVM.  This makes it easy to apply the patch.  For information on how to
94    clone from git, please see the :ref:`Getting Started Guide <sources>`.
96 #. Similarly, patches should be submitted soon after they are generated.  Old
97    patches may not apply correctly if the underlying code changes between the
98    time the patch was created and the time it is applied.
100 #. Once you have created your patch, create a
101    :ref:`GitHub Pull Request <github-reviews>` for
102    it (or commit it directly if applicable).
104 When submitting patches, please do not add confidentiality or non-disclosure
105 notices to the patches themselves.  These notices conflict with the LLVM
106 licensing terms and may result in your contribution being excluded.
108 .. _github-email-address:
110 Email Addresses
111 ---------------
113 The LLVM project uses email to communicate to contributors outside of the
114 GitHub platform about their past contributions. Primarily, our buildbot
115 infrastructure uses emails to contact contributors about build and test
116 failures.
118 Therefore, the LLVM community requires contributors to have a public
119 email address associated with their GitHub commits, so please ensure that "Keep
120 my email addresses private" is disabled in your
121 `account settings <https://github.com/settings/emails>`_.
123 .. _code review:
125 Code Reviews
126 ------------
128 LLVM has a code-review policy. Code review is one way to increase the quality of
129 software. Please see :doc:`CodeReview` for more information on LLVM's code-review
130 process.
132 .. _breaking:
134 Making Potentially Breaking Changes
135 -----------------------------------
137 Please help notify users and vendors of potential disruptions when upgrading to
138 a newer version of a tool. For example, deprecating a feature that is expected
139 to be removed in the future, removing an already-deprecated feature, upgrading a
140 diagnostic from a warning to an error, switching important default behavior, or
141 any other potentially disruptive situation thought to be worth raising
142 awareness of. For such changes, the following should be done:
144 .. warning::
146   Phabricator is deprecated and is available in read-only mode,
147   for new code contributions use :ref:`GitHub Pull Requests <github-reviews>`.
148   This section contains old information that needs to be updated.
150 * When performing the code review for the change, please add any applicable
151   "vendors" group to the review for their awareness. The purpose of these
152   groups is to give vendors early notice that potentially disruptive changes
153   are being considered but have not yet been accepted. Vendors can give early
154   testing feedback on the changes to alert us to unacceptable breakages. The
155   current list of vendor groups is:
157   * `Clang vendors <https://reviews.llvm.org/project/members/113/>`_
158   * `libc++ vendors <https://reviews.llvm.org/project/members/109/>`_
160   People interested in joining the vendors group can do so by clicking the
161   "Join Project" link on the vendor's "Members" page in Phabricator.
163 * When committing the change to the repository, add appropriate information
164   about the potentially breaking changes to the ``Potentially Breaking Changes``
165   section of the project's release notes. The release note should have
166   information about what the change is, what is potentially disruptive about
167   it, as well as any code examples, links, and motivation that is appropriate
168   to share with users. This helps users to learn about potential issues with
169   upgrading to that release.
171 * After the change has been committed to the repository, the potentially
172   disruptive changes described in the release notes should be posted to the
173   `Announcements <https://discourse.llvm.org/c/announce/>`_ channel on
174   Discourse. The post should be tagged with the ``potentially-breaking`` label
175   and a label specific to the project (such as ``clang``, ``llvm``, etc). This
176   is another mechanism by which we can give pre-release notice to users about
177   potentially disruptive changes. It is a lower-traffic alternative to the
178   joining "vendors" group. To automatically be notified of new announcements
179   with the ``potentially-breaking`` label, go to your user preferences page in
180   Discourse, and add the label to one of the watch categories under
181   ``Notifications->Tags``.
183 .. _maintainers:
185 Maintainers
186 -----------
188 The LLVM Project aims to evolve features quickly while continually being in a
189 release-ready state. In order to accomplish this, the project needs volunteers
190 willing to do the less glamorous work to ensure we produce robust, high-quality
191 products.
193 Maintainers are those volunteers; they are regular contributors who volunteer
194 to take on additional community responsibilities beyond code contributions.
195 Community members can find active and inactive maintainers for a project in the
196 ``Maintainers.rst`` file at the root directory of the individual project.
198 Maintainers are volunteering to take on the following shared responsibilities
199 within an area of a project:
201     * ensure that commits receive high-quality review, either by the maintainer
202       or by someone else,
203     * help to confirm and comment on issues,
204     * mediate code review disagreements through collaboration with other
205       maintainers (and other reviewers) to come to a consensus on how best to
206       proceed with disputed changes,
207     * actively engage with relevant RFCs,
208     * aid release managers with backporting and other release-related
209       activities,
210     * be a point of contact for contributors who need help (answering questions
211       on Discord/Discourse or holding office hours).
213 Each top-level project in the monorepo will specify one or more
214 lead maintainers who are responsible for ensuring community needs are
215 met for that project. This role is like any other maintainer role,
216 except the responsibilities span the project rather than a limited area
217 within the project. If you cannot reach a maintainer or don't know which
218 maintainer to reach out to, a lead maintainer is always a good choice
219 to reach out to. If a project has no active lead maintainers, it may be a
220 reasonable candidate for removal from the monorepo. A discussion should be
221 started on Discourse to find a new, active lead maintainer or whether the
222 project should be discontinued.
224 All contributors with commit access to the LLVM Project are eligible to be a
225 maintainer. However, we are looking for people who can commit to:
227     * engaging in their responsibilities the majority of the days in a month,
228     * ensuring that they, and the community members they interact with, abide by
229       the LLVM Community Code of Conduct, and
230     * performing these duties for at least three months.
232 We recognize that priorities shift, job changes happen, burnout is real,
233 extended vacations are a blessing, and people's lives are generally complex.
234 Therefore, we want as little friction as possible for someone to become a
235 maintainer or to step down as a maintainer.
237 *To become a new maintainer*, you can volunteer yourself by posting a PR which
238 adds yourself to the area(s) you are volunteering for. Alternatively, an
239 existing maintainer can nominate you by posting a PR, but the nominee must
240 explicitly accept the PR so that it's clear they agree to volunteer within the
241 proposed area(s). The PR will be accepted so long as at least one maintainer in
242 the same project vouches for their ability to perform the responsibilities and
243 there are no explicit objections raised by the community.
245 *To step down as a maintainer*, you can move your name to the "inactive
246 maintainers" section of the ``Maintainers.rst`` file for the project, or remove
247 your name entirely; no PR review is necessary. Additionally, any maintainer who
248 has not been actively performing their responsibilities over an extended period
249 of time can be moved to the "inactive maintainers" section by another active
250 maintainer within that project with agreement from one other active maintainer
251 within that project. If there is only one active maintainer for a project,
252 please post on Discourse to solicit wider community feedback about the removal
253 and future direction for the project. However, please discuss the situation
254 with the inactive maintainer before such removal to avoid accidental
255 miscommunications. If the inactive maintainer is unreachable, no discussion
256 with them is required. Stepping down or being removed as a maintainer is normal
257 and does not prevent someone from resuming their activities as a maintainer in
258 the future.
260 *To resume activities as a maintainer*, you can post a PR moving your name from
261 the "inactive maintainers" section of the ``Maintainers.rst`` file to the
262 active maintainers list. Because the volunteer was already previously accepted,
263 they will be re-accepted so long as at least one maintainer in the same project
264 approves the PR and there are no explicit objections raised by the community.
266 .. _include a testcase:
268 Test Cases
269 ----------
271 Developers are required to create test cases for any bugs fixed and any new
272 features added.  Some tips for getting your testcase approved:
274 * All feature and regression test cases are added to the ``llvm/test``
275   directory. The appropriate sub-directory should be selected (see the
276   :doc:`Testing Guide <TestingGuide>` for details).
278 * Test cases should be written in :doc:`LLVM assembly language <LangRef>`.
280 * Test cases, especially for regressions, should be reduced as much as possible,
281   by :doc:`bugpoint <Bugpoint>` or manually. It is unacceptable to place an
282   entire failing program into ``llvm/test`` as this creates a *time-to-test*
283   burden on all developers. Please keep them short.
285 * Avoid adding links to resources that are not available to the entire
286   community, such as links to private bug trackers, internal corporate
287   documentation, etc. Instead, add sufficient comments to the test to provide
288   the context behind such links.
290 Note that llvm/test and clang/test are designed for regression and small feature
291 tests only. More extensive test cases (e.g., entire applications, benchmarks,
292 etc) should be added to the ``llvm-test`` test suite.  The llvm-test suite is
293 for coverage (correctness, performance, etc) testing, not feature or regression
294 testing.
296 Release Notes
297 -------------
299 Many projects in LLVM communicate important changes to users through release
300 notes, typically found in ``docs/ReleaseNotes.rst`` for the project. Changes to
301 a project that are user-facing, or that users may wish to know about, should be
302 added to the project's release notes at the author's or code reviewer's
303 discretion, preferably as part of the commit landing the changes. Examples of
304 changes that would typically warrant adding a release note (this list is not
305 exhaustive):
307 * Adding, removing, or modifying command-line options.
308 * Adding, removing, or regrouping a diagnostic.
309 * Fixing a bug that potentially has significant user-facing impact (please link
310   to the issue fixed in the bug database).
311 * Adding or removing optimizations that have widespread impact or enables new
312   programming paradigms.
313 * Modifying a C stable API.
314 * Notifying users about a potentially disruptive change expected to be made in
315   a future release, such as removal of a deprecated feature. In this case, the
316   release note should be added to a ``Potentially Breaking Changes`` section of
317   the notes with sufficient information and examples to demonstrate the
318   potential disruption. Additionally, any new entries to this section should be
319   announced in the `Announcements <https://discourse.llvm.org/c/announce/>`_
320   channel on Discourse. See :ref:`breaking` for more details.
322 Code reviewers are encouraged to request a release note if they think one is
323 warranted when performing a code review.
325 Quality
326 -------
328 The minimum quality standards that any change must satisfy before being
329 committed to the main development branch are:
331 #. Code must adhere to the `LLVM Coding Standards <CodingStandards.html>`_.
333 #. Code must compile cleanly (no errors, no warnings) on at least one platform.
335 #. Bug fixes and new features should `include a testcase`_ so we know if the
336    fix/feature ever regresses in the future.
338 #. Code must pass the ``llvm/test`` test suite.
340 #. The code must not cause regressions on a reasonable subset of llvm-test,
341    where "reasonable" depends on the contributor's judgement and the scope of
342    the change (more invasive changes require more testing). A reasonable subset
343    might be something like "``llvm-test/MultiSource/Benchmarks``".
345 #. Ensure that links in source code and test files point to publicly available
346    resources and are used primarily to add additional information rather than
347    to supply critical context. The surrounding comments should be sufficient
348    to provide the context behind such links.
350 Additionally, the committer is responsible for addressing any problems found in
351 the future that the change is responsible for.  For example:
353 * The code should compile cleanly on all supported platforms.
355 * The changes should not cause any correctness regressions in the ``llvm-test``
356   suite and must not cause any major performance regressions.
358 * The change set should not cause performance or correctness regressions for the
359   LLVM tools.
361 * The changes should not cause performance or correctness regressions in code
362   compiled by LLVM on all applicable targets.
364 * You are expected to address any `GitHub Issues <https://github.com/llvm/llvm-project/issues>`_ that
365   result from your change.
367 We prefer for this to be handled before submission but understand that it isn't
368 possible to test all of this for every submission.  Our build bots and nightly
369 testing infrastructure normally finds these problems.  A good rule of thumb is
370 to check the nightly testers for regressions the day after your change.  Build
371 bots will directly email you if a group of commits that included yours caused a
372 failure.  You are expected to check the build bot messages to see if they are
373 your fault and, if so, fix the breakage.
375 Commits that violate these quality standards (e.g. are very broken) may be
376 reverted. This is necessary when the change blocks other developers from making
377 progress. The developer is welcome to re-commit the change after the problem has
378 been fixed.
380 .. _commit messages:
382 Commit messages
383 ---------------
385 Although we don't enforce the format of commit messages, we prefer that
386 you follow these guidelines to help review, search in logs, email formatting
387 and so on. These guidelines are very similar to rules used by other open source
388 projects.
390 Most importantly, the contents of the message should be carefully written to
391 convey the rationale of the change (without delving too much in detail). It
392 also should avoid being vague or overly specific. For example, "bits were not
393 set right" will leave the reviewer wondering about which bits, and why they
394 weren't right, while "Correctly set overflow bits in TargetInfo" conveys almost
395 all there is to the change.
397 Below are some guidelines about the format of the message itself:
399 * Separate the commit message into title and body separated by a blank line.
401 * If you're not the original author, ensure the 'Author' property of the commit is
402   set to the original author and the 'Committer' property is set to yourself.
403   You can use a command similar to
404   ``git commit --amend --author="John Doe <jdoe@llvm.org>"`` to correct the
405   author property if it is incorrect. See `Attribution of Changes`_ for more
406   information including the method we used for attribution before the project
407   migrated to git.
409   In the rare situation where there are multiple authors, please use the `git
410   tag 'Co-authored-by:' to list the additional authors
411   <https://github.blog/2018-01-29-commit-together-with-co-authors/>`_.
413 * The title should be concise. Because all commits are emailed to the list with
414   the first line as the subject, long titles are frowned upon.  Short titles
415   also look better in `git log`.
417 * When the changes are restricted to a specific part of the code (e.g. a
418   back-end or optimization pass), it is customary to add a tag to the
419   beginning of the line in square brackets.  For example, "[SCEV] ..."
420   or "[OpenMP] ...". This helps email filters and searches for post-commit
421   reviews.
423 * The body, if it exists, should be separated from the title by an empty line.
425 * The body should be concise, but explanatory, including a complete
426   reasoning.  Unless it is required to understand the change, examples,
427   code snippets and gory details should be left to bug comments, web
428   review or the mailing list.
430 * Text formatting and spelling should follow the same rules as documentation
431   and in-code comments, ex. capitalization, full stop, etc.
433 * If the commit is a bug fix on top of another recently committed patch, or a
434   revert or reapply of a patch, include the git commit hash of the prior
435   related commit. This could be as simple as "Revert commit NNNN because it
436   caused PR#".
438 * If the patch has been reviewed, add a link to its review page, as shown
439   `here <https://www.llvm.org/docs/Phabricator.html#committing-a-change>`__.
440   If the patch fixes a bug in GitHub Issues, we encourage adding a reference to
441   the issue being closed, as described
442   `here <https://llvm.org/docs/BugLifeCycle.html#resolving-closing-bugs>`__.
444 * It is also acceptable to add other metadata to the commit message to automate
445   processes, including for downstream consumers. This metadata can include
446   links to resources that are not available to the entire community. However,
447   such links and/or metadata should not be used in place of making the commit
448   message self-explanatory. Note that such non-public links should not be
449   included in the submitted code.
451 For minor violations of these recommendations, the community normally favors
452 reminding the contributor of this policy over reverting. Minor corrections and
453 omissions can be handled by sending a reply to the commits mailing list.
455 .. _revert_policy:
457 Patch reversion policy
458 ----------------------
460 As a community, we strongly value having the tip of tree in a good state while
461 allowing rapid iterative development.  As such, we tend to make much heavier
462 use of reverts to keep the tree healthy than some other open source projects,
463 and our norms are a bit different.
465 How should you respond if someone reverted your change?
467 * Remember, it is normal and healthy to have patches reverted.  Having a patch
468   reverted does not necessarily mean you did anything wrong.
469 * We encourage explicitly thanking the person who reverted the patch for doing
470   the task on your behalf.
471 * If you need more information to address the problem, please follow up in the
472   original commit thread with the reverting patch author.
474 When should you revert your own change?
476 * Any time you learn of a serious problem with a change, you should revert it.
477   We strongly encourage "revert to green" as opposed to "fixing forward".  We
478   encourage reverting first, investigating offline, and then reapplying the
479   fixed patch - possibly after another round of review if warranted.
480 * If you break a buildbot in a way which can't be quickly fixed, please revert.
481 * If a test case that demonstrates a problem is reported in the commit thread,
482   please revert and investigate offline.
483 * If you receive substantial :ref:`post-commit review <post_commit_review>`
484   feedback, please revert and address said feedback before recommitting.
485   (Possibly after another round of review.)
486 * If you are asked to revert by another contributor, please revert and discuss
487   the merits of the request offline (unless doing so would further destabilize
488   tip of tree).
490 When should you revert someone else's change?
492 * In general, if the author themselves would revert the change per these
493   guidelines, we encourage other contributors to do so as a courtesy to the
494   author.  This is one of the major cases where our norms differ from others;
495   we generally consider reverting a normal part of development.  We don't
496   expect contributors to be always available, and the assurance that a
497   problematic patch will be reverted and we can return to it at our next
498   opportunity enables this.
500 What are the expectations around a revert?
502 * Use your best judgment. If you're uncertain, please start an email on
503   the commit thread asking for assistance.  We aren't trying to enumerate
504   every case, but rather give a set of guidelines.
505 * You should be sure that reverting the change improves the stability of tip
506   of tree.  Sometimes reverting one change in a series can worsen things
507   instead of improving them.  We expect reasonable judgment to ensure that
508   the proper patch or set of patches is being reverted.
509 * The commit message for the reverting commit should explain why patch
510   is being reverted.
511 * It is customary to respond to the original commit email mentioning the
512   revert.  This serves as both a notice to the original author that their
513   patch was reverted, and helps others following llvm-commits track context.
514 * Ideally, you should have a publicly reproducible test case ready to share.
515   Where possible, we encourage sharing of test cases in commit threads, or
516   in PRs.  We encourage the reverter to minimize the test case and to prune
517   dependencies where practical.  This even applies when reverting your own
518   patch; documenting the reasons for others who might be following along
519   is critical.
520 * It is not considered reasonable to revert without at least the promise to
521   provide a means for the patch author to debug the root issue.  If a situation
522   arises where a public reproducer can not be shared for some reason (e.g.
523   requires hardware patch author doesn't have access to, sharp regression in
524   compile time of internal workload, etc.), the reverter is expected to be
525   proactive about working with the patch author to debug and test candidate
526   patches.
527 * Reverts should be reasonably timely.  A change submitted two hours ago
528   can be reverted without prior discussion.  A change submitted two years ago
529   should not be.  Where exactly the transition point is is hard to say, but
530   it's probably in the handful of days in tree territory.  If you are unsure,
531   we encourage you to reply to the commit thread, give the author a bit to
532   respond, and then proceed with the revert if the author doesn't seem to be
533   actively responding.
534 * When re-applying a reverted patch, the commit message should be updated to
535   indicate the problem that was addressed and how it was addressed.
537 .. _obtaining_commit_access:
539 Obtaining Commit Access
540 -----------------------
542 We grant commit access to contributors that can provide a valid justification.
543 If you would like commit access, please use this `link <https://github.com/llvm/llvm-project/issues/new?title=Request%20Commit%20Access%20For%20%3Cuser%3E&body=%23%23%23%20Why%20Are%20you%20requesting%20commit%20access%20?>`_ to file
544 an issue and request commit access. Replace the <user> string in the title
545 with your github username, and explain why you are requesting commit access in
546 the issue description. If approved, a GitHub invitation will be sent to your
547 GitHub account. In case you don't get notification from GitHub, go to
548 `Invitation Link <https://github.com/orgs/llvm/invitation>`_ directly. Once
549 you accept the invitation, you'll get commit access.
551 Prior to obtaining commit access, it is common practice to request that
552 someone with commit access commits on your behalf. When doing so, please
553 provide the name and email address you would like to use in the Author
554 property of the commit.
556 For external tracking purposes, committed changes are automatically reflected
557 on a commits mailing list soon after the commit lands (e.g. llvm-commits_).
558 Note that these mailing lists are moderated, and it is not unusual for a large
559 commit to require a moderator to approve the email, so do not be concerned if a
560 commit does not immediately appear in the archives.
562 If you have recently been granted commit access, these policies apply:
564 #. You are granted *commit-after-approval* to all parts of LLVM. For
565    information on how to get approval for a patch, please see :doc:`CodeReview`.
566    When approved, you may commit it yourself.
568 #. You are allowed to commit patches without approval which you think are
569    obvious. This is clearly a subjective decision --- we simply expect you to
570    use good judgement.  Examples include: fixing build breakage, reverting
571    obviously broken patches, documentation/comment changes, any other minor
572    changes. Avoid committing formatting- or whitespace-only changes outside of
573    code you plan to make subsequent changes to. Also, try to separate
574    formatting or whitespace changes from functional changes, either by
575    correcting the format first (ideally) or afterward. Such changes should be
576    highly localized and the commit message should clearly state that the commit
577    is not intended to change functionality, usually by stating it is
578    :ref:`NFC <nfc>`.
580 #. You are allowed to commit patches without approval to those portions of LLVM
581    that you have contributed or maintain (i.e., have been assigned
582    responsibility for), with the proviso that such commits must not break the
583    build.  This is a "trust but verify" policy, and commits of this nature are
584    reviewed after they are committed.
586 #. Multiple violations of these policies or a single egregious violation may
587    cause commit access to be revoked.
589 In any case, your changes are still subject to `code review`_ (either before or
590 after they are committed, depending on the nature of the change).  You are
591 encouraged to review other peoples' patches as well, but you aren't required
592 to do so.
594 .. _discuss the change/gather consensus:
596 Making a Major Change
597 ---------------------
599 When a developer begins a major new project with the aim of contributing it back
600 to LLVM, they should inform the community with a post to the `LLVM Discourse forums`_, to the extent
601 possible. The reason for this is to:
603 #. keep the community informed about future changes to LLVM,
605 #. avoid duplication of effort by preventing multiple parties working on the
606    same thing and not knowing about it, and
608 #. ensure that any technical issues around the proposed work are discussed and
609    resolved before any significant work is done.
611 The design of LLVM is carefully controlled to ensure that all the pieces fit
612 together well and are as consistent as possible. If you plan to make a major
613 change to the way LLVM works or want to add a major new extension, it is a good
614 idea to get consensus with the development community before you start working on
617 Once the design of the new feature is finalized, the work itself should be done
618 as a series of `incremental changes`_, not as a long-term development branch.
620 .. _incremental changes:
622 Incremental Development
623 -----------------------
625 In the LLVM project, we do all significant changes as a series of incremental
626 patches.  We have a strong dislike for huge changes or long-term development
627 branches.  Long-term development branches have a number of drawbacks:
629 #. Branches must have mainline merged into them periodically.  If the branch
630    development and mainline development occur in the same pieces of code,
631    resolving merge conflicts can take a lot of time.
633 #. Other people in the community tend to ignore work on branches.
635 #. Huge changes (produced when a branch is merged back onto mainline) are
636    extremely difficult to `code review`_.
638 #. Branches are not routinely tested by our nightly tester infrastructure.
640 #. Changes developed as monolithic large changes often don't work until the
641    entire set of changes is done.  Breaking it down into a set of smaller
642    changes increases the odds that any of the work will be committed to the main
643    repository.
645 To address these problems, LLVM uses an incremental development style and we
646 require contributors to follow this practice when making a large/invasive
647 change.  Some tips:
649 * Large/invasive changes usually have a number of secondary changes that are
650   required before the big change can be made (e.g. API cleanup, etc).  These
651   sorts of changes can often be done before the major change is done,
652   independently of that work.
654 * The remaining inter-related work should be decomposed into unrelated sets of
655   changes if possible.  Once this is done, define the first increment and get
656   consensus on what the end goal of the change is.
658 * Each change in the set can be stand alone (e.g. to fix a bug), or part of a
659   planned series of changes that works towards the development goal.
661 * Each change should be kept as small as possible. This simplifies your work
662   (into a logical progression), simplifies code review and reduces the chance
663   that you will get negative feedback on the change. Small increments also
664   facilitate the maintenance of a high quality code base.
666 * Often, an independent precursor to a big change is to add a new API and slowly
667   migrate clients to use the new API.  Each change to use the new API is often
668   "obvious" and can be committed without review.  Once the new API is in place
669   and used, it is much easier to replace the underlying implementation of the
670   API.  This implementation change is logically separate from the API
671   change.
673 If you are interested in making a large change, and this scares you, please make
674 sure to first `discuss the change/gather consensus`_ then ask about the best way
675 to go about making the change.
677 Attribution of Changes
678 ----------------------
680 When contributors submit a patch to an LLVM project, other developers with
681 commit access may commit it for the author once appropriate (based on the
682 progression of code review, etc.). When doing so, it is important to retain
683 correct attribution of contributions to their contributors. However, we do not
684 want the source code to be littered with random attributions "this code written
685 by J. Random Hacker" (this is noisy and distracting). In practice, the revision
686 control system keeps a perfect history of who changed what, and the CREDITS.txt
687 file describes higher-level contributions. If you commit a patch for someone
688 else, please follow the attribution of changes in the simple manner as outlined
689 by the `commit messages`_ section. Overall, please do not add contributor names
690 to the source code.
692 Also, don't commit patches authored by others unless they have submitted the
693 patch to the project or you have been authorized to submit them on their behalf
694 (you work together and your company authorized you to contribute the patches,
695 etc.). The author should first submit them to the relevant project's commit
696 list, development list, or LLVM bug tracker component. If someone sends you
697 a patch privately, encourage them to submit it to the appropriate list first.
699 Our previous version control system (subversion) did not distinguish between the
700 author and the committer like git does. As such, older commits used a different
701 attribution mechanism. The previous method was to include "Patch by John Doe."
702 in a separate line of the commit message and there are automated processes that
703 rely on this format.
705 Bans
706 ----
708 The goal of a ban is to protect people in the community from having to interact
709 with people who are consistently not respecting the
710 :ref:`LLVM Community Code of Conduct` in LLVM project spaces. Contributions of
711 any variety (pull requests, issue reports, forum posts, etc.) require
712 interacting with the community. Therefore, we do not accept any form of direct
713 contribution from a banned individual.
715 Indirect contributions are permissible only by someone taking full ownership of
716 such a contribution and they are responsible for all related interactions with
717 the community regarding that contribution.
719 When in doubt how to act in a specific instance, please reach out to
720 conduct@llvm.org for advice.
723 .. _IR backwards compatibility:
725 IR Backwards Compatibility
726 --------------------------
728 When the IR format has to be changed, keep in mind that we try to maintain some
729 backwards compatibility. The rules are intended as a balance between convenience
730 for llvm users and not imposing a big burden on llvm developers:
732 * The textual format is not backwards compatible. We don't change it too often,
733   but there are no specific promises.
735 * Additions and changes to the IR should be reflected in
736   ``test/Bitcode/compatibility.ll``.
738 * The current LLVM version supports loading any bitcode since version 3.0.
740 * After each X.Y release, ``compatibility.ll`` must be copied to
741   ``compatibility-X.Y.ll``. The corresponding bitcode file should be assembled
742   using the X.Y build and committed as ``compatibility-X.Y.ll.bc``.
744 * Newer releases can ignore features from older releases, but they cannot
745   miscompile them. For example, if nsw is ever replaced with something else,
746   dropping it would be a valid way to upgrade the IR.
748 * Debug metadata is special in that it is currently dropped during upgrades.
750 * Non-debug metadata is defined to be safe to drop, so a valid way to upgrade
751   it is to drop it. That is not very user friendly and a bit more effort is
752   expected, but no promises are made.
754 C API Changes
755 -------------
757 * Stability Guarantees: The C API is, in general, a "best effort" for stability.
758   This means that we make every attempt to keep the C API stable, but that
759   stability will be limited by the abstractness of the interface and the
760   stability of the C++ API that it wraps. In practice, this means that things
761   like "create debug info" or "create this type of instruction" are likely to be
762   less stable than "take this IR file and JIT it for my current machine".
764 * Release stability: We won't break the C API on the release branch with patches
765   that go on that branch, with the exception that we will fix an unintentional
766   C API break that will keep the release consistent with both the previous and
767   next release.
769 * Testing: Patches to the C API are expected to come with tests just like any
770   other patch.
772 * Including new things into the API: If an LLVM subcomponent has a C API already
773   included, then expanding that C API is acceptable. Adding C API for
774   subcomponents that don't currently have one needs to be discussed on the
775   `LLVM Discourse forums`_ for design and maintainability feedback prior to implementation.
777 * Documentation: Any changes to the C API are required to be documented in the
778   release notes so that it's clear to external users who do not follow the
779   project how the C API is changing and evolving.
781 .. _toolchain:
783 Updating Toolchain Requirements
784 -------------------------------
786 We intend to require newer toolchains as time goes by. This means LLVM's
787 codebase can use newer versions of C++ as they get standardized. Requiring newer
788 toolchains to build LLVM can be painful for those building LLVM; therefore, it
789 will only be done through the following process:
791   * It is a general goal to support LLVM and GCC versions from the last 3 years
792     at a minimum. This time-based guideline is not strict: we may support much
793     older compilers, or decide to support fewer versions.
795   * An RFC is sent to the `LLVM Discourse forums`_
797     - Detail upsides of the version increase (e.g. which newer C++ language or
798       library features LLVM should use; avoid miscompiles in particular compiler
799       versions, etc).
800     - Detail downsides on important platforms (e.g. Ubuntu LTS status).
802   * Once the RFC reaches consensus, update the CMake toolchain version checks as
803     well as the :doc:`getting started<GettingStarted>` guide.  This provides a
804     softer transition path for developers compiling LLVM, because the
805     error can be turned into a warning using a CMake flag. This is an important
806     step: LLVM still doesn't have code which requires the new toolchains, but it
807     soon will. If you compile LLVM but don't read the forums, we should
808     tell you!
810   * Ensure that at least one LLVM release has had this soft-error. Not all
811     developers compile LLVM top-of-tree. These release-bound developers should
812     also be told about upcoming changes.
814   * Turn the soft-error into a hard-error after said LLVM release has branched.
816   * Update the :doc:`coding standards<CodingStandards>` to allow the new
817     features we've explicitly approved in the RFC.
819   * Start using the new features in LLVM's codebase.
821 Here's a `sample RFC
822 <https://discourse.llvm.org/t/rfc-migrating-past-c-11/50943>`_ and the
823 `corresponding change <https://reviews.llvm.org/D57264>`_.
825 .. _ci-usage:
827 Working with the CI system
828 --------------------------
830 The main continuous integration (CI) tool for the LLVM project is the
831 `LLVM Buildbot <https://lab.llvm.org/buildbot/>`_. It uses different *builders*
832 to cover a wide variety of sub-projects and configurations. The builds are
833 executed on different *workers*. Builders and workers are configured and
834 provided by community members.
836 The Buildbot tracks the commits on the main branch and the release branches.
837 This means that patches are built and tested after they are merged to the these
838 branches (aka post-merge testing). This also means it's okay to break the build
839 occasionally, as it's unreasonable to expect contributors to build and test
840 their patch with every possible configuration.
842 *If your commit broke the build:*
844 * Fix the build as soon as possible as this might block other contributors or
845   downstream users.
846 * If you need more time to analyze and fix the bug, please revert your change to
847   unblock others.
849 *If someone else broke the build and this blocks your work*
851 * Comment on the code review in `GitHub <https://github.com/llvm/llvm-project/pulls>`_
852   (if available) or email the author, explain the problem and how this impacts
853   you. Add a link to the broken build and the error message so folks can
854   understand the problem.
855 * Revert the commit if this blocks your work, see revert_policy_ .
857 *If a build/worker is permanently broken*
859 * 1st step: contact the owner of the worker. You can find the name and contact
860   information for the *Admin* of worker on the page of the build in the
861   *Worker* tab:
863   .. image:: buildbot_worker_contact.png
865 * 2nd step: If the owner does not respond or fix the worker, please escalate
866   to Galina Kostanova, the maintainer of the BuildBot master.
867 * 3rd step: If Galina could not help you, please escalate to the
868   `Infrastructure Working Group <mailto:iwg@llvm.org>`_.
870 .. _new-llvm-components:
872 Introducing New Components into LLVM
873 ====================================
875 The LLVM community is a vibrant and exciting place to be, and we look to be
876 inclusive of new projects and foster new communities, and increase
877 collaboration across industry and academia.
879 That said, we need to strike a balance between being inclusive of new ideas and
880 people and the cost of ongoing maintenance that new code requires.  As such, we
881 have a general :doc:`support policy<SupportPolicy>` for introducing major new
882 components into the LLVM world, depending on the degree of detail and
883 responsibility required. *Core* projects need a higher degree of scrutiny
884 than *peripheral* projects, and the latter may have additional differences.
886 However, this is really only intended to cover common cases
887 that we have seen arise: different situations are different, and we are open
888 to discussing unusual cases as well - just start an RFC thread on the
889 `LLVM Discourse forums`_.
891 Adding a New Target
892 -------------------
894 LLVM is very receptive to new targets, even experimental ones, but a number of
895 problems can appear when adding new large portions of code, and back-ends are
896 normally added in bulk. New targets need the same level of support as other
897 *core* parts of the compiler, so they are covered in the *core tier* of our
898 :doc:`support policy<SupportPolicy>`.
900 We have found that landing large pieces of new code and then trying to fix
901 emergent problems in-tree is problematic for a variety of reasons. For these
902 reasons, new targets are *always* added as *experimental* until they can be
903 proven stable, and later moved to non-experimental.
905 The differences between both classes are:
907 * Experimental targets are not built by default (they need to be explicitly
908   enabled at CMake time).
910 * Test failures, bugs, and build breakages that only appear when the
911   experimental target is enabled, caused by changes unrelated to the target, are
912   the responsibility of the community behind the target to fix.
914 The basic rules for a back-end to be upstreamed in **experimental** mode are:
916 * Every target must have at least one :ref:`maintainer<maintainers>`. The
917   `Maintainers.rst` file has to be updated as part of the first merge. These
918   maintainers make sure that changes to the target get reviewed and steers the
919   overall effort.
921 * There must be an active community behind the target. This community
922   will help maintain the target by providing buildbots, fixing
923   bugs, answering the LLVM community's questions and making sure the new
924   target doesn't break any of the other targets, or generic code. This
925   behavior is expected to continue throughout the lifetime of the
926   target's code.
928 * The code must be free of contentious issues, for example, large
929   changes in how the IR behaves or should be formed by the front-ends,
930   unless agreed by the majority of the community via refactoring of the
931   (:doc:`IR standard<LangRef>`) **before** the merge of the new target changes,
932   following the :ref:`IR backwards compatibility`.
934 * The code conforms to all of the policies laid out in this developer policy
935   document, including license, patent, and coding standards.
937 * The target should have either reasonable documentation on how it
938   works (ISA, ABI, etc.) or a publicly available simulator/hardware
939   (either free or cheap enough) - preferably both.  This allows
940   developers to validate assumptions, understand constraints and review code
941   that can affect the target.
943 In addition, the rules for a back-end to be promoted to **official** are:
945 * The target must have addressed every other minimum requirement and
946   have been stable in tree for at least 3 months. This cool down
947   period is to make sure that the back-end and the target community can
948   endure continuous upstream development for the foreseeable future.
950 * The target's code must have been completely adapted to this policy
951   as well as the :doc:`coding standards<CodingStandards>`. Any exceptions that
952   were made to move into experimental mode must have been fixed **before**
953   becoming official.
955 * The test coverage needs to be broad and well written (small tests,
956   well documented). The build target ``check-all`` must pass with the
957   new target built, and where applicable, the ``test-suite`` must also
958   pass without errors, in at least one configuration (publicly
959   demonstrated, for example, via buildbots).
961 * Public buildbots need to be created and actively maintained, unless
962   the target requires no additional buildbots (ex. ``check-all`` covers
963   all tests). The more relevant and public the new target's CI infrastructure
964   is, the more the LLVM community will embrace it.
966 To **continue** as a supported and official target:
968 * The maintainer(s) must continue following these rules throughout the lifetime
969   of the target. Continuous violations of aforementioned rules and policies
970   could lead to complete removal of the target from the code base.
972 * Degradation in support, documentation or test coverage will make the target as
973   nuisance to other targets and be considered a candidate for deprecation and
974   ultimately removed.
976 In essence, these rules are necessary for targets to gain and retain their
977 status, but also markers to define bit-rot, and will be used to clean up the
978 tree from unmaintained targets.
980 Those wishing to add a new target to LLVM must follow the procedure below:
982 1. Read this section and make sure your target follows all requirements. For
983    minor issues, your community will be responsible for making all necessary
984    adjustments soon after the initial merge.
985 2. Send a request for comment (RFC) to the `LLVM Discourse forums`_ describing
986    your target and how it follows all the requirements and what work has been
987    done and will need to be done to accommodate the official target requirements.
988    Make sure to expose any and all controversial issues, changes needed in the
989    base code, table gen, etc.
990 3. Once the response is positive, the LLVM community can start reviewing the
991    actual patches (but they can be prepared before, to support the RFC). Create
992    a sequence of N patches, numbered '1/N' to 'N/N' (make sure N is an actual
993    number, not the letter 'N'), that completes the basic structure of the target.
994 4. The initial patch should add documentation, maintainers, and triple support in
995    clang and LLVM. The following patches add TableGen infrastructure to describe
996    the target and lower instructions to assembly. The final patch must show that
997    the target can lower correctly with extensive LIT tests (IR to MIR, MIR to
998    ASM, etc).
999 5. Some patches may be approved before others, but only after *all* patches are
1000    approved that the whole set can be merged in one go. This is to guarantee
1001    that all changes are good as a single block.
1002 6. After the initial merge, the target community can stop numbering patches and
1003    start working asynchronously on the target to complete support. They should
1004    still seek review from those who helped them in the initial phase, to make
1005    sure the progress is still consistent.
1006 7. Once all official requirements have been fulfilled (as above), the maintainers
1007    should request the target to be enabled by default by sending another RFC to
1008    the `LLVM Discourse forums`_.
1010 Adding an Established Project To the LLVM Monorepo
1011 --------------------------------------------------
1013 The `LLVM monorepo <https://github.com/llvm/llvm-project>`_ is the centerpoint
1014 of development in the LLVM world, and has all of the primary LLVM components,
1015 including the LLVM optimizer and code generators, Clang, LLDB, etc.  `Monorepos
1016 in general <https://en.wikipedia.org/wiki/Monorepo>`_ are great because they
1017 allow atomic commits to the project, simplify CI, and make it easier for
1018 subcommunities to collaborate.
1020 Like new targets, most projects already in the monorepo are considered to be in
1021 the *core tier* of our :doc:`support policy<SupportPolicy>`. The burden to add
1022 things to the LLVM monorepo needs to be very high - code that is added to this
1023 repository is checked out by everyone in the community.  As such, we hold
1024 components to a high bar similar to "official targets", they:
1026  * Must be generally aligned with the mission of the LLVM project to advance
1027    compilers, languages, tools, runtimes, etc.
1028  * Must conform to all of the policies laid out in this developer policy
1029    document, including license, patent, coding standards, and code of conduct.
1030  * Must have an active community that maintains the code, including established
1031    maintainers.
1032  * Should have reasonable documentation about how it works, including a high
1033    quality README file.
1034  * Should have CI to catch breakage within the project itself or due to
1035    underlying LLVM dependencies.
1036  * Should have code free of issues the community finds contentious, or be on a
1037    clear path to resolving them.
1038  * Must be proposed through the LLVM RFC process, and have its addition approved
1039    by the LLVM community - this ultimately mediates the resolution of the
1040    "should" concerns above.
1042 If you have a project that you think would make sense to add to the LLVM
1043 monorepo, please start an RFC topic on the `LLVM Discourse forums`_ to kick off
1044 the discussion.  This process can take some time and iteration - please don’t
1045 be discouraged or intimidated by that!
1047 If you have an earlier stage project that you think is aligned with LLVM, please
1048 see the "Incubating New Projects" section.
1050 Incubating New Projects
1051 -----------------------
1053 The burden to add a new project to the LLVM monorepo is intentionally very high,
1054 but that can have a chilling effect on new and innovative projects.  To help
1055 foster these sorts of projects, LLVM supports an "incubator" process that is
1056 much easier to get started with.  It provides space for potentially valuable,
1057 new top-level and sub-projects to reach a critical mass before they have enough
1058 code to prove their utility and grow a community.  This also allows
1059 collaboration between teams that already have permissions to make contributions
1060 to projects under the LLVM umbrella.
1062 Projects which can be considered for the LLVM incubator meet the following
1063 criteria:
1065  * Must be generally aligned with the mission of the LLVM project to advance
1066    compilers, languages, tools, runtimes, etc.
1067  * Must conform to the license, patent, and code of conduct policies laid out
1068    in this developer policy document.
1069  * Must have a documented charter and development plan, e.g. in the form of a
1070    README file, mission statement, and/or manifesto.
1071  * Should conform to coding standards, incremental development process, and
1072    other expectations.
1073  * Should have a sense of the community that it hopes to eventually foster, and
1074    there should be interest from members with different affiliations /
1075    organizations.
1076  * Should have a feasible path to eventually graduate as a dedicated top-level
1077    or sub-project within the `LLVM monorepo
1078    <https://github.com/llvm/llvm-project>`_.
1079  * Should include a notice (e.g. in the project README or web page) that the
1080    project is in â€˜incubation status’ and is not included in LLVM releases (see
1081    suggested wording below).
1082  * Must be proposed through the LLVM RFC process, and have its addition
1083    approved by the LLVM community - this ultimately mediates the resolution of
1084    the "should" concerns above.
1086 That said, the project need not have any code to get started, and need not have
1087 an established community at all!  Furthermore, incubating projects may pass
1088 through transient states that violate the "Should" guidelines above, or would
1089 otherwise make them unsuitable for direct inclusion in the monorepo (e.g.
1090 dependencies that have not yet been factored appropriately, leveraging
1091 experimental components or APIs that are not yet upstream, etc).
1093 When approved, the llvm-admin group can grant the new project:
1094  * A new repository in the LLVM Github Organization - but not the LLVM monorepo.
1095  * New mailing list, discourse forum, and/or discord chat hosted with other LLVM
1096    forums.
1097  * Other infrastructure integration can be discussed on a case-by-case basis.
1099 Graduation to the mono-repo would follow existing processes and standards for
1100 becoming a first-class part of the monorepo.  Similarly, an incubating project
1101 may be eventually retired, but no process has been established for that yet.  If
1102 and when this comes up, please start an RFC discussion on the `LLVM Discourse forums`_.
1104 This process is very new - please expect the details to change, it is always
1105 safe to ask on the `LLVM Discourse forums`_ about this.
1107 Suggested disclaimer for the project README and the main project web page:
1111    This project is participating in the LLVM Incubator process: as such, it is
1112    not part of any official LLVM release.  While incubation status is not
1113    necessarily a reflection of the completeness or stability of the code, it
1114    does indicate that the project is not yet endorsed as a component of LLVM.
1116 .. _copyright-license-patents:
1118 Copyright, License, and Patents
1119 ===============================
1121 .. note::
1123    This section deals with legal matters but does not provide legal advice.  We
1124    are not lawyers --- please seek legal counsel from a licensed attorney.
1126 This section addresses the issues of copyright, license and patents for the LLVM
1127 project.  The copyright for the code is held by the contributors of
1128 the code.  The code is licensed under permissive `open source licensing terms`_,
1129 namely the Apache-2.0 with LLVM-exception license, which includes a copyright
1130 and `patent license`_.  When you contribute code to the LLVM project, you
1131 license it under these terms.
1133 In certain circumstances, code licensed under other licenses can be added
1134 to the codebase.  However, this may only be done with approval of the LLVM
1135 Foundation Board of Directors, and contributors should plan for the approval
1136 process to take at least 4-6 weeks.  If you would like to contribute code
1137 under a different license, please create a pull request with the code
1138 you want to contribute and email board@llvm.org requesting a review.
1140 If you have questions or comments about these topics, please ask on the
1141 `LLVM Discourse forums`_.  However,
1142 please realize that most compiler developers are not lawyers, and therefore you
1143 will not be getting official legal advice.
1145 .. _LLVM Discourse forums: https://discourse.llvm.org
1147 Copyright
1148 ---------
1150 The LLVM project does not collect copyright assignments, which means that the
1151 copyright for the code in the project is held by the respective contributors.
1152 Because you (or your company)
1153 retain ownership of the code you contribute, you know it may only be used under
1154 the terms of the open source license you contributed it under: the license for
1155 your contributions cannot be changed in the future without your approval.
1157 Because the LLVM project does not require copyright assignments, changing the
1158 LLVM license requires tracking down the
1159 contributors to LLVM and getting them to agree that a license change is
1160 acceptable for their contributions.  We feel that a high burden for relicensing
1161 is good for the project, because contributors do not have to fear that their
1162 code will be used in a way with which they disagree.
1164 Embedded Copyright or 'Contributed by' Statements
1165 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1167 The LLVM project does not accept contributions that include in-source copyright
1168 notices except where such notices are part of a larger external project being
1169 added as a vendored dependency.
1171 LLVM source code lives for a long time and is edited by many people, the best
1172 way to track contributions is through revision control history.
1173 See the `Attribution of Changes`_ section for more information about attributing
1174 changes to authors other than the committer.
1176 Relicensing
1177 -----------
1179 The last paragraph notwithstanding, the LLVM Project is in the middle of a large
1180 effort to change licenses, which aims to solve several problems:
1182 * The old licenses made it difficult to move code from (e.g.) the compiler to
1183   runtime libraries, because runtime libraries used a different license from the
1184   rest of the compiler.
1185 * Some contributions were not submitted to LLVM due to concerns that
1186   the patent grant required by the project was overly broad.
1187 * The patent grant was unique to the LLVM Project, not written by a lawyer, and
1188   was difficult to determine what protection was provided (if any).
1190 The scope of relicensing is all code that is considered part of the LLVM
1191 project, including the main LLVM repository, runtime libraries (compiler_rt,
1192 OpenMP, etc), Polly, and all other subprojects.  There are a few exceptions:
1194 * Code imported from other projects (e.g. Google Test, Autoconf, etc) will
1195   remain as it is.  This code isn't developed as part of the LLVM project, it
1196   is used by LLVM.
1197 * Some subprojects are impractical or uninteresting to relicense (e.g. llvm-gcc
1198   and dragonegg). These will be split off from the LLVM project (e.g. to
1199   separate GitHub projects), allowing interested people to continue their
1200   development elsewhere.
1202 To relicense LLVM, we will be seeking approval from all of the copyright holders
1203 of code in the repository, or potentially remove/rewrite code if we cannot.
1204 This is a large
1205 and challenging project which will take a significant amount of time to
1206 complete.
1208 Starting on 2024-06-01 (first of June 2024), new contributions only need to
1209 be covered by the new LLVM license, i.e. Apache-2.0 WITH LLVM-exception.
1210 Before this date, the project required all contributions to be made under
1211 both the new license and the legacy license.
1213 If you are a contributor to LLVM with contributions committed before 2019-01-19
1214 and have not done so already, please do follow the instructions at
1215 https://foundation.llvm.org/docs/relicensing/, under section "Individual
1216 Relicensing Agreement" to relicense your contributions under the new license.
1219 .. _open source licensing terms:
1221 New LLVM Project License Framework
1222 ----------------------------------
1224 Contributions to LLVM are licensed under the `Apache License, Version 2.0
1225 <https://www.apache.org/licenses/LICENSE-2.0>`_, with two limited
1226 exceptions intended to ensure that LLVM is very permissively licensed.
1227 Collectively, the name of this license is "Apache 2.0 License with LLVM
1228 exceptions".  The exceptions read:
1232    ---- LLVM Exceptions to the Apache 2.0 License ----
1234    As an exception, if, as a result of your compiling your source code, portions
1235    of this Software are embedded into an Object form of such source code, you
1236    may redistribute such embedded portions in such Object form without complying
1237    with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
1239    In addition, if you combine or link compiled forms of this Software with
1240    software that is licensed under the GPLv2 ("Combined Software") and if a
1241    court of competent jurisdiction determines that the patent provision (Section
1242    3), the indemnity provision (Section 9) or other Section of the License
1243    conflicts with the conditions of the GPLv2, you may retroactively and
1244    prospectively choose to deem waived or otherwise exclude such Section(s) of
1245    the License, but only in their entirety and only with respect to the Combined
1246    Software.
1249 We intend to keep LLVM perpetually open source and available under a permissive
1250 license - this fosters the widest adoption of LLVM by
1251 **allowing commercial products to be derived from LLVM** with few restrictions
1252 and without a requirement for making any derived works also open source.  In
1253 particular, LLVM's license is not a "copyleft" license like the GPL.
1255 The "Apache 2.0 License with LLVM exceptions" allows you to:
1257 * freely download and use LLVM (in whole or in part) for personal, internal, or
1258   commercial purposes.
1259 * include LLVM in packages or distributions you create.
1260 * combine LLVM with code licensed under every other major open source
1261   license (including BSD, MIT, GPLv2, GPLv3...).
1262 * make changes to LLVM code without being required to contribute it back
1263   to the project - contributions are appreciated though!
1265 However, it imposes these limitations on you:
1267 * You must retain the copyright notice if you redistribute LLVM: You cannot
1268   strip the copyright headers off or replace them with your own.
1269 * Binaries that include LLVM must reproduce the copyright notice (e.g. in an
1270   included README file or in an "About" box), unless the LLVM code was added as
1271   a by-product of compilation.  For example, if an LLVM runtime library like
1272   compiler_rt or libc++ was automatically included into your application by the
1273   compiler, you do not need to attribute it.
1274 * You can't use our names to promote your products (LLVM derived or not) -
1275   though you can make truthful statements about your use of the LLVM code,
1276   without implying our sponsorship.
1277 * There's no warranty on LLVM at all.
1279 We want LLVM code to be widely used, and believe that this provides a model that
1280 is great for contributors and users of the project.  For more information about
1281 the Apache 2.0 License, please see the `Apache License FAQ
1282 <http://www.apache.org/foundation/license-faq.html>`_, maintained by the
1283 Apache Project.
1285 .. _patent license:
1287 Patents
1288 -------
1290 Section 3 of the Apache 2.0 license is a patent grant under which
1291 contributors of code to the project contribute the rights to use any of
1292 their patents that would otherwise be infringed by that code contribution
1293 (protecting uses of that code).  Further, the patent grant is revoked
1294 from anyone who files a patent lawsuit about code in LLVM - this protects the
1295 community by providing a "patent commons" for the code base and reducing the
1296 odds of patent lawsuits in general.
1298 The license specifically scopes which patents are included with code
1299 contributions.  To help explain this, the `Apache License FAQ
1300 <http://www.apache.org/foundation/license-faq.html>`_ explains this scope using
1301 some questions and answers, which we reproduce here for your convenience (for
1302 reference, the "ASF" is the Apache Software Foundation, the guidance still
1303 holds though)::
1305    Q1: If I own a patent and contribute to a Work, and, at the time my
1306    contribution is included in that Work, none of my patent's claims are subject
1307    to Apache's Grant of Patent License, is there a way any of those claims would
1308    later become subject to the Grant of Patent License solely due to subsequent
1309    contributions by other parties who are not licensees of that patent.
1311    A1: No.
1313    Q2: If at any time after my contribution, I am able to license other patent
1314    claims that would have been subject to Apache's Grant of Patent License if
1315    they were licensable by me at the time of my contribution, do those other
1316    claims become subject to the Grant of Patent License?
1318    A2: Yes.
1320    Q3: If I own or control a licensable patent and contribute code to a specific
1321    Apache product, which of my patent claims are subject to Apache's Grant of
1322    Patent License?
1324    A3:  The only patent claims that are licensed to the ASF are those you own or
1325    have the right to license that read on your contribution or on the
1326    combination of your contribution with the specific Apache product to which
1327    you contributed as it existed at the time of your contribution. No additional
1328    patent claims become licensed as a result of subsequent combinations of your
1329    contribution with any other software. Note, however, that licensable patent
1330    claims include those that you acquire in the future, as long as they read on
1331    your original contribution as made at the original time. Once a patent claim
1332    is subject to Apache's Grant of Patent License, it is licensed under the
1333    terms of that Grant to the ASF and to recipients of any software distributed
1334    by the ASF for any Apache software product whatsoever.
1336 .. _legacy:
1338 Legacy License Structure
1339 ------------------------
1341 .. note::
1342    The code base was previously licensed under the Terms described here.
1343    We are in the middle of relicensing to a new approach (described above).
1344    More than 99% of all contributions made to LLVM are covered by the Apache-2.0
1345    WITH LLVM-exception license. A small portion of LLVM code remains exclusively
1346    covered by the legacy license. Contributions after 2024-06-01 are covered
1347    exclusively by the new license._
1349 We intend to keep LLVM perpetually open source and to use a permissive open
1350 source license.  The code in
1351 LLVM is available under the `University of Illinois/NCSA Open Source License
1352 <http://www.opensource.org/licenses/UoI-NCSA.php>`_, which boils down to
1353 this:
1355 * You can freely distribute LLVM.
1356 * You must retain the copyright notice if you redistribute LLVM.
1357 * Binaries derived from LLVM must reproduce the copyright notice (e.g. in an
1358   included README file).
1359 * You can't use our names to promote your LLVM derived products.
1360 * There's no warranty on LLVM at all.
1362 We believe this fosters the widest adoption of LLVM because it **allows
1363 commercial products to be derived from LLVM** with few restrictions and without
1364 a requirement for making any derived works also open source (i.e. LLVM's
1365 license is not a "copyleft" license like the GPL). We suggest that you read the
1366 `License <http://www.opensource.org/licenses/UoI-NCSA.php>`_ if further
1367 clarification is needed.
1369 In addition to the UIUC license, the runtime library components of LLVM
1370 (**compiler_rt, libc++, and libclc**) are also licensed under the `MIT License
1371 <http://www.opensource.org/licenses/mit-license.php>`_, which does not contain
1372 the binary redistribution clause.  As a user of these runtime libraries, it
1373 means that you can choose to use the code under either license (and thus don't
1374 need the binary redistribution clause), and as a contributor to the code that
1375 you agree that any contributions to these libraries be licensed under both
1376 licenses.  We feel that this is important for runtime libraries, because they
1377 are implicitly linked into applications and therefore should not subject those
1378 applications to the binary redistribution clause. This also means that it is ok
1379 to move code from (e.g.)  libc++ to the LLVM core without concern, but that code
1380 cannot be moved from the LLVM core to libc++ without the copyright owner's
1381 permission.
1383 .. _ai contributions:
1385 AI generated contributions
1386 --------------------------
1388 Artificial intelligence systems raise many questions around copyright that have
1389 yet to be answered. Our policy on AI tools is guided by our copyright policy:
1390 Contributors are responsible for ensuring that they have the right to contribute
1391 code under the terms of our license, typically meaning that either they, their
1392 employer, or their collaborators hold the copyright. Using AI tools to
1393 regenerate copyrighted material does not remove the copyright, and contributors
1394 are responsible for ensuring that such material does not appear in their
1395 contributions.
1397 As such, the LLVM policy is that contributors are permitted to use artificial
1398 intelligence tools to produce contributions, provided that they have the right
1399 to license that code under the project license. Contributions found to violate
1400 this policy will be removed just like any other offending contribution.
1402 While the LLVM project has a liberal policy on AI tool use, contributors are
1403 considered responsible for their contributions. We encourage contributors to
1404 review all generated code before sending it for review to verify its
1405 correctness and to understand it so that they can answer questions during code
1406 review. Reviewing and maintaining generated code that the original contributor
1407 does not understand is not a good use of limited project resources.