Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp =================================================================== --- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -704,6 +704,11 @@ if (isVerbose()) { F.printAsOperand(OutStreamer->GetCommentOS(), /*PrintType=*/false, F.getParent()); + MDNode *OutlinedMetaData = F.getMetadata("outlined.kind"); + if (OutlinedMetaData) + if (MDString *OutlinedMetaString = + dyn_cast(OutlinedMetaData->getOperand(0))) + OutStreamer->GetCommentOS() << ' ' << OutlinedMetaString->getString(); OutStreamer->GetCommentOS() << '\n'; } Index: llvm/lib/Target/AArch64/AArch64InstrInfo.cpp =================================================================== --- llvm/lib/Target/AArch64/AArch64InstrInfo.cpp +++ llvm/lib/Target/AArch64/AArch64InstrInfo.cpp @@ -6375,6 +6375,9 @@ const outliner::OutlinedFunction &OF) const { // For thunk outlining, rewrite the last instruction from a call to a // tail-call. + + std::string OutlinerString = "Function"; + if (OF.FrameConstructionID == MachineOutlinerThunk) { MachineInstr *Call = &*--MBB.instr_end(); unsigned TailOpcode; @@ -6389,7 +6392,10 @@ .addImm(0); MBB.insert(MBB.end(), TC); Call->eraseFromParent(); - } + + OutlinerString = "Thunk"; + } else if (OF.FrameConstructionID == MachineOutlinerTailCall) + OutlinerString = "Tail Call"; bool IsLeafFunction = true; @@ -6478,6 +6484,11 @@ ShouldSignReturnAddrWithAKey = Key.equals_lower("a_key"); } + Function *F = CF.getParent()->getFunction(MF.getName()); + MDNode *N = MDNode::get(F->getContext(), + MDString::get(F->getContext(), OutlinerString)); + F->addMetadata("outlined.kind", *N); + // If this is a tail call outlined function, then there's already a return. if (OF.FrameConstructionID == MachineOutlinerTailCall || OF.FrameConstructionID == MachineOutlinerThunk) { Index: llvm/test/CodeGen/AArch64/machine-outliner-function-annotate.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/AArch64/machine-outliner-function-annotate.ll @@ -0,0 +1,30 @@ +; RUN: llc -verify-machineinstrs -enable-machine-outliner -mtriple=aarch64-linux-gnu < %s | FileCheck %s + +; Check that a non tail called or thunk function is annotated properly with +; only "Function" + +; CHECK-LABEL: OUTLINED_FUNCTION_0: +; CHECK-SAME: // @OUTLINED_FUNCTION_0 Function +; CHECK: mov w0, #1 +; CHECK-NEXT: mov w1, #2 +; CHECK-NEXT: mov w2, #3 +; CHECK-NEXT: mov w3, #4 +; CHECK-NEXT: ret + +define void @a() { +entry: + call void @z(i32 1, i32 2, i32 3, i32 4) + %0= alloca i32, align 4 + store i32 2, i32* %0, align 4 + ret void +} + +declare void @z(i32, i32, i32, i32) + +define dso_local void @b(i32* nocapture readnone %p) { +entry: + call void @z(i32 1, i32 2, i32 3, i32 4) + %0 = alloca i32, align 4 + store i32 1, i32* %0, align 4 + ret void +} \ No newline at end of file Index: llvm/test/CodeGen/AArch64/machine-outliner-tail.ll =================================================================== --- llvm/test/CodeGen/AArch64/machine-outliner-tail.ll +++ llvm/test/CodeGen/AArch64/machine-outliner-tail.ll @@ -1,6 +1,7 @@ ; RUN: llc -verify-machineinstrs -enable-machine-outliner -mtriple=aarch64-linux-gnu < %s | FileCheck %s -; CHECK: OUTLINED_FUNCTION_0: +; CHECK-LABEL: OUTLINED_FUNCTION_0: +; CHECK-SAME: // @OUTLINED_FUNCTION_0 Tail Call ; CHECK: mov w0, #1 ; CHECK-NEXT: mov w1, #2 ; CHECK-NEXT: mov w2, #3 Index: llvm/test/CodeGen/AArch64/machine-outliner-thunk.ll =================================================================== --- llvm/test/CodeGen/AArch64/machine-outliner-thunk.ll +++ llvm/test/CodeGen/AArch64/machine-outliner-thunk.ll @@ -71,6 +71,7 @@ } ; CHECK: [[OUTLINED_INDIRECT]]: +; CHECK-SAME: // @[[OUTLINED_INDIRECT]] Thunk ; CHECK: // %bb.0: ; CHECK-NEXT: mov x8, x0 ; CHECK-NEXT: mov w0, #1 @@ -80,6 +81,7 @@ ; CHECK-NEXT: br x8 ; CHECK: [[OUTLINED_DIRECT]]: +; CHECK-SAME: // @[[OUTLINED_DIRECT]] Thunk ; CHECK: // %bb.0: ; CHECK-NEXT: mov w0, #1 ; CHECK-NEXT: mov w1, #2