[PATCH] D125249: [Inliner] Preserve !prof metadata when converting call to invoke.

Hongtao Yu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 9 11:24:20 PDT 2022


hoy created this revision.
Herald added subscribers: modimo, wenlei, hiraditya.
Herald added a project: All.
hoy requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Test Plan:


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125249

Files:
  llvm/lib/Transforms/Utils/Local.cpp
  llvm/test/Transforms/Inline/profile_meta_invoke.ll


Index: llvm/test/Transforms/Inline/profile_meta_invoke.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/Inline/profile_meta_invoke.ll
@@ -0,0 +1,30 @@
+; Make sure that profile metadata is preserved when cloning a call.
+; RUN: opt < %s -S -inline | FileCheck %s
+; RUN: opt < %s -S -passes='cgscc(inline)' | FileCheck %s
+
+declare i32 @__gxx_personality_v0(...)
+
+define void @callee(void ()* %func) {
+  call void %func(), !prof !0
+  ret void
+}
+
+define void @caller(void ()* %func) personality i32 (...)* @__gxx_personality_v0 {
+  invoke void @callee(void ()* %func)
+          to label %ret unwind label %lpad
+
+ret:
+  ret void
+
+lpad:
+  %exn = landingpad {i8*, i32}
+          cleanup
+  unreachable
+}
+
+!0 = !{!"VP", i32 0, i64 3457, i64 9191153033785521275, i64 2059, i64 -1069303473483922844, i64 1398}
+
+; CHECK-LABEL: @caller(
+; CHECK:  invoke void %func()
+; CHECK-NEXT: {{.*}} !prof ![[PROF:[0-9]+]]
+; CHECK: ![[PROF]] = !{!"VP", i32 0, i64 3457, i64 9191153033785521275, i64 2059, i64 -1069303473483922844, i64 1398}
Index: llvm/lib/Transforms/Utils/Local.cpp
===================================================================
--- llvm/lib/Transforms/Utils/Local.cpp
+++ llvm/lib/Transforms/Utils/Local.cpp
@@ -2233,6 +2233,7 @@
   II->setDebugLoc(CI->getDebugLoc());
   II->setCallingConv(CI->getCallingConv());
   II->setAttributes(CI->getAttributes());
+  II->setMetadata(LLVMContext::MD_prof, CI->getMetadata(LLVMContext::MD_prof));
 
   if (DTU)
     DTU->applyUpdates({{DominatorTree::Insert, BB, UnwindEdge}});


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125249.428136.patch
Type: text/x-patch
Size: 1608 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220509/d6f108f5/attachment.bin>


More information about the llvm-commits mailing list