Skip to contentSkip to conversation

perf llvm: Specify features="+all" for aarch64

PATCH Applied Peter Collingbourne 4 participants 4 messages Mar 3 – Mar 5 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf llvm: Specify features="+all" for aarch64

This is consistent with what llvm-objdump does (see [1]) and allows the LLVM disassembler to disassemble instructions not in the base instruction set.

[1] https://reviews.llvm.org/D127741

---
 tools/perf/util/llvm.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
tools/perf/util/llvm.c +8 -2
index 87fceae8488a7..44eff99970fe2 100644
@@ -153,11 +153,17 @@ int symbol__disassemble_llvm(const char *filename, struct symbol *sym,
 					  /*get_op_info=*/NULL, symbol_lookup_callback);
 	} else {
 		char triplet[64];
+		const char *features = NULL;
 
 		scnprintf(triplet, sizeof(triplet), "%s-linux-gnu",
 			  args->arch->name);
-		disasm = LLVMCreateDisasm(triplet, &storage, /*tag_type=*/0,
-					  /*get_op_info=*/NULL, symbol_lookup_callback);
+		if (args->arch->id.e_machine == EM_AARCH64)
+			features = "+all";
+		disasm = LLVMCreateDisasmCPUFeatures(triplet, /*cpu=*/"",
+						     features, &storage,
+						     /*tag_type=*/0,
+						     /*get_op_info=*/NULL,
+						     symbol_lookup_callback);
 	}
 
 	if (disasm == NULL)
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Peter Collingbourne

This is consistent with what llvm-objdump does (see [1]) and allows the LLVM disassembler to disassemble instructions not in the base instruction set.

[1] https://reviews.llvm.org/D127741

Thanks,
Ian

Quoted 31 lines
---
 tools/perf/util/llvm.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
tools/perf/util/llvm.c +8 -3
index 87fceae8488a7..44eff99970fe2 100644
@@ -153,11 +153,17 @@ int symbol__disassemble_llvm(const char *filename, struct symbol *sym,
                                          /*get_op_info=*/NULL, symbol_lookup_callback);
        } else {
                char triplet[64];
+               const char *features = NULL;
 
                scnprintf(triplet, sizeof(triplet), "%s-linux-gnu",
                          args->arch->name);
-               disasm = LLVMCreateDisasm(triplet, &storage, /*tag_type=*/0,
-                                         /*get_op_info=*/NULL, symbol_lookup_callback);
+               if (args->arch->id.e_machine == EM_AARCH64)
+                       features = "+all";
+               disasm = LLVMCreateDisasmCPUFeatures(triplet, /*cpu=*/"",
+                                                    features, &storage,
+                                                    /*tag_type=*/0,
+                                                    /*get_op_info=*/NULL,
+                                                    symbol_lookup_callback);
        }
 
        if (disasm == NULL)
--

2.53.0.473.g4a7958ca14-goog

maintainer Acked-by
#2 lore raw
Quoted 6 lines · Ian Rogers
Quoted 5 lines · Peter Collingbourne

This is consistent with what llvm-objdump does (see [1]) and allows the LLVM disassembler to disassemble instructions not in the base instruction set.

Quoted 6 lines
Quoted 4 lines

[1] https://reviews.llvm.org/D127741

Namhyung, this should go to 7.1 (perf-tools-next),

Regards,

- Arnaldo