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