[PATCH] D81996: [IR] Don't copy profile metadata in createCallMatchingInvoke()
Hans Wennborg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 17 02:07:31 PDT 2020
hans created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.
looks good
The invoke instruction can have profile metadata with branch_weights, which does not make sense for a call instruction and will be rejected by the verifier.
https://reviews.llvm.org/D81996
Files:
llvm/lib/Transforms/Utils/Local.cpp
llvm/test/Transforms/SimplifyCFG/invoke_unwind.ll
Index: llvm/test/Transforms/SimplifyCFG/invoke_unwind.ll
===================================================================
--- llvm/test/Transforms/SimplifyCFG/invoke_unwind.ll
+++ llvm/test/Transforms/SimplifyCFG/invoke_unwind.ll
@@ -7,9 +7,10 @@
define i32 @test1() personality i32 (...)* @__gxx_personality_v0 {
; CHECK-LABEL: @test1(
; CHECK-NEXT: call void @bar()
+; CHECK-NOT: !prof
; CHECK-NEXT: ret i32 0
invoke void @bar( )
- to label %1 unwind label %Rethrow
+ to label %1 unwind label %Rethrow, !prof !0
ret i32 0
Rethrow:
%exn = landingpad {i8*, i32}
@@ -17,6 +18,8 @@
resume { i8*, i32 } %exn
}
+!0 = !{!"branch_weights", i32 369, i32 0}
+
define i32 @test2() personality i32 (...)* @__gxx_personality_v0 {
; CHECK-LABEL: @test2(
; CHECK-NEXT: call void @bar() [ "foo"(i32 100) ]
Index: llvm/lib/Transforms/Utils/Local.cpp
===================================================================
--- llvm/lib/Transforms/Utils/Local.cpp
+++ llvm/lib/Transforms/Utils/Local.cpp
@@ -1985,6 +1985,11 @@
NewCall->setAttributes(II->getAttributes());
NewCall->setDebugLoc(II->getDebugLoc());
NewCall->copyMetadata(*II);
+
+ // If the invoke had profile metadata, drop it.
+ if (NewCall->hasMetadata(LLVMContext::MD_prof))
+ NewCall->setMetadata(LLVMContext::MD_prof, nullptr);
+
return NewCall;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81996.271300.patch
Type: text/x-patch
Size: 1413 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200617/0a7f596f/attachment.bin>
More information about the llvm-commits
mailing list