[llvm] [AIX] Add git revision to .file string (PR #88164)
Jake Egan via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 9 10:38:44 PDT 2024
https://github.com/jakeegan created https://github.com/llvm/llvm-project/pull/88164
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)"`
>From 4dc5015fb04cd8c3b21d02b778c653947703438f Mon Sep 17 00:00:00 2001
From: Jake Egan <jake.egan at ibm.com>
Date: Tue, 9 Apr 2024 12:41:14 -0400
Subject: [PATCH] [AIX] Add git revision to .file string
---
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 12 ++++++++----
llvm/test/CodeGen/PowerPC/git_revision.ll | 13 +++++++++++++
2 files changed, 21 insertions(+), 4 deletions(-)
create mode 100644 llvm/test/CodeGen/PowerPC/git_revision.ll
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"
More information about the llvm-commits
mailing list