[PATCH] D34997: Keep metadata when changing Invoke instructions to Call ones

Yevgeny Rouban via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 5 21:19:53 PDT 2017


yrouban updated this revision to Diff 105370.
yrouban added a comment.

Added a new test.


https://reviews.llvm.org/D34997

Files:
  lib/Transforms/Utils/Local.cpp
  test/Transforms/SimplifyCFG/invoke_unwind.ll


Index: test/Transforms/SimplifyCFG/invoke_unwind.ll
===================================================================
--- test/Transforms/SimplifyCFG/invoke_unwind.ll
+++ test/Transforms/SimplifyCFG/invoke_unwind.ll
@@ -72,4 +72,21 @@
   br label %rethrow
 }
 
+declare i32 @test4_dummy_callee()
+
+; This testcase checks to see if the simplifycfg pass converting invoke
+; instructions preserves metadata.
+define i32 @test4() personality i32 (...)* @__gxx_personality_v0 {
+; CHECK-LABEL: @test4(
+; CHECK-NEXT: call i32 @test4_dummy_callee(), !range !0, !test4_metadata !1
+; CHECK-NEXT: ret i32 %result
+        %result = invoke i32 @test4_dummy_callee( )
+                        to label %1 unwind label %Rethrow, !range !{i32 1, i32 10}, !test4_metadata !{i32 -1}
+        ret i32 %result
+Rethrow:
+        %exn = landingpad {i8*, i32}
+                 catch i8* null
+        resume { i8*, i32 } %exn
+}
+
 declare i32 @__gxx_personality_v0(...)
Index: lib/Transforms/Utils/Local.cpp
===================================================================
--- lib/Transforms/Utils/Local.cpp
+++ lib/Transforms/Utils/Local.cpp
@@ -1431,6 +1431,7 @@
   NewCall->setCallingConv(II->getCallingConv());
   NewCall->setAttributes(II->getAttributes());
   NewCall->setDebugLoc(II->getDebugLoc());
+  NewCall->copyMetadata(*II);
   II->replaceAllUsesWith(NewCall);
 
   // Follow the call by a branch to the normal destination.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34997.105370.patch
Type: text/x-patch
Size: 1428 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170706/133a5074/attachment.bin>


More information about the llvm-commits mailing list