Skip to content

Commit

Permalink
[opaque pointer type] Add textual IR support for explicit type parame…
Browse files Browse the repository at this point in the history
…ter to load instruction

Essentially the same as the GEP change in r230786.

A similar migration script can be used to update test cases, though a few more
test case improvements/changes were required this time around: (r229269-r229278)

import fileinput
import sys
import re

pat = re.compile(r"((?:=|:|^)\s*load (?:atomic )?(?:volatile )?(.*?))(| addrspace\(\d+\) *)\*($| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$)")

for line in sys.stdin:
  sys.stdout.write(re.sub(pat, r"\1, \2\3*\4", line))

Reviewers: rafael, dexonsmith, grosser

Differential Revision: http://reviews.llvm.org/D7649

llvm-svn: 230794
  • Loading branch information
dwblaikie committed Feb 27, 2015
1 parent 83687fb commit a79ac14
Show file tree
Hide file tree
Showing 3,931 changed files with 29,317 additions and 29,293 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
10 changes: 9 additions & 1 deletion llvm/lib/AsmParser/LLParser.cpp
Expand Up @@ -5241,7 +5241,11 @@ int LLParser::ParseLoad(Instruction *&Inst, PerFunctionState &PFS) {
Lex.Lex();
}

if (ParseTypeAndValue(Val, Loc, PFS) ||
Type *Ty = nullptr;
LocTy ExplicitTypeLoc = Lex.getLoc();
if (ParseType(Ty) ||
ParseToken(lltok::comma, "expected comma after load's type") ||
ParseTypeAndValue(Val, Loc, PFS) ||
ParseScopeAndOrdering(isAtomic, Scope, Ordering) ||
ParseOptionalCommaAlign(Alignment, AteExtraComma))
return true;
Expand All @@ -5254,6 +5258,10 @@ int LLParser::ParseLoad(Instruction *&Inst, PerFunctionState &PFS) {
if (Ordering == Release || Ordering == AcquireRelease)
return Error(Loc, "atomic load cannot use Release ordering");

if (Ty != cast<PointerType>(Val->getType())->getElementType())
return Error(ExplicitTypeLoc,
"explicit pointee type doesn't match operand's pointee type");

Inst = new LoadInst(Val, "", isVolatile, Alignment, Ordering, Scope);
return AteExtraComma ? InstExtraComma : InstNormal;
}
Expand Down
6 changes: 5 additions & 1 deletion llvm/lib/IR/AsmWriter.cpp
Expand Up @@ -2898,10 +2898,14 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
Out << ", ";
TypePrinter.print(I.getType(), Out);
} else if (Operand) { // Print the normal way.
if (const GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(&I)) {
if (const auto *GEP = dyn_cast<GetElementPtrInst>(&I)) {
Out << ' ';
TypePrinter.print(GEP->getSourceElementType(), Out);
Out << ',';
} else if (const auto *LI = dyn_cast<LoadInst>(&I)) {
Out << ' ';
TypePrinter.print(LI->getType(), Out);
Out << ", ";
}

// PrintAllTypes - Instructions who have operands of all the same type
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/Analysis/BasicAA/2003-02-26-AccessSizeTest.ll
Expand Up @@ -5,15 +5,15 @@
; RUN: opt < %s -basicaa -gvn -instcombine -S | FileCheck %s

define i32 @test() {
; CHECK: %Y.DONOTREMOVE = load i32* %A
; CHECK: %Y.DONOTREMOVE = load i32, i32* %A
; CHECK: %Z = sub i32 0, %Y.DONOTREMOVE
%A = alloca i32
store i32 0, i32* %A
%X = load i32* %A
%X = load i32, i32* %A
%B = bitcast i32* %A to i8*
%C = getelementptr i8, i8* %B, i64 1
store i8 1, i8* %C ; Aliases %A
%Y.DONOTREMOVE = load i32* %A
%Y.DONOTREMOVE = load i32, i32* %A
%Z = sub i32 %X, %Y.DONOTREMOVE
ret i32 %Z
}
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Analysis/BasicAA/2003-04-22-GEPProblem.ll
Expand Up @@ -6,9 +6,9 @@ define i32 @test(i32 *%Ptr, i64 %V) {
; CHECK: sub i32 %X, %Y
%P2 = getelementptr i32, i32* %Ptr, i64 1
%P1 = getelementptr i32, i32* %Ptr, i64 %V
%X = load i32* %P1
%X = load i32, i32* %P1
store i32 5, i32* %P2
%Y = load i32* %P1
%Y = load i32, i32* %P1
%Z = sub i32 %X, %Y
ret i32 %Z
}
2 changes: 1 addition & 1 deletion llvm/test/Analysis/BasicAA/2003-05-21-GEP-Problem.ll
Expand Up @@ -7,7 +7,7 @@ define void @table_reindex(%struct..apr_table_t* %t.1) { ; No predecessors!

loopentry: ; preds = %0, %no_exit
%tmp.101 = getelementptr %struct..apr_table_t, %struct..apr_table_t* %t.1, i64 0, i32 0, i32 2
%tmp.11 = load i32* %tmp.101 ; <i32> [#uses=0]
%tmp.11 = load i32, i32* %tmp.101 ; <i32> [#uses=0]
br i1 false, label %no_exit, label %UnifiedExitNode

no_exit: ; preds = %loopentry
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/Analysis/BasicAA/2003-06-01-AliasCrash.ll
Expand Up @@ -2,10 +2,10 @@

define i32 @MTConcat([3 x i32]* %a.1) {
%tmp.961 = getelementptr [3 x i32], [3 x i32]* %a.1, i64 0, i64 4
%tmp.97 = load i32* %tmp.961
%tmp.97 = load i32, i32* %tmp.961
%tmp.119 = getelementptr [3 x i32], [3 x i32]* %a.1, i64 1, i64 0
%tmp.120 = load i32* %tmp.119
%tmp.120 = load i32, i32* %tmp.119
%tmp.1541 = getelementptr [3 x i32], [3 x i32]* %a.1, i64 0, i64 4
%tmp.155 = load i32* %tmp.1541
%tmp.155 = load i32, i32* %tmp.1541
ret i32 0
}
4 changes: 2 additions & 2 deletions llvm/test/Analysis/BasicAA/2003-09-19-LocalArgument.ll
Expand Up @@ -7,9 +7,9 @@

define i32 @test(i32* %P) {
%X = alloca i32
%V1 = load i32* %P
%V1 = load i32, i32* %P
store i32 0, i32* %X
%V2 = load i32* %P
%V2 = load i32, i32* %P
%Diff = sub i32 %V1, %V2
ret i32 %Diff
}
4 changes: 2 additions & 2 deletions llvm/test/Analysis/BasicAA/2006-03-03-BadArraySubscript.ll
Expand Up @@ -15,9 +15,9 @@ no_exit: ; preds = %no_exit, %entry
%tmp.6 = getelementptr [3 x [3 x i32]], [3 x [3 x i32]]* %X, i32 0, i32 0, i32 %i.0.0 ; <i32*> [#uses=1]
store i32 1, i32* %tmp.6
%tmp.8 = getelementptr [3 x [3 x i32]], [3 x [3 x i32]]* %X, i32 0, i32 0, i32 0 ; <i32*> [#uses=1]
%tmp.9 = load i32* %tmp.8 ; <i32> [#uses=1]
%tmp.9 = load i32, i32* %tmp.8 ; <i32> [#uses=1]
%tmp.11 = getelementptr [3 x [3 x i32]], [3 x [3 x i32]]* %X, i32 0, i32 1, i32 0 ; <i32*> [#uses=1]
%tmp.12 = load i32* %tmp.11 ; <i32> [#uses=1]
%tmp.12 = load i32, i32* %tmp.11 ; <i32> [#uses=1]
%tmp.13 = add i32 %tmp.12, %tmp.9 ; <i32> [#uses=1]
%inc = add i32 %i.0.0, 1 ; <i32> [#uses=2]
%tmp.2 = icmp slt i32 %inc, %N ; <i1> [#uses=1]
Expand Down
Expand Up @@ -23,12 +23,12 @@ target triple = "i686-apple-darwin8"
define i32 @test(%struct.closure_type* %tmp18169) {
%tmp18174 = getelementptr %struct.closure_type, %struct.closure_type* %tmp18169, i32 0, i32 4, i32 0, i32 0 ; <i32*> [#uses=2]
%tmp18269 = bitcast i32* %tmp18174 to %struct.STYLE* ; <%struct.STYLE*> [#uses=1]
%A = load i32* %tmp18174 ; <i32> [#uses=1]
%A = load i32, i32* %tmp18174 ; <i32> [#uses=1]

%tmp18272 = getelementptr %struct.STYLE, %struct.STYLE* %tmp18269, i32 0, i32 0, i32 0, i32 2 ; <i16*> [#uses=1]
store i16 123, i16* %tmp18272

%Q = load i32* %tmp18174 ; <i32> [#uses=1]
%Q = load i32, i32* %tmp18174 ; <i32> [#uses=1]
%Z = sub i32 %A, %Q ; <i32> [#uses=1]
ret i32 %Z
}
6 changes: 3 additions & 3 deletions llvm/test/Analysis/BasicAA/2007-08-05-GetOverloadedModRef.ll
Expand Up @@ -5,10 +5,10 @@ declare i16 @llvm.cttz.i16(i16, i1)

define i32 @test(i32* %P, i16* %Q) {
; CHECK: ret i32 0
%A = load i16* %Q ; <i16> [#uses=1]
%x = load i32* %P ; <i32> [#uses=1]
%A = load i16, i16* %Q ; <i16> [#uses=1]
%x = load i32, i32* %P ; <i32> [#uses=1]
%B = call i16 @llvm.cttz.i16( i16 %A, i1 true ) ; <i16> [#uses=1]
%y = load i32* %P ; <i32> [#uses=1]
%y = load i32, i32* %P ; <i32> [#uses=1]
store i16 %B, i16* %Q
%z = sub i32 %x, %y ; <i32> [#uses=1]
ret i32 %z
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Analysis/BasicAA/2007-10-24-ArgumentsGlobals.ll
Expand Up @@ -11,6 +11,6 @@ entry:
store i32 1, i32* getelementptr (%struct.B* @a, i32 0, i32 0, i32 0), align 8
%tmp4 = getelementptr %struct.A, %struct.A* %b, i32 0, i32 0 ;<i32*> [#uses=1]
store i32 0, i32* %tmp4, align 4
%tmp7 = load i32* getelementptr (%struct.B* @a, i32 0, i32 0, i32 0), align 8 ; <i32> [#uses=1]
%tmp7 = load i32, i32* getelementptr (%struct.B* @a, i32 0, i32 0, i32 0), align 8 ; <i32> [#uses=1]
ret i32 %tmp7
}
4 changes: 2 additions & 2 deletions llvm/test/Analysis/BasicAA/2007-11-05-SizeCrash.ll
Expand Up @@ -17,15 +17,15 @@ entry:
%tmp17 = getelementptr %struct.usb_hcd, %struct.usb_hcd* %hcd, i32 0, i32 2, i64 1
; <i64*> [#uses=1]
%tmp1718 = bitcast i64* %tmp17 to i32* ; <i32*> [#uses=1]
%tmp19 = load i32* %tmp1718, align 4 ; <i32> [#uses=0]
%tmp19 = load i32, i32* %tmp1718, align 4 ; <i32> [#uses=0]
br i1 false, label %cond_true34, label %done_okay

cond_true34: ; preds = %entry
%tmp631 = getelementptr %struct.usb_hcd, %struct.usb_hcd* %hcd, i32 0, i32 2, i64
2305843009213693950 ; <i64*> [#uses=1]
%tmp70 = bitcast i64* %tmp631 to %struct.device**

%tmp71 = load %struct.device** %tmp70, align 8
%tmp71 = load %struct.device*, %struct.device** %tmp70, align 8

ret i32 undef

Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Analysis/BasicAA/2007-12-08-OutOfBoundsCrash.ll
Expand Up @@ -14,7 +14,7 @@ target triple = "x86_64-unknown-linux-gnu"
define i32 @ehci_pci_setup(%struct.usb_hcd* %hcd) {
entry:
%tmp14 = getelementptr %struct.usb_hcd, %struct.usb_hcd* %hcd, i32 0, i32 0, i32 0 ; <%struct.device**> [#uses=1]
%tmp15 = load %struct.device** %tmp14, align 8 ; <%struct.device*> [#uses=0]
%tmp15 = load %struct.device*, %struct.device** %tmp14, align 8 ; <%struct.device*> [#uses=0]
br i1 false, label %bb25, label %return

bb25: ; preds = %entry
Expand All @@ -23,7 +23,7 @@ bb25: ; preds = %entry
cond_true: ; preds = %bb25
%tmp601 = getelementptr %struct.usb_hcd, %struct.usb_hcd* %hcd, i32 0, i32 1, i64 2305843009213693951 ; <i64*> [#uses=1]
%tmp67 = bitcast i64* %tmp601 to %struct.device** ; <%struct.device**> [#uses=1]
%tmp68 = load %struct.device** %tmp67, align 8 ; <%struct.device*> [#uses=0]
%tmp68 = load %struct.device*, %struct.device** %tmp67, align 8 ; <%struct.device*> [#uses=0]
ret i32 undef

return: ; preds = %bb25, %entry
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Analysis/BasicAA/2008-06-02-GEPTailCrash.ll
Expand Up @@ -10,6 +10,6 @@ target triple = "i686-pc-linux-gnu"
define void @test291() nounwind {
entry:
store i32 1138410269, i32* getelementptr ([5 x %struct.S291]* @a291, i32 0, i32 2, i32 1)
%tmp54 = load i32* bitcast (%struct.S291* getelementptr ([5 x %struct.S291]* @a291, i32 0, i32 2) to i32*), align 4 ; <i32> [#uses=0]
%tmp54 = load i32, i32* bitcast (%struct.S291* getelementptr ([5 x %struct.S291]* @a291, i32 0, i32 2) to i32*), align 4 ; <i32> [#uses=0]
unreachable
}
2 changes: 1 addition & 1 deletion llvm/test/Analysis/BasicAA/2008-11-23-NoaliasRet.ll
Expand Up @@ -9,6 +9,6 @@ define i32 @foo() {
%B = call i32* @_Znwj(i32 4)
store i32 1, i32* %A
store i32 2, i32* %B
%C = load i32* %A
%C = load i32, i32* %A
ret i32 %C
}
4 changes: 2 additions & 2 deletions llvm/test/Analysis/BasicAA/2009-03-04-GEPNoalias.ll
Expand Up @@ -3,12 +3,12 @@
declare noalias i32* @noalias()

define i32 @test(i32 %x) {
; CHECK: load i32* %a
; CHECK: load i32, i32* %a
%a = call i32* @noalias()
store i32 1, i32* %a
%b = getelementptr i32, i32* %a, i32 %x
store i32 2, i32* %b

%c = load i32* %a
%c = load i32, i32* %a
ret i32 %c
}
4 changes: 2 additions & 2 deletions llvm/test/Analysis/BasicAA/2009-10-13-AtomicModRef.ll
Expand Up @@ -5,9 +5,9 @@ define i8 @foo(i8* %ptr) {
%P = getelementptr i8, i8* %ptr, i32 0
%Q = getelementptr i8, i8* %ptr, i32 1
; CHECK: getelementptr
%X = load i8* %P
%X = load i8, i8* %P
%Y = atomicrmw add i8* %Q, i8 1 monotonic
%Z = load i8* %P
%Z = load i8, i8* %P
; CHECK-NOT: = load
%A = sub i8 %X, %Z
ret i8 %A
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Analysis/BasicAA/2009-10-13-GEP-BaseNoAlias.ll
Expand Up @@ -23,9 +23,9 @@ bb1:

bb2:
%P = phi i32* [ %b, %bb ], [ @Y, %bb1 ]
%tmp1 = load i32* @Z, align 4
%tmp1 = load i32, i32* @Z, align 4
store i32 123, i32* %P, align 4
%tmp2 = load i32* @Z, align 4
%tmp2 = load i32, i32* @Z, align 4
br label %return

return:
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Analysis/BasicAA/2010-09-15-GEP-SignedArithmetic.ll
Expand Up @@ -9,9 +9,9 @@ define i32 @test(i32* %tab, i32 %indvar) nounwind {
%tmp31 = mul i32 %indvar, -2
%tmp32 = add i32 %tmp31, 30
%t.5 = getelementptr i32, i32* %tab, i32 %tmp32
%loada = load i32* %tab
%loada = load i32, i32* %tab
store i32 0, i32* %t.5
%loadb = load i32* %tab
%loadb = load i32, i32* %tab
%rval = add i32 %loada, %loadb
ret i32 %rval
}
2 changes: 1 addition & 1 deletion llvm/test/Analysis/BasicAA/2014-03-18-Maxlookup-reached.ll
Expand Up @@ -30,7 +30,7 @@ define i32 @main() {
store i8 0, i8* %10
%11 = getelementptr inbounds i8, i8* %10, i32 -1
store i8 0, i8* %11
%12 = load i32* %1, align 4
%12 = load i32, i32* %1, align 4
ret i32 %12
; CHECK: ret i32 %12
}
4 changes: 2 additions & 2 deletions llvm/test/Analysis/BasicAA/aligned-overread.ll
Expand Up @@ -9,10 +9,10 @@ target triple = "x86_64-apple-macosx10.8.0"

define i32 @main() nounwind uwtable ssp {
entry:
%tmp = load i8* getelementptr inbounds ({ i8, i8, i8, i8, i8 }* @a, i64 0, i32 4), align 4
%tmp = load i8, i8* getelementptr inbounds ({ i8, i8, i8, i8, i8 }* @a, i64 0, i32 4), align 4
%tmp1 = or i8 %tmp, -128
store i8 %tmp1, i8* getelementptr inbounds ({ i8, i8, i8, i8, i8 }* @a, i64 0, i32 4), align 4
%tmp2 = load i64* bitcast ({ i8, i8, i8, i8, i8 }* @a to i64*), align 8
%tmp2 = load i64, i64* bitcast ({ i8, i8, i8, i8, i8 }* @a to i64*), align 8
store i8 11, i8* getelementptr inbounds ({ i8, i8, i8, i8, i8 }* @a, i64 0, i32 4), align 4
%tmp3 = trunc i64 %tmp2 to i32
ret i32 %tmp3
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Analysis/BasicAA/args-rets-allocas-loads.ll
Expand Up @@ -22,8 +22,8 @@ define void @caller_a(double* %arg_a0,
%noalias_ret_a0 = call double* @noalias_returner()
%noalias_ret_a1 = call double* @noalias_returner()

%loaded_a0 = load double** %indirect_a0
%loaded_a1 = load double** %indirect_a1
%loaded_a0 = load double*, double** %indirect_a0
%loaded_a1 = load double*, double** %indirect_a1

call void @callee(double* %escape_alloca_a0)
call void @callee(double* %escape_alloca_a1)
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Analysis/BasicAA/byval.ll
Expand Up @@ -10,7 +10,7 @@ define i32 @foo(%struct.x* byval %a) nounwind {
%tmp2 = getelementptr %struct.x, %struct.x* %a, i32 0, i32 0 ; <i32*> [#uses=2]
store i32 1, i32* %tmp2, align 4
store i32 2, i32* @g, align 4
%tmp4 = load i32* %tmp2, align 4 ; <i32> [#uses=1]
%tmp4 = load i32, i32* %tmp2, align 4 ; <i32> [#uses=1]
ret i32 %tmp4
}

Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Analysis/BasicAA/cas.ll
Expand Up @@ -6,9 +6,9 @@
; CHECK: ret i32 0

define i32 @main() {
%a = load i32* @flag0
%a = load i32, i32* @flag0
%b = atomicrmw xchg i32* @turn, i32 1 monotonic
%c = load i32* @flag0
%c = load i32, i32* @flag0
%d = sub i32 %a, %c
ret i32 %d
}
2 changes: 1 addition & 1 deletion llvm/test/Analysis/BasicAA/dag.ll
Expand Up @@ -36,6 +36,6 @@ xc:
%bigbase = bitcast i8* %base to i16*
store i16 -1, i16* %bigbase

%loaded = load i8* %phi
%loaded = load i8, i8* %phi
ret i8 %loaded
}

0 comments on commit a79ac14

Please sign in to comment.