[PATCH] D102814: [AIX] Print printable byte list as quoted string

2021-05-20 Thread Jinsong Ji via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGedf4d69d3888: [AIX] Print printable byte list as quoted 
string (authored by jsji).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102814/new/

https://reviews.llvm.org/D102814

Files:
  clang/test/CodeGenCXX/debug-info-byval.cpp
  llvm/include/llvm/MC/MCAsmInfo.h
  llvm/lib/MC/MCAsmInfoXCOFF.cpp
  llvm/lib/MC/MCAsmStreamer.cpp
  llvm/test/CodeGen/PowerPC/aix-emit-tracebacktable-clobber-register.ll
  llvm/test/CodeGen/PowerPC/aix-emit-tracebacktable.ll
  llvm/test/CodeGen/PowerPC/aix-exception.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-data-sections.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-data.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-rodata.ll
  llvm/test/DebugInfo/XCOFF/empty.ll
  llvm/test/DebugInfo/XCOFF/explicit-section.ll
  llvm/test/DebugInfo/XCOFF/function-sections.ll

Index: llvm/test/DebugInfo/XCOFF/function-sections.ll
===
--- llvm/test/DebugInfo/XCOFF/function-sections.ll
+++ llvm/test/DebugInfo/XCOFF/function-sections.ll
@@ -72,7 +72,7 @@
 ; CHECK-NEXT:  .byte   0x01# NumberOfFPParms = 0, +HasParmsOnStack
 ; CHECK-NEXT:  .vbyte  4, L..foo0-.foo[PR] # Function size
 ; CHECK-NEXT:  .vbyte  2, 0x0003   # Function name len = 3
-; CHECK-NEXT:  .byte   'f,'o,'o# Function Name
+; CHECK-NEXT:  .byte   "foo"   # Function Name
 ; CHECK-NEXT:  L..func_end0:
 ; CHECK-NEXT:  # -- End function
 ; CHECK-NEXT:  .csect .bar[PR],2
@@ -108,7 +108,7 @@
 ; CHECK-NEXT:  .byte   0x01# NumberOfFPParms = 0, +HasParmsOnStack
 ; CHECK-NEXT:  .vbyte  4, L..bar0-.bar[PR] # Function size
 ; CHECK-NEXT:  .vbyte  2, 0x0003   # Function name len = 3
-; CHECK-NEXT:  .byte   'b,'a,'r# Function Name
+; CHECK-NEXT:  .byte   "bar"   # Function Name
 ; CHECK-NEXT:  L..func_end1:
 ; CHECK-NEXT:  # -- End function
 ; CHECK-NEXT:  L..sec_end0:
@@ -222,17 +222,17 @@
 ; CHECK:   .dwsect 0x7
 ; CHECK-NEXT:  L...dwstr:
 ; CHECK-NEXT:  L..info_string0:
-; CHECK-NEXT:  .byte   'c,'l,'a,'n,'g,' ,'v,'e,'r,'s,'i,'o,'n,' ,'1,'3,'.,'0,'.,'0, # string offset=0
+; CHECK-NEXT:  .string "clang version 13.0.0"  # string offset=0
 ; CHECK-NEXT:  L..info_string1:
-; CHECK-NEXT:  .byte   '1,'.,'c,   # string offset=21
+; CHECK-NEXT:  .string "1.c"   # string offset=21
 ; CHECK-NEXT:  L..info_string2:
-; CHECK-NEXT:  .byte   'd,'e,'b,'u,'g, # string offset=25
+; CHECK-NEXT:  .string "debug" # string offset=25
 ; CHECK-NEXT:  L..info_string3:
-; CHECK-NEXT:  .byte   'f,'o,'o,   # string offset=31
+; CHECK-NEXT:  .string "foo"   # string offset=31
 ; CHECK-NEXT:  L..info_string4:
-; CHECK-NEXT:  .byte   'i,'n,'t,   # string offset=35
+; CHECK-NEXT:  .string "int"   # string offset=35
 ; CHECK-NEXT:  L..info_string5:
