-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[gold] Enable MCTargetOptions::AsmVerbose
along with emit-asm
#71606
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
[gold] Enable MCTargetOptions::AsmVerbose
along with emit-asm
#71606
Conversation
@llvm/pr-subscribers-lto Author: Min-Yih Hsu (mshockwave) ChangesUse Full diff: https://github.com/llvm/llvm-project/pull/71606.diff 2 Files Affected:
diff --git a/llvm/test/tools/gold/X86/asm-verbose.ll b/llvm/test/tools/gold/X86/asm-verbose.ll
new file mode 100644
index 000000000000000..252d5b3a076d613
--- /dev/null
+++ b/llvm/test/tools/gold/X86/asm-verbose.ll
@@ -0,0 +1,15 @@
+; RUN: llvm-as -o %t.bc %s
+; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext -plugin-opt=emit-asm \
+; RUN: -plugin-opt=asm-verbose \
+; RUN: -m elf_x86_64 -r -o %t.s %t.bc
+; RUN: FileCheck --input-file=%t.s %s
+
+; Check if comments are emitted into assembly.
+; CHECK: -- End function
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @foo() {
+ ret i32 10
+}
diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp
index d9e5983a4bacd63..bc4514990fa8f20 100644
--- a/llvm/tools/gold/gold-plugin.cpp
+++ b/llvm/tools/gold/gold-plugin.cpp
@@ -152,6 +152,7 @@ namespace options {
static std::string extra_library_path;
static std::string triple;
static std::string mcpu;
+ static bool asm_verbose = false;
// When the thinlto plugin option is specified, only read the function
// the information from intermediate files and write a combined
// global index for the ThinLTO backends.
@@ -308,6 +309,8 @@ namespace options {
RemarksFormat = std::string(opt);
} else if (opt.consume_front("stats-file=")) {
stats_file = std::string(opt);
+ } else if (opt == "asm-verbose") {
+ asm_verbose = true;
} else {
// Save this option to pass to the code generator.
// ParseCommandLineOptions() expects argv[0] to be program name. Lazily
@@ -950,6 +953,9 @@ static std::unique_ptr<LTO> createLTO(IndexWriteCallback OnIndexWrite,
Conf.HasWholeProgramVisibility = options::whole_program_visibility;
Conf.StatsFile = options::stats_file;
+
+ Conf.Options.MCOptions.AsmVerbose = options::asm_verbose;
+
return std::make_unique<LTO>(std::move(Conf), Backend,
options::ParallelCodeGenParallelismLevel);
}
|
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.
I see that lld enables this unconditionally:
Line 156 in 26ab444
c.Options.MCOptions.AsmVerbose = true; |
How about just make it unconditionally true to be consistent and avoid adding another plugin option?
In which case you can just modify https://github.com/llvm/llvm-project/blob/26ab444e88fc8fdd554e5a9381a68b7b5e63b6fd/llvm/test/tools/gold/X86/emit-asm.ll slightly to check that the comments are emitted. |
Yes I think this is a good idea. I've updated the PR. |
-plugin-opt
to enable MCTargetOptions::AsmVerbose
MCTargetOptions::AsmVerbose
along with emit-asm
…vm#71606) Print comments into assembly output if we're using `emit-asm`.
Print comments into assembly output if we're using
emit-asm
.