[PATCH] D65531: [ArgPromo][Tests] Examples to show missing 'tail' marker removal

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 31 12:54:30 PDT 2019


jdoerfert created this revision.
jdoerfert added reviewers: vsk, dblaikie, davidxl, tejohnson, tstellar, echristo, chandlerc, efriedma, lebedev.ri.
Herald added a subscriber: bollu.
Herald added a project: LLVM.

Test cases for https://bugs.llvm.org/show_bug.cgi?id=42850

The tail marker is removed by ArgumentPromotion only if the promoted
argument is used by the call. This is not sufficient as shown by the
three functions baz, biz, and buz.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65531

Files:
  llvm/test/Transforms/ArgumentPromotion/tail.ll


Index: llvm/test/Transforms/ArgumentPromotion/tail.ll
===================================================================
--- llvm/test/Transforms/ArgumentPromotion/tail.ll
+++ llvm/test/Transforms/ArgumentPromotion/tail.ll
@@ -1,6 +1,9 @@
 ; RUN: opt %s -argpromotion -S -o - | FileCheck %s
 ; RUN: opt %s -passes=argpromotion -S -o - | FileCheck %s
-; PR14710
+; PR14710, and related problems (baz, biz, buz) where 'tail' needs to be
+; removed if we introduce allocas.
+
+; FIXME: If the function is norecurse 'tail' removal should not be necessary.
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 
@@ -9,7 +12,7 @@
 declare i8* @foo(%pair*)
 
 define internal void @bar(%pair* byval %Data) {
-; CHECK: define internal void @bar(i32 %Data.0, i32 %Data.1)
+; CHECK: define internal void @bar(i32 %{{.*}}, i32 %{{.*}})
 ; CHECK: %Data = alloca %pair
 ; CHECK-NOT: tail
 ; CHECK: call i8* @foo(%pair* %Data)
@@ -17,7 +20,51 @@
   ret void
 }
 
+define internal void @baz(%pair* byval %Data) {
+; CHECK: define internal void @baz(i32 %{{.*}}, i32 %{{.*}})
+; CHECK: %Data = alloca %pair
+; CHECK: %Data2 = getelementptr %pair, %pair* %Data
+; FIXME: This is broken right now, it should be CHECK-NOT!
+; CHECK: tail
+; CHECK: call i8* @foo(%pair* %Data2)
+  %Data2 = getelementptr %pair, %pair* %Data
+  tail call i8* @foo(%pair* %Data2)
+  ret void
+}
+
+ at a = global %pair* null, align 8
+declare void @unknown(%pair*)
+
+define internal void @biz(%pair* byval %Data) {
+; CHECK: define internal void @biz(i32 %{{.*}}, i32 %{{.*}})
+; CHECK: %Data = alloca %pair
+; CHECK: %Data2 = load %pair*, %pair** @a
+; FIXME: This is broken right now, it should be CHECK-NOT!
+; CHECK: tail
+; CHECK: call i8* @foo(%pair* %Data2)
+  call void @unknown(%pair* %Data)
+  %Data2 = load %pair*, %pair** @a
+  tail call i8* @foo(%pair* %Data2)
+  ret void
+}
+
+define internal void @buz(%pair* byval %Data) {
+; CHECK: define internal void @buz(i32 %{{.*}}, i32 %{{.*}})
+; CHECK: %Data = alloca %pair
+; CHECK: call i8* @foo(%pair* %Data)
+; FIXME: This is broken right now, it should be CHECK-NOT!
+; CHECK: tail
+; CHECK: call i8* @foo(%pair* %Data2)
+  %fr = call i8* @foo(%pair* %Data)
+  %Data2 = bitcast i8* %fr to %pair*
+  tail call i8* @foo(%pair* %Data2)
+  ret void
+}
+
 define void @zed(%pair* byval %Data) {
   call void @bar(%pair* byval %Data)
+  call void @baz(%pair* byval %Data)
+  call void @biz(%pair* byval %Data)
+  call void @buz(%pair* byval %Data)
   ret void
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65531.212643.patch
Type: text/x-patch
Size: 2491 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190731/01ef70e4/attachment.bin>


More information about the llvm-commits mailing list