Index: llvm/include/llvm/MC/MCAsmInfo.h =================================================================== --- llvm/include/llvm/MC/MCAsmInfo.h +++ llvm/include/llvm/MC/MCAsmInfo.h @@ -126,6 +126,10 @@ /// "#" StringRef CommentString; + /// This indicates whether the comment character is only accepted as a comment + /// at the beginning of statements. Defaults to false. + bool RestrictCommentString = false; + /// This is appended to emitted labels. Defaults to ":" const char *LabelSuffix; @@ -549,6 +553,7 @@ unsigned getCommentColumn() const { return 40; } StringRef getCommentString() const { return CommentString; } + bool getRestrictCommentString() const { return RestrictCommentString; } const char *getLabelSuffix() const { return LabelSuffix; } bool useAssignmentForEHBegin() const { return UseAssignmentForEHBegin; } Index: llvm/lib/MC/MCParser/AsmLexer.cpp =================================================================== --- llvm/lib/MC/MCParser/AsmLexer.cpp +++ llvm/lib/MC/MCParser/AsmLexer.cpp @@ -660,9 +660,11 @@ bool AsmLexer::isAtStartOfComment(const char *Ptr) { StringRef CommentString = MAI.getCommentString(); + bool RestrictCommentString = MAI.getRestrictCommentString(); if (CommentString.size() == 1) - return CommentString[0] == Ptr[0]; + return CommentString[0] == Ptr[0] && + (!RestrictCommentString || IsAtStartOfStatement); // Allow # preprocessor commments also be counted as comments for "##" cases if (CommentString[1] == '#') Index: llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp =================================================================== --- llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp +++ llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp @@ -23,7 +23,8 @@ MaxInstLength = 6; - CommentString = "#"; + CommentString = AssemblerDialect == AD_HLASM ? "*" : "#"; + RestrictCommentString = (AssemblerDialect == AD_HLASM); ZeroDirective = "\t.space\t"; Data64bitsDirective = "\t.quad\t"; UsesELFSectionDirectiveForBSS = true;