-; CHECK-NEXT:  .byte   'b,'a,'r,   # string offset=39
+; CHECK-NEXT:  .string "bar"   # string offset=39
 ; CHECK-NEXT:  .toc
 ; CHECK:   .dwsect 0x2
 ; CHECK-NEXT:  L...dwline:
@@ -258,10 +258,10 @@
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   1
-; CHECK-NEXT:  .byte   'd,'e,'b,'u,'g
+; CHECK-NEXT:  .byte   "debug"
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   0
-; CHECK-NEXT:  .byte   '1,'.,'c
+; CHECK-NEXT:  .byte   "1.c"
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   1
 ; CHECK-NEXT:  .byte   0
Index: llvm/test/DebugInfo/XCOFF/explicit-section.ll
===
--- llvm/test/DebugInfo/XCOFF/explicit-section.ll
+++ llvm/test/DebugInfo/XCOFF/explicit-section.ll
@@ -77,7 +77,7 @@
 ; CHECK-NEXT:  .byte   0x01# NumberOfFPParms = 0, +HasParmsOnStack
 ; CHECK-NEXT:  .vbyte  4, L..bar0-.bar # Function size
 ; CHECK-NEXT:  .vbyte  2, 0x0003   # Function name len = 3
-; CHECK-NEXT:  .byte   'b,'a,'r# Function Name
+; CHECK-NEXT:  .byte   "bar"   # Function Name
 ; CHECK-NEXT: 

[PATCH] D102814: [AIX] Print printable byte list as quoted string

2021-05-20 Thread Jinsong Ji via Phabricator via cfe-commits
jsji updated this revision to Diff 346907.
jsji added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102814/new/

https://reviews.llvm.org/D102814

Files:
  clang/test/CodeGenCXX/debug-info-byval.cpp
  llvm/include/llvm/MC/MCAsmInfo.h
  llvm/lib/MC/MCAsmInfoXCOFF.cpp
  llvm/lib/MC/MCAsmStreamer.cpp
  llvm/test/CodeGen/PowerPC/aix-emit-tracebacktable-clobber-register.ll
  llvm/test/CodeGen/PowerPC/aix-emit-tracebacktable.ll
  llvm/test/CodeGen/PowerPC/aix-exception.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-data-sections.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-data.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-rodata.ll
  llvm/test/DebugInfo/XCOFF/empty.ll
  llvm/test/DebugInfo/XCOFF/explicit-section.ll
  llvm/test/DebugInfo/XCOFF/function-sections.ll

Index: llvm/test/DebugInfo/XCOFF/function-sections.ll
===
--- llvm/test/DebugInfo/XCOFF/function-sections.ll
+++ llvm/test/DebugInfo/XCOFF/function-sections.ll
@@ -72,7 +72,7 @@
 ; CHECK-NEXT:  .byte   0x01# NumberOfFPParms = 0, +HasParmsOnStack
 ; CHECK-NEXT:  .vbyte  4, L..foo0-.foo[PR] # Function size
 ; CHECK-NEXT:  .vbyte  2, 0x0003   # Function name len = 3
-; CHECK-NEXT:  .byte   'f,'o,'o# Function Name
+; CHECK-NEXT:  .byte   "foo"   # Function Name
 ; CHECK-NEXT:  L..func_end0:
 ; CHECK-NEXT:  # -- End function
 ; CHECK-NEXT:  .csect .bar[PR],2
@@ -108,7 +108,7 @@
 ; CHECK-NEXT:  .byte   0x01# NumberOfFPParms = 0, +HasParmsOnStack
 ; CHECK-NEXT:  .vbyte  4, L..bar0-.bar[PR] # Function size
 ; CHECK-NEXT:  .vbyte  2, 0x0003   # Function name len = 3
-; CHECK-NEXT:  .byte   'b,'a,'r# Function Name
+; CHECK-NEXT:  .byte   "bar"   # Function Name
 ; CHECK-NEXT:  L..func_end1:
 ; CHECK-NEXT:  # -- End function
 ; CHECK-NEXT:  L..sec_end0:
@@ -222,17 +222,17 @@
 ; CHECK:   .dwsect 0x7
 ; CHECK-NEXT:  L...dwstr:
 ; CHECK-NEXT:  L..info_string0:
-; CHECK-NEXT:  .byte   'c,'l,'a,'n,'g,' ,'v,'e,'r,'s,'i,'o,'n,' ,'1,'3,'.,'0,'.,'0, # string offset=0
+; CHECK-NEXT:  .string "clang version 13.0.0"  # string offset=0
 ; CHECK-NEXT:  L..info_string1:
-; CHECK-NEXT:  .byte   '1,'.,'c,   # string offset=21
+; CHECK-NEXT:  .string "1.c"   # string offset=21
 ; CHECK-NEXT:  L..info_string2:
-; CHECK-NEXT:  .byte   'd,'e,'b,'u,'g, # string offset=25
+; CHECK-NEXT:  .string "debug" # string offset=25
 ; CHECK-NEXT:  L..info_string3:
-; CHECK-NEXT:  .byte   'f,'o,'o,   # string offset=31
+; CHECK-NEXT:  .string "foo"   # string offset=31
 ; CHECK-NEXT:  L..info_string4:
-; CHECK-NEXT:  .byte   'i,'n,'t,   # string offset=35
+; CHECK-NEXT:  .string "int"   # string offset=35
 ; CHECK-NEXT:  L..info_string5:
-; CHECK-NEXT:  .byte   'b,'a,'r,   # string offset=39
+; CHECK-NEXT:  .string "bar"   # string offset=39
 ; CHECK-NEXT:  .toc
 ; CHECK:   .dwsect 0x2
 ; CHECK-NEXT:  L...dwline:
@@ -258,10 +258,10 @@
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   1
-; CHECK-NEXT:  .byte   'd,'e,'b,'u,'g
+; CHECK-NEXT:  .byte   "debug"
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   0
-; CHECK-NEXT:  .byte   '1,'.,'c
+; CHECK-NEXT:  .byte   "1.c"
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   1
 ; CHECK-NEXT:  .byte   0
Index: llvm/test/DebugInfo/XCOFF/explicit-section.ll
===
--- llvm/test/DebugInfo/XCOFF/explicit-section.ll
+++ llvm/test/DebugInfo/XCOFF/explicit-section.ll
@@ -77,7 +77,7 @@
 ; CHECK-NEXT:  .byte   0x01# NumberOfFPParms = 0, +HasParmsOnStack
 ; CHECK-NEXT:  .vbyte  4, L..bar0-.bar # Function size
 ; CHECK-NEXT:  .vbyte  2, 0x0003   # Function name len = 3
-; CHECK-NEXT:  .byte   'b,'a,'r# Function Name
+; CHECK-NEXT:  .byte   "bar"   # Function Name
 ; CHECK-NEXT:  L..func_end0:
 ; CHECK-NEXT:  # -- End function
 ; CHECK-NEXT:  .csect explicit_main_sec[PR],2
@@ 

[PATCH] D102814: [AIX] Print printable byte list as quoted string

2021-05-20 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.
This revision is now accepted and ready to land.

LGTM with minor comments; thanks!




Comment at: llvm/include/llvm/MC/MCAsmInfo.h:268-270
+  /// This directive allows emission of an ascii string without the standard C
+  /// escape characters embedded into it.  If a target doesn't support this, it
+  /// can be set to null. Defaults to null.

See suggested edit. Emphasizing the difference from `.ascii` by starting with 
its associated comment is nice. Need to indicate that this is the 
zero-terminated case though.



Comment at: llvm/lib/MC/MCAsmStreamer.cpp:1012-1014
+  if (isPrint(Data.back()) || Data.back() == 0)
+return true;
+  return false;

Minor comment: Can just return the expression instead of using it for 
`if`/`else`.



Comment at: llvm/lib/MC/MCAsmStreamer.cpp:1128
+   isPrintableString(Data)) {
+  // For target with DoubleQuteString constants, .string and .byte are used
+  // as replacement of .asciz and .ascii.

Minor nit: typo.



Comment at: llvm/lib/MC/MCAsmStreamer.cpp:1139-1140
+Data = Data.substr(0, Data.size() - 1);
+  } else
+OS << MAI->getByteListDirective();
 } else if (MAI->getByteListDirective()) {

The style guide was clarified some time ago to indicate that mixing use/non-use 
of braces in an `if`/`else` chain is discouraged.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102814/new/

https://reviews.llvm.org/D102814

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102814: [AIX] Print printable byte list as quoted string

2021-05-20 Thread Jinsong Ji via Phabricator via cfe-commits
jsji added inline comments.



Comment at: llvm/lib/MC/MCAsmStreamer.cpp:1008
+  for (const unsigned char C : Data) {
+if (!isPrint(C))
+  return false;

jsji wrote:
> This still need some slight change to deal with the ending 0 so that we can 
> handle .string.
Done.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102814/new/

https://reviews.llvm.org/D102814

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102814: [AIX] Print printable byte list as quoted string

2021-05-20 Thread Jinsong Ji via Phabricator via cfe-commits
jsji updated this revision to Diff 346830.
jsji added a comment.

Update .string handling.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102814/new/

https://reviews.llvm.org/D102814

Files:
  clang/test/CodeGenCXX/debug-info-byval.cpp
  llvm/include/llvm/MC/MCAsmInfo.h
  llvm/lib/MC/MCAsmInfoXCOFF.cpp
  llvm/lib/MC/MCAsmStreamer.cpp
  llvm/test/CodeGen/PowerPC/aix-emit-tracebacktable-clobber-register.ll
  llvm/test/CodeGen/PowerPC/aix-emit-tracebacktable.ll
  llvm/test/CodeGen/PowerPC/aix-exception.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-data-sections.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-data.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-rodata.ll
  llvm/test/DebugInfo/XCOFF/empty.ll
  llvm/test/DebugInfo/XCOFF/explicit-section.ll
  llvm/test/DebugInfo/XCOFF/function-sections.ll

Index: llvm/test/DebugInfo/XCOFF/function-sections.ll
===
--- llvm/test/DebugInfo/XCOFF/function-sections.ll
+++ llvm/test/DebugInfo/XCOFF/function-sections.ll
@@ -72,7 +72,7 @@
 ; CHECK-NEXT:  .byte   0x01# NumberOfFPParms = 0, +HasParmsOnStack
 ; CHECK-NEXT:  .vbyte  4, L..foo0-.foo[PR] # Function size
 ; CHECK-NEXT:  .vbyte  2, 0x0003   # Function name len = 3
-; CHECK-NEXT:  .byte   'f,'o,'o# Function Name
+; CHECK-NEXT:  .byte   "foo"   # Function Name
 ; CHECK-NEXT:  L..func_end0:
 ; CHECK-NEXT:  # -- End function
 ; CHECK-NEXT:  .csect .bar[PR],2
@@ -108,7 +108,7 @@
 ; CHECK-NEXT:  .byte   0x01# NumberOfFPParms = 0, +HasParmsOnStack
 ; CHECK-NEXT:  .vbyte  4, L..bar0-.bar[PR] # Function size
 ; CHECK-NEXT:  .vbyte  2, 0x0003   # Function name len = 3
-; CHECK-NEXT:  .byte   'b,'a,'r# Function Name
+; CHECK-NEXT:  .byte   "bar"   # Function Name
 ; CHECK-NEXT:  L..func_end1:
 ; CHECK-NEXT:  # -- End function
 ; CHECK-NEXT:  L..sec_end0:
@@ -222,17 +222,17 @@
 ; CHECK:   .dwsect 0x7
 ; CHECK-NEXT:  L...dwstr:
 ; CHECK-NEXT:  L..info_string0:
-; CHECK-NEXT:  .byte   'c,'l,'a,'n,'g,' ,'v,'e,'r,'s,'i,'o,'n,' ,'1,'3,'.,'0,'.,'0, # string offset=0
+; CHECK-NEXT:  .string "clang version 13.0.0"  # string offset=0
 ; CHECK-NEXT:  L..info_string1:
-; CHECK-NEXT:  .byte   '1,'.,'c,   # string offset=21
+; CHECK-NEXT:  .string "1.c"   # string offset=21
 ; CHECK-NEXT:  L..info_string2:
-; CHECK-NEXT:  .byte   'd,'e,'b,'u,'g, # string offset=25
+; CHECK-NEXT:  .string "debug" # string offset=25
 ; CHECK-NEXT:  L..info_string3:
-; CHECK-NEXT:  .byte   'f,'o,'o,   # string offset=31
+; CHECK-NEXT:  .string "foo"   # string offset=31
 ; CHECK-NEXT:  L..info_string4:
-; CHECK-NEXT:  .byte   'i,'n,'t,   # string offset=35
+; CHECK-NEXT:  .string "int"   # string offset=35
 ; CHECK-NEXT:  L..info_string5:
-; CHECK-NEXT:  .byte   'b,'a,'r,   # string offset=39
+; CHECK-NEXT:  .string "bar"   # string offset=39
 ; CHECK-NEXT:  .toc
 ; CHECK:   .dwsect 0x2
 ; CHECK-NEXT:  L...dwline:
@@ -258,10 +258,10 @@
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   1
-; CHECK-NEXT:  .byte   'd,'e,'b,'u,'g
+; CHECK-NEXT:  .byte   "debug"
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   0
-; CHECK-NEXT:  .byte   '1,'.,'c
+; CHECK-NEXT:  .byte   "1.c"
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   1
 ; CHECK-NEXT:  .byte   0
Index: llvm/test/DebugInfo/XCOFF/explicit-section.ll
===
--- llvm/test/DebugInfo/XCOFF/explicit-section.ll
+++ llvm/test/DebugInfo/XCOFF/explicit-section.ll
@@ -77,7 +77,7 @@
 ; CHECK-NEXT:  .byte   0x01# NumberOfFPParms = 0, +HasParmsOnStack
 ; CHECK-NEXT:  .vbyte  4, L..bar0-.bar # Function size
 ; CHECK-NEXT:  .vbyte  2, 0x0003   # Function name len = 3
-; CHECK-NEXT:  .byte   'b,'a,'r# Function Name
+; CHECK-NEXT:  .byte   "bar"   # Function Name
 ; CHECK-NEXT:  L..func_end0:
 ; CHECK-NEXT:  # -- End function
 ; CHECK-NEXT:  .csect 

[PATCH] D102814: [AIX] Print printable byte list as quoted string

2021-05-20 Thread Jinsong Ji via Phabricator via cfe-commits
jsji added inline comments.



Comment at: llvm/lib/MC/MCAsmStreamer.cpp:1008
+  for (const unsigned char C : Data) {
+if (!isPrint(C))
+  return false;

This still need some slight change to deal with the ending 0 so that we can 
handle .string.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102814/new/

https://reviews.llvm.org/D102814

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102814: [AIX] Print printable byte list as quoted string

2021-05-20 Thread Jinsong Ji via Phabricator via cfe-commits
jsji updated this revision to Diff 346794.
jsji added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102814/new/

https://reviews.llvm.org/D102814

Files:
  clang/test/CodeGenCXX/debug-info-byval.cpp
  llvm/include/llvm/MC/MCAsmInfo.h
  llvm/lib/MC/MCAsmInfoXCOFF.cpp
  llvm/lib/MC/MCAsmStreamer.cpp
  llvm/test/CodeGen/PowerPC/aix-emit-tracebacktable-clobber-register.ll
  llvm/test/CodeGen/PowerPC/aix-emit-tracebacktable.ll
  llvm/test/CodeGen/PowerPC/aix-exception.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-data.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-rodata.ll
  llvm/test/DebugInfo/XCOFF/empty.ll
  llvm/test/DebugInfo/XCOFF/explicit-section.ll
  llvm/test/DebugInfo/XCOFF/function-sections.ll

Index: llvm/test/DebugInfo/XCOFF/function-sections.ll
===
--- llvm/test/DebugInfo/XCOFF/function-sections.ll
+++ llvm/test/DebugInfo/XCOFF/function-sections.ll
@@ -72,7 +72,7 @@
 ; CHECK-NEXT:  .byte   0x01# NumberOfFPParms = 0, +HasParmsOnStack
 ; CHECK-NEXT:  .vbyte  4, L..foo0-.foo[PR] # Function size
 ; CHECK-NEXT:  .vbyte  2, 0x0003   # Function name len = 3
-; CHECK-NEXT:  .byte   'f,'o,'o# Function Name
+; CHECK-NEXT:  .byte   "foo"   # Function Name
 ; CHECK-NEXT:  L..func_end0:
 ; CHECK-NEXT:  # -- End function
 ; CHECK-NEXT:  .csect .bar[PR],2
@@ -108,7 +108,7 @@
 ; CHECK-NEXT:  .byte   0x01# NumberOfFPParms = 0, +HasParmsOnStack
 ; CHECK-NEXT:  .vbyte  4, L..bar0-.bar[PR] # Function size
 ; CHECK-NEXT:  .vbyte  2, 0x0003   # Function name len = 3
-; CHECK-NEXT:  .byte   'b,'a,'r# Function Name
+; CHECK-NEXT:  .byte   "bar"   # Function Name
 ; CHECK-NEXT:  L..func_end1:
 ; CHECK-NEXT:  # -- End function
 ; CHECK-NEXT:  L..sec_end0:
@@ -258,10 +258,10 @@
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   1
-; CHECK-NEXT:  .byte   'd,'e,'b,'u,'g
+; CHECK-NEXT:  .byte   "debug"
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   0
-; CHECK-NEXT:  .byte   '1,'.,'c
+; CHECK-NEXT:  .byte   "1.c"
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   1
 ; CHECK-NEXT:  .byte   0
Index: llvm/test/DebugInfo/XCOFF/explicit-section.ll
===
--- llvm/test/DebugInfo/XCOFF/explicit-section.ll
+++ llvm/test/DebugInfo/XCOFF/explicit-section.ll
@@ -77,7 +77,7 @@
 ; CHECK-NEXT:  .byte   0x01# NumberOfFPParms = 0, +HasParmsOnStack
 ; CHECK-NEXT:  .vbyte  4, L..bar0-.bar # Function size
 ; CHECK-NEXT:  .vbyte  2, 0x0003   # Function name len = 3
-; CHECK-NEXT:  .byte   'b,'a,'r# Function Name
+; CHECK-NEXT:  .byte   "bar"   # Function Name
 ; CHECK-NEXT:  L..func_end0:
 ; CHECK-NEXT:  # -- End function
 ; CHECK-NEXT:  .csect explicit_main_sec[PR],2
@@ -125,7 +125,7 @@
 ; CHECK-NEXT:  .byte   0x01# NumberOfFPParms = 0, +HasParmsOnStack
 ; CHECK-NEXT:  .vbyte  4, L..main0-.main   # Function size
 ; CHECK-NEXT:  .vbyte  2, 0x0004   # Function name len = 4
-; CHECK-NEXT:  .byte   'm,'a,'i,'n # Function Name
+; CHECK-NEXT:  .byte   "main"  # Function Name
 ; CHECK-NEXT:  L..func_end1:
 ; CHECK-NEXT:  # -- End function
 ; CHECK-NEXT:  L..sec_end0:
@@ -271,10 +271,10 @@
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   1
-; CHECK-NEXT:  .byte   'd,'e,'b,'u,'g
+; CHECK-NEXT:  .byte   "debug"
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   0
-; CHECK-NEXT:  .byte   '2,'.,'c
+; CHECK-NEXT:  .byte   "2.c"
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   1
 ; CHECK-NEXT:  .byte   0
Index: llvm/test/DebugInfo/XCOFF/empty.ll
===
--- llvm/test/DebugInfo/XCOFF/empty.ll
+++ llvm/test/DebugInfo/XCOFF/empty.ll
@@ -71,7 +71,7 @@
 ; ASM32-NEXT:  .byte   0x01# NumberOfFPParms = 0, +HasParmsOnStack
 ; ASM32-NEXT:  .vbyte  4, L..main0-.main   # Function size
 ; ASM32-NEXT:  .vbyte  2, 0x0004   # Function name len = 4

[PATCH] D102814: [AIX] Print printable byte list as quoted string

2021-05-19 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: llvm/lib/MC/MCAsmStreamer.cpp:1007-1008
+static inline bool isPrintableString(StringRef Data) {
+  const auto BeginPtr = Data.begin(), EndPtr = Data.end();
+  for (const unsigned char C : make_range(BeginPtr, EndPtr)) {
+if (!isPrint(C))

If going through the whole string, going through `make_range` is not needed.



Comment at: llvm/lib/MC/MCAsmStreamer.cpp:1009
+  for (const unsigned char C : make_range(BeginPtr, EndPtr)) {
+if (!isPrint(C))
+  return false;

`isPrint` returns true for `"`, which does require escaping.



Comment at: llvm/lib/MC/MCAsmStreamer.cpp:1048-1051
   case MCAsmInfo::ACLS_SingleQuotePrefix:
-printCharacterList(printOneCharacterFor([](char C) {
-  const char AsmCharLitBuf[2] = {'\'', C};
-  OS << StringRef(AsmCharLitBuf, sizeof(AsmCharLitBuf));
-}));
+// If the whole string can be printed, print it directly.
+if (isPrintableString(Data))
+  OS << '"' << Data << '"';

This breaks the abstraction. That a "byte-list" directive accepting a list of 
elements where there are single-quote-prefixed character literals is available 
does not mean that the same directive accepts a string argument.

Note: `PrintQuotedString` does print more general strings on AIX (that do not 
contain a newline); however, I do not believe it to be desirable to emit 
control characters and the such "raw".



Comment at: llvm/lib/MC/MCAsmStreamer.cpp:1123-1126
 if (MAI->getAscizDirective() && Data.back() == 0) {
   OS << MAI->getAscizDirective();
   Data = Data.substr(0, Data.size() - 1);
 } else if (LLVM_LIKELY(MAI->getAsciiDirective())) {

Here may be a nice point to add a condition that 
`hasPairedDoubleQuoteStringConstants` means we check `isPrintableString` before 
deciding to use AIX `.string` for `.asciz` and AIX `.byte` for `.ascii`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102814/new/

https://reviews.llvm.org/D102814

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102814: [AIX] Print printable byte list as quoted string

2021-05-19 Thread Jinsong Ji via Phabricator via cfe-commits
jsji created this revision.
jsji added reviewers: PowerPC, hubert.reinterpretcast, DiggerLin, xingxue, 
shchenz.
Herald added subscribers: hiraditya, nemanjai.
jsji requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

.byte supports string, so if the whole byte list are printable,
we can actually print the string for readability and LIT tests maintainence.

  .byte 'H,'e,'l,'l,'o,',,' ,'w,'o,'r,'l,'d

->

  .byte "Hello, world"


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102814

Files:
  clang/test/CodeGenCXX/debug-info-byval.cpp
  llvm/lib/MC/MCAsmStreamer.cpp
  llvm/test/CodeGen/PowerPC/aix-emit-tracebacktable-clobber-register.ll
  llvm/test/CodeGen/PowerPC/aix-emit-tracebacktable.ll
  llvm/test/CodeGen/PowerPC/aix-exception.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-data.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-rodata.ll
  llvm/test/DebugInfo/XCOFF/empty.ll
  llvm/test/DebugInfo/XCOFF/explicit-section.ll
  llvm/test/DebugInfo/XCOFF/function-sections.ll

Index: llvm/test/DebugInfo/XCOFF/function-sections.ll
===
--- llvm/test/DebugInfo/XCOFF/function-sections.ll
+++ llvm/test/DebugInfo/XCOFF/function-sections.ll
@@ -72,7 +72,7 @@
 ; CHECK-NEXT:  .byte   0x01# NumberOfFPParms = 0, +HasParmsOnStack
 ; CHECK-NEXT:  .vbyte  4, L..foo0-.foo[PR] # Function size
 ; CHECK-NEXT:  .vbyte  2, 0x0003   # Function name len = 3
-; CHECK-NEXT:  .byte   'f,'o,'o# Function Name
+; CHECK-NEXT:  .byte   "foo"   # Function Name
 ; CHECK-NEXT:  L..func_end0:
 ; CHECK-NEXT:  # -- End function
 ; CHECK-NEXT:  .csect .bar[PR],2
@@ -108,7 +108,7 @@
 ; CHECK-NEXT:  .byte   0x01# NumberOfFPParms = 0, +HasParmsOnStack
 ; CHECK-NEXT:  .vbyte  4, L..bar0-.bar[PR] # Function size
 ; CHECK-NEXT:  .vbyte  2, 0x0003   # Function name len = 3
-; CHECK-NEXT:  .byte   'b,'a,'r# Function Name
+; CHECK-NEXT:  .byte   "bar"   # Function Name
 ; CHECK-NEXT:  L..func_end1:
 ; CHECK-NEXT:  # -- End function
 ; CHECK-NEXT:  L..sec_end0:
@@ -258,10 +258,10 @@
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   1
-; CHECK-NEXT:  .byte   'd,'e,'b,'u,'g
+; CHECK-NEXT:  .byte   "debug"
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   0
-; CHECK-NEXT:  .byte   '1,'.,'c
+; CHECK-NEXT:  .byte   "1.c"
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   1
 ; CHECK-NEXT:  .byte   0
Index: llvm/test/DebugInfo/XCOFF/explicit-section.ll
===
--- llvm/test/DebugInfo/XCOFF/explicit-section.ll
+++ llvm/test/DebugInfo/XCOFF/explicit-section.ll
@@ -77,7 +77,7 @@
 ; CHECK-NEXT:  .byte   0x01# NumberOfFPParms = 0, +HasParmsOnStack
 ; CHECK-NEXT:  .vbyte  4, L..bar0-.bar # Function size
 ; CHECK-NEXT:  .vbyte  2, 0x0003   # Function name len = 3
-; CHECK-NEXT:  .byte   'b,'a,'r# Function Name
+; CHECK-NEXT:  .byte   "bar"   # Function Name
 ; CHECK-NEXT:  L..func_end0:
 ; CHECK-NEXT:  # -- End function
 ; CHECK-NEXT:  .csect explicit_main_sec[PR],2
@@ -125,7 +125,7 @@
 ; CHECK-NEXT:  .byte   0x01# NumberOfFPParms = 0, +HasParmsOnStack
 ; CHECK-NEXT:  .vbyte  4, L..main0-.main   # Function size
 ; CHECK-NEXT:  .vbyte  2, 0x0004   # Function name len = 4
-; CHECK-NEXT:  .byte   'm,'a,'i,'n # Function Name
+; CHECK-NEXT:  .byte   "main"  # Function Name
 ; CHECK-NEXT:  L..func_end1:
 ; CHECK-NEXT:  # -- End function
 ; CHECK-NEXT:  L..sec_end0:
@@ -271,10 +271,10 @@
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   1
-; CHECK-NEXT:  .byte   'd,'e,'b,'u,'g
+; CHECK-NEXT:  .byte   "debug"
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   0
-; CHECK-NEXT:  .byte   '2,'.,'c
+; CHECK-NEXT:  .byte   "2.c"
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   1
 ; CHECK-NEXT:  .byte   0
Index: llvm/test/DebugInfo/XCOFF/empty.ll
===
--- llvm/test/DebugInfo/XCOFF/empty.ll
+++ llvm/test/DebugInfo/XCOFF/empty.ll
@@