[llvm] [AIX] Add git revision to .file string (PR #88164)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 9 10:39:16 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-powerpc
Author: Jake Egan (jakeegan)
<details>
<summary>Changes</summary>
If `LLVM_APPEND_VC_REV` is on, add the git revision to the `.file` string. The revision can be set with `LLVM_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)"`
---
Full diff: https://github.com/llvm/llvm-project/pull/88164.diff
2 Files Affected:
- (modified) llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (+8-4)
- (added) llvm/test/CodeGen/PowerPC/git_revision.ll (+13)
``````````diff
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"
``````````
</details>
https://github.com/llvm/llvm-project/pull/88164
More information about the llvm-commits
mailing list