Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Add a section on AI-generated content to the developer policy #91014

Merged
merged 7 commits into from
Sep 10, 2024

Conversation

rnk
Copy link
Collaborator

@rnk rnk commented May 3, 2024

Governments around the world are starting to require labelling for AI-generated content, and some LLVM stakeholders have asked if LLVM contains AI-generated content. Defining a policy on the use of AI tools allows us to answer that question affirmatively, one way of the other.

The policy proposed here allows the use of AI tools in LLVM contributions, flowing from the idea that any contribution is fine regardless of how it is made, as long as the contributor has the right to license it under the project license.

I will post an RFC on this topic on Discourse before merging this so we can gather input beyond the reviewers I've listed here.

@rnk rnk requested review from joker-eph, lattner and llvm-beanz May 3, 2024 21:13
@rengolin
Copy link
Member

rengolin commented May 3, 2024

Concise and precise. +1 from me.

@lattner
Copy link
Collaborator

lattner commented May 4, 2024

This LGTM (with some discussion to confirm there are not important objections), thank you so much for driving this Reid!

@joker-eph
Copy link
Collaborator

LGTM, thanks.

Copy link
Collaborator

@searlmc1 searlmc1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"... are permitted to to use..."

minor typo: 'to' is repeated

@saiislam
Copy link
Contributor

saiislam commented Sep 4, 2024

@rnk any plans to merge this PR, or take the discourse discussion to a conclusion?

@rnk
Copy link
Collaborator Author

rnk commented Sep 4, 2024

My reading of the RFC is that most folks are in favor of a liberal policy on AI tool use as covered in this policy, but there was a lot of feedback that folks want to discourage low-effort AI-assisted contributions. This wouldn't be policy, just guidance, but there were several voices calling for it, and that's what's been blocking me from merging this as is.


I added a paragraph, PTAL

rnk added 4 commits September 4, 2024 16:53
This potentially affects platforms that support comdats other than ELF,
COFF, or wasm, but that is the intention of the FIXME, and if they don't
want this behavior, they probably shouldn't advertise comdat support.
Governments around the world are starting to require labelling for
AI-generated content, and some LLVM stakeholders have asked if LLVM
contains AI-generated content. Defining a policy on the use of AI tools
allows us to answer that question affirmatively, one way of the other.

The policy proposed here allows the use of AI tools in LLVM
contributions, flowing from the idea that any contribution is fine
regardless of how it is made, as long as the contributor has the right
to license it under the project license.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:codegen labels Sep 4, 2024
@llvmbot
Copy link
Member

llvmbot commented Sep 4, 2024

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-codegen

Author: Reid Kleckner (rnk)

Changes

Governments around the world are starting to require labelling for AI-generated content, and some LLVM stakeholders have asked if LLVM contains AI-generated content. Defining a policy on the use of AI tools allows us to answer that question affirmatively, one way of the other.

The policy proposed here allows the use of AI tools in LLVM contributions, flowing from the idea that any contribution is fine regardless of how it is made, as long as the contributor has the right to license it under the project license.

I will post an RFC on this topic on Discourse before merging this so we can gather input beyond the reviewers I've listed here.


Full diff: https://github.com/llvm/llvm-project/pull/91014.diff

3 Files Affected:

  • (modified) clang/lib/CodeGen/CGDeclCXX.cpp (+6-6)
  • (modified) llvm/docs/DeveloperPolicy.rst (+27-1)
  • (modified) llvm/docs/FAQ.rst (+7)
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 8dcb5f61006196..c44f38ef02a3f1 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -640,13 +640,13 @@ CodeGenModule::EmitCXXGlobalVarDeclInitFunc(const VarDecl *D,
       addUsedGlobal(COMDATKey);
     }
 
-    // If we used a COMDAT key for the global ctor, the init function can be
-    // discarded if the global ctor entry is discarded.
-    // FIXME: Do we need to restrict this to ELF and Wasm?
+    // If comdats are in use and supported, place the initializer function into
+    // the comdat group of the global. In the MS ABI, initializers are mangled
+    // and have their own comdat, so we don't include them in the group for
+    // consistency with MSVC.
     llvm::Comdat *C = Addr->getComdat();
-    if (COMDATKey && C &&
-        (getTarget().getTriple().isOSBinFormatELF() ||
-         getTarget().getTriple().isOSBinFormatWasm())) {
+    if (COMDATKey && C && getTriple().supportsCOMDAT() &&
+        !getTarget().getCXXABI().isMicrosoft()) {
       Fn->setComdat(C);
     }
   } else {
diff --git a/llvm/docs/DeveloperPolicy.rst b/llvm/docs/DeveloperPolicy.rst
index 49ec310b382f94..3f568f8372aa9e 100644
--- a/llvm/docs/DeveloperPolicy.rst
+++ b/llvm/docs/DeveloperPolicy.rst
@@ -1077,6 +1077,8 @@ If you have questions or comments about these topics, please ask on the
 please realize that most compiler developers are not lawyers, and therefore you
 will not be getting official legal advice.
 
+.. _LLVM Discourse forums: https://discourse.llvm.org
+
 Copyright
 ---------
 
@@ -1301,4 +1303,28 @@ to move code from (e.g.)  libc++ to the LLVM core without concern, but that code
 cannot be moved from the LLVM core to libc++ without the copyright owner's
 permission.
 
-.. _LLVM Discourse forums: https://discourse.llvm.org
+.. _ai contributions:
+
+AI generated contributions
+--------------------------
+
+Artificial intelligence systems raise many questions around copyright that have
+yet to be answered. Our policy on AI tools is guided by our copyright policy:
+contributors are responsible for ensuring that they have the right to contribute
+code under the terms of our license, typically meaning that either they, their
+employer, or their collaborators hold the copyright. Using AI tools to
+regenerate copyrighted material does not remove the copyright, and contributors
+are responsible for ensuring that such material does not appear in their
+contributions.
+
+As such, the LLVM policy is that contributors are permitted to to use artificial
+intelligence tools to produce contributions, provided that they have the right
+to license that code under the project license. Contributions found to violate
+this policy will be removed just like any other offending contribution.
+
+While the LLVM project has a liberal policy on AI tool use, contributors are
+considered responsible for their contributions. We encourage contributors to
+review all generated code before sending it for review to verify its
+correctness and to understand it so that they can answer questions during code
+review. Reviewing and maintaining generated code that the original contributor
+does not understand is not a good use of limited project resources.
diff --git a/llvm/docs/FAQ.rst b/llvm/docs/FAQ.rst
index 229ac99f703c19..aa20de47a69980 100644
--- a/llvm/docs/FAQ.rst
+++ b/llvm/docs/FAQ.rst
@@ -22,6 +22,13 @@ Yes. This is why we distribute LLVM under a less restrictive license than GPL,
 as explained in the first question above.
 
 
+Can I use AI coding tools, such as GitHub co-pilot, to write LLVM patches?
+--------------------------------------------------------------------------
+Yes, as long as the resulting work can be licensed under the project license, as
+covered in the :doc:`DeveloperPolicy`. Using an AI tool to reproduce copyrighted
+work does not rinse it of copyright and grant you the right to relicense it.
+
+
 Source Code
 ===========
 

llvm/docs/DeveloperPolicy.rst Outdated Show resolved Hide resolved
llvm/docs/DeveloperPolicy.rst Outdated Show resolved Hide resolved
rnk and others added 2 commits September 10, 2024 16:14
Co-authored-by: maflcko <6399679+maflcko@users.noreply.github.com>
Co-authored-by: maflcko <6399679+maflcko@users.noreply.github.com>
@rnk rnk merged commit 829ea59 into llvm:main Sep 10, 2024
6 of 8 checks passed
VitaNuo pushed a commit to VitaNuo/llvm-project that referenced this pull request Sep 12, 2024
…lvm#91014)

Governments around the world are starting to require labelling for
AI-generated content, and some LLVM stakeholders have asked if LLVM
contains AI-generated content. Defining a policy on the use of AI tools
allows us to answer that question affirmatively, one way of the other.

The policy proposed here allows the use of AI tools in LLVM
contributions, flowing from the idea that any contribution is fine
regardless of how it is made, as long as the contributor has the right
to license it under the project license.

I gathered input from the community in this RFC and incorporated it into the policy:
https://discourse.llvm.org/t/rfc-define-policy-on-ai-tool-usage-in-contributions/78758
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:codegen clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants