-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[AIX] Add git revision to .file string #88164
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
Conversation
@llvm/pr-subscribers-backend-powerpc Author: Jake Egan (jakeegan) ChangesIf Before: After: Full diff: https://github.com/llvm/llvm-project/pull/88164.diff 2 Files Affected:
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 721d144d7f4c67..1072fce89e3099 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -114,6 +114,7 @@
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Timer.h"
+#include "llvm/Support/VCSRevision.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetMachine.h"
@@ -497,12 +498,15 @@ bool AsmPrinter::doInitialization(Module &M) {
else
FileName = M.getSourceFileName();
if (MAI->hasFourStringsDotFile()) {
-#ifdef PACKAGE_VENDOR
const char VerStr[] =
- PACKAGE_VENDOR " " PACKAGE_NAME " version " PACKAGE_VERSION;
-#else
- const char VerStr[] = PACKAGE_NAME " version " PACKAGE_VERSION;
+#ifdef PACKAGE_VENDOR
+ PACKAGE_VENDOR " "
+#endif
+ PACKAGE_NAME " version " PACKAGE_VERSION
+#ifdef LLVM_REVISION
+ " (" LLVM_REVISION ")"
#endif
+ ;
// TODO: Add timestamp and description.
OutStreamer->emitFileDirective(FileName, VerStr, "", "");
} else {
diff --git a/llvm/test/CodeGen/PowerPC/git_revision.ll b/llvm/test/CodeGen/PowerPC/git_revision.ll
new file mode 100644
index 00000000000000..280c311c8bd7c8
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/git_revision.ll
@@ -0,0 +1,13 @@
+; Check that the git revision is contained in the assembly/object files
+
+; RUN: cd %S && git rev-parse HEAD > %t
+
+; RUN: llc < %s > %t.a.o
+; RUN: sed -n -e "/$(cat %t)/p" %t.a.o
+
+; RUN: llc -filetype=obj < %s > %t.b.o
+; RUN: sed -n -e "/$(cat %t)/p" %t.b.o
+
+source_filename = "git_revision.cpp"
+target datalayout = "E-m:a-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512"
+target triple = "powerpc64-ibm-aix7.2.0.0"
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
Addressed comments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I left some additional nit's you should consider addressing before landing this
Addressed nits |
This already happens implicitly because we don't build from a git checkout. However, currently this also breaks the build due to llvm/llvm-project#88164. Avoid this by explicitly disabling the option.
If
LLVM_APPEND_VC_REV
is on, add the git revision to the.file
string. The revision can be set withLLVM_FORCE_VC_REVISION
.Before:
.file "git_revision.cpp",,"LLVM version 19.0.0git"
After:
.file "git_revision.cpp",,"LLVM version 19.0.0git (LLVM_REVISION)"