[PATCH] D120078: Insert MIRProfile into LLD
Roger Kim via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 17 11:35:19 PST 2022
Roger created this revision.
Herald added subscribers: ormris, steven_wu, hiraditya.
Roger requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D120078
Files:
clang/test/Pika/MIP/mip-stat-debug-info.c
llvm/lib/LTO/LTO.cpp
Index: llvm/lib/LTO/LTO.cpp
===================================================================
--- llvm/lib/LTO/LTO.cpp
+++ llvm/lib/LTO/LTO.cpp
@@ -52,6 +52,7 @@
#include "llvm/Transforms/Utils/FunctionImportUtils.h"
#include "llvm/Transforms/Utils/SplitModule.h"
#ifdef __FACEBOOK__
+#include "pika/CodeGen/MIRProfileSummary.h"
#include "pika/Transforms/IPO/IVarDirectAccess.h"
#endif // __FACEBOOK__
@@ -977,10 +978,19 @@
return StatsFileOrErr.takeError();
std::unique_ptr<ToolOutputFile> StatsFile = std::move(StatsFileOrErr.get());
+#ifdef __FACEBOOK__
+ MIRProfileSummary::parseProfile();
+#endif
+
Error Result = runRegularLTO(AddStream);
if (!Result)
Result = runThinLTO(AddStream, Cache, GUIDPreservedSymbols);
+#ifdef __FACEBOOK__
+ std::vector<std::string> temp;
+ MIRProfileSummary::publishFinalOrderedSymbols(temp);
+#endif
+
if (StatsFile)
PrintStatisticsJSON(StatsFile->os());
Index: clang/test/Pika/MIP/mip-stat-debug-info.c
===================================================================
--- clang/test/Pika/MIP/mip-stat-debug-info.c
+++ clang/test/Pika/MIP/mip-stat-debug-info.c
@@ -1,11 +1,28 @@
// REQUIRES: system-darwin && native && asserts
// RUN: llvm-odrcov yaml2mip %p/Inputs/mip-stat-debug-info-x86.yaml -p %t.mip
// RUN: %clang -isysroot %macos_sdk_root -g -target x86_64-apple-macosx -flto -c -o %t.o %s
-// RUN: %clang -isysroot %macos_sdk_root -g -target x86_64-apple-macosx -Wl,-mllvm,-odrcov-use=%t.mip -Wl,-mllvm,-debug-only=mip-stat -o %t %t.o 2>/dev/stdout >/dev/null | FileCheck %s
+// RUN: %clang -isysroot %macos_sdk_root -g -target x86_64-apple-macosx -Wl,-mllvm,-odrcov-use=%t.mip -Wl,-mllvm,-debug-only=mip-stat -o %t-ld64.out %t.o 2>%t/logs-ld64 >/dev/null
+// RUN: FileCheck %s < %t/logs-ld64
+// RUN: llvm-objdump --section=__text -D %t-ld64.out | FileCheck --check-prefix OUTPUT-ORDER %s
+// RUN: %clang -fuse-ld=lld.darwinnew -isysroot %macos_sdk_root -g -target x86_64-apple-macosx -Wl,-mllvm,-odrcov-use=%t.mip -Wl,-mllvm,-debug-only=mip-stat -o %t-lld.out %t.o 2>%t/logs-lld >/dev/null
+// RUN: llvm-objdump --section=__text -D %t-lld.out | FileCheck --check-prefix OUTPUT-ORDER %s
+
+// # ld64 and lld should be running the same code for MIRProfile logic so the
+// # output should be exactly the same.
+// RUN: diff %t/logs-ld64 %t/logs-lld
// RUN: llvm-odrcov yaml2mip %p/Inputs/mip-stat-debug-info-arm64.yaml -p %t-arm64.mip
// RUN: %clang -isysroot %macos_sdk_root -g -target arm64-macosx -flto -c -o %t.o %s
-// RUN: %clang -isysroot %macos_sdk_root -g -target arm64-macosx -Wl,-mllvm,-odrcov-use=%t-arm64.mip -Wl,-mllvm,-debug-only=mip-stat -o %t %t.o 2>/dev/stdout >/dev/null | FileCheck --check-prefix CHECK-ARM64 %s
+// RUN: %clang -isysroot %macos_sdk_root -g -target arm64-macosx -Wl,-mllvm,-odrcov-use=%t-arm64.mip -Wl,-mllvm,-debug-only=mip-stat -o %t-arm64-ld64.out %t.o 2>%t/logs-arm64-ld64 >/dev/null
+// RUN: FileCheck --check-prefix CHECK-ARM64 %s < %t/logs-arm64-ld64
+// RUN: llvm-objdump --section=__text -D %t-arm64-ld64.out | FileCheck --check-prefix OUTPUT-ORDER %s
+// RUN: %clang -fuse-ld=lld.darwinnew -isysroot %macos_sdk_root -g -target arm64-macosx -Wl,-mllvm,-odrcov-use=%t-arm64.mip -Wl,-mllvm,-debug-only=mip-stat -o %t-arm64-lld.out %t.o 2>%t/logs-arm64-lld >/dev/null
+// RUN: FileCheck --check-prefix CHECK-ARM64 %s < %t/logs-arm64-lld
+// RUN: llvm-objdump --section=__text -D %t-arm64-lld.out | FileCheck --check-prefix OUTPUT-ORDER %s
+
+// # ld64 and lld should be running the same code for MIRProfile logic so the
+// # output should be exactly the same.
+// RUN: diff %t/logs-arm64-ld64 %t/logs-arm64-lld
// CHECK: [OdrCov] Parsed profile [[MIP_PATH:.+\.mip]]
// CHECK-NEXT: [MachineIRProfileStat] Start
@@ -33,6 +50,12 @@
// CHECK-ARM64-NEXT: [MachineIRProfileStat] f3: 24
// CHECK-ARM64-NEXT: [MachineIRProfileStat] main: 56
+// OUTPUT-ORDER: Disassembly of section __TEXT,__text:
+// OUTPUT-ORDER: <_f1>:
+// OUTPUT-ORDER: <_f2>:
+// OUTPUT-ORDER: <_f3>:
+// OUTPUT-ORDER: <_f5>:
+
#include <stdio.h>
// Hot function
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120078.409735.patch
Type: text/x-patch
Size: 4093 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220217/0a001334/attachment.bin>
More information about the llvm-commits
mailing list