David Blaikie 5a70dd1d82 [opaque pointer type] Add textual IR support for explicit type parameter to gep operator
Similar to gep (r230786) and load (r230794) changes.

Similar migration script can be used to update test cases, which
successfully migrated all of LLVM and Polly, but about 4 test cases
needed manually changes in Clang.

(this script will read the contents of stdin and massage it into stdout
- wrap it in the 'apply.sh' script shown in previous commits + xargs to
apply it over a large set of test cases)

import fileinput
import sys
import re

rep = re.compile(r"(getelementptr(?:\s+inbounds)?\s*\()((<\d*\s+x\s+)?([^@]*?)(|\s*addrspace\(\d+\))\s*\*(?(3)>)\s*)(?=$|%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|zeroinitializer|<|\[\[[a-zA-Z]|\{\{)", re.MULTILINE | re.DOTALL)

def conv(match):
  line = match.group(1)
  line += match.group(4)
  line += ", "
  line += match.group(2)
  return line

line = sys.stdin.read()
off = 0
for match in re.finditer(rep, line):
  sys.stdout.write(line[off:match.start()])
  sys.stdout.write(conv(match))
  off = match.end()
sys.stdout.write(line[off:])

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232184 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-13 18:20:45 +00:00

81 lines
3.3 KiB
LLVM

; RUN: opt -S -scalarrepl-ssa < %s | FileCheck %s
; rdar://10589171
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%struct.foo = type { i32, i32 }
@.str = private unnamed_addr constant [6 x i8] c"x=%d\0A\00", align 1
define i32 @main(i32 %argc, i8** nocapture %argv) nounwind uwtable {
entry:
%f = alloca %struct.foo, align 4
%x.i = getelementptr inbounds %struct.foo, %struct.foo* %f, i64 0, i32 0
store i32 1, i32* %x.i, align 4
%y.i = getelementptr inbounds %struct.foo, %struct.foo* %f, i64 0, i32 1
br label %while.cond.i
; CHECK: while.cond.i:
; CHECK-NEXT: %tmp = phi i32 [ 1, %entry ], [ %tmp2, %while.cond.backedge.i ]
; CHECK-NEXT: %pos.0.i = phi i32 [ 1, %entry ], [ %xtmp.i, %while.cond.backedge.i ]
; CHECK-NEXT: %left.0.i = phi i32 [ 1, %entry ], [ %dec.i, %while.cond.backedge.i ]
; CHECK-NOT: phi
while.cond.i: ; preds = %while.cond.backedge.i, %entry
%tmp = phi i32 [ 1, %entry ], [ %tmp2, %while.cond.backedge.i ]
%pos.0.i = phi i32 [ 1, %entry ], [ %xtmp.i, %while.cond.backedge.i ]
%left.0.i = phi i32 [ 1, %entry ], [ %dec.i, %while.cond.backedge.i ]
%cmp.i = icmp sgt i32 %left.0.i, 0
br i1 %cmp.i, label %while.body.i, label %while.cond.i.func.exit_crit_edge
while.cond.i.func.exit_crit_edge: ; preds = %while.cond.i
br label %func.exit
while.body.i: ; preds = %while.cond.i
%dec.i = add nsw i32 %left.0.i, -1
switch i32 1, label %while.body.i.func.exit_crit_edge [
i32 0, label %while.cond.backedge.i
i32 1, label %sw.bb.i
]
while.body.i.func.exit_crit_edge: ; preds = %while.body.i
br label %func.exit
sw.bb.i: ; preds = %while.body.i
%cmp2.i = icmp eq i32 %tmp, 1
br i1 %cmp2.i, label %if.then.i, label %if.end.i
if.then.i: ; preds = %sw.bb.i
store i32 %pos.0.i, i32* %x.i, align 4
br label %if.end.i
; CHECK: if.end.i:
; CHECK-NEXT: %tmp1 = phi i32 [ %pos.0.i, %if.then.i ], [ %tmp, %sw.bb.i ]
; CHECK-NOT: phi
if.end.i: ; preds = %if.then.i, %sw.bb.i
%tmp1 = phi i32 [ %pos.0.i, %if.then.i ], [ %tmp, %sw.bb.i ]
store i32 %tmp1, i32* %y.i, align 4
br label %while.cond.backedge.i
; CHECK: while.cond.backedge.i:
; CHECK-NEXT: %tmp2 = phi i32 [ %tmp1, %if.end.i ], [ %tmp, %while.body.i ]
; CHECK-NOT: phi
while.cond.backedge.i: ; preds = %if.end.i, %while.body.i
%tmp2 = phi i32 [ %tmp1, %if.end.i ], [ %tmp, %while.body.i ]
%xtmp.i = add i32 %pos.0.i, 1
br label %while.cond.i
; CHECK: func.exit:
; CHECK-NOT: load
; CHECK: %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %tmp) [[NUW:#[0-9]+]]
func.exit: ; preds = %while.body.i.func.exit_crit_edge, %while.cond.i.func.exit_crit_edge
%tmp3 = load i32, i32* %x.i, align 4
%call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %tmp3) nounwind
ret i32 0
}
declare i32 @printf(i8* nocapture, ...) nounwind
; CHECK: attributes #0 = { nounwind uwtable }
; CHECK: attributes [[NUW]] = { nounwind }