-
Notifications
You must be signed in to change notification settings - Fork 15.7k
[SystemZ][z/OS] Improve use of formatv #174503
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
Using a `raw_svector_ostream` object is not necessary, because this is hidden in the conversion function. In addition, there is no need to reason about a zero termination of the string. Declaring the ascii and ebcdic version of the string variables at the same time makes sure that both strings are allocated with the same size.
|
@llvm/pr-subscribers-backend-systemz Author: Kai Nacke (redstar) ChangesUsing a Full diff: https://github.com/llvm/llvm-project/pull/174503.diff 1 Files Affected:
diff --git a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
index 444bc578a3fab..332a38281eab0 100644
--- a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
@@ -1602,25 +1602,19 @@ void SystemZAsmPrinter::emitPPA2(Module &M) {
MCSymbol *DateVersionSym = OutContext.createTempSymbol("DVS", false);
std::time_t Time = getTranslationTime(M);
- SmallString<15> CompilationTime; // 14 + null
- raw_svector_ostream O(CompilationTime);
- O << formatv("{0:%Y%m%d%H%M%S}", llvm::sys::toUtcTime(Time));
+ SmallString<14> CompilationTimeEBCDIC, CompilationTime;
+ CompilationTime = formatv("{0:%Y%m%d%H%M%S}", llvm::sys::toUtcTime(Time));
uint32_t ProductVersion = getProductVersion(M),
ProductRelease = getProductRelease(M),
ProductPatch = getProductPatch(M);
- SmallString<7> Version; // 6 + null
- raw_svector_ostream ostr(Version);
- ostr << formatv("{0,0-2:d}{1,0-2:d}{2,0-2:d}", ProductVersion, ProductRelease,
- ProductPatch);
+ SmallString<6> VersionEBCDIC, Version;
+ Version = formatv("{0,0-2:d}{1,0-2:d}{2,0-2:d}", ProductVersion,
+ ProductRelease, ProductPatch);
- // Drop 0 during conversion.
- SmallString<sizeof(CompilationTime) - 1> CompilationTimeStr;
- SmallString<sizeof(Version) - 1> VersionStr;
-
- ConverterEBCDIC::convertToEBCDIC(CompilationTime, CompilationTimeStr);
- ConverterEBCDIC::convertToEBCDIC(Version, VersionStr);
+ ConverterEBCDIC::convertToEBCDIC(CompilationTime, CompilationTimeEBCDIC);
+ ConverterEBCDIC::convertToEBCDIC(Version, VersionEBCDIC);
enum class PPA2MemberId : uint8_t {
// See z/OS Language Environment Vendor Interfaces v2r5, p.23, for
@@ -1689,8 +1683,8 @@ void SystemZAsmPrinter::emitPPA2(Module &M) {
// Emit date and version section.
OutStreamer->emitLabel(DateVersionSym);
- OutStreamer->emitBytes(CompilationTimeStr.str());
- OutStreamer->emitBytes(VersionStr.str());
+ OutStreamer->emitBytes(CompilationTimeEBCDIC.str());
+ OutStreamer->emitBytes(VersionEBCDIC.str());
OutStreamer->emitInt16(0x0000); // Service level string length.
|
perry-ca
left a comment
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
uweigand
left a comment
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, thanks!
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/129/builds/36089 Here is the relevant piece of the build log for the reference |
Using a
raw_svector_ostreamobject is not necessary, because this is hidden in the conversion function. In addition, there is no need to reason about a zero termination of the string. Declaring the ascii and ebcdic version of the string variables at the same time makes sure that both strings are allocated with the same size.