X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=test%2FTransforms%2FGlobalOpt%2Fctor-list-opt.ll;h=95e7d4d1ab5b0d82511cfd61498b41286c8edfb0;hb=cbfbb3ee4c9b215cd367db3b64dfef0a7f334369;hp=7e90bc1a62722efa16b658052f89e3ab5fa88976;hpb=4e51a12ed77d8ec42493eaed0d9f8486f678ccad;p=oota-llvm.git diff --git a/test/Transforms/GlobalOpt/ctor-list-opt.ll b/test/Transforms/GlobalOpt/ctor-list-opt.ll index 7e90bc1a627..95e7d4d1ab5 100644 --- a/test/Transforms/GlobalOpt/ctor-list-opt.ll +++ b/test/Transforms/GlobalOpt/ctor-list-opt.ll @@ -1,5 +1,20 @@ -; RUN: opt < %s -globalopt -S | not grep CTOR -@llvm.global_ctors = appending global [10 x { i32, void ()* }] [ { i32, void ()* } { i32 65535, void ()* @CTOR1 }, { i32, void ()* } { i32 65535, void ()* @CTOR1 }, { i32, void ()* } { i32 65535, void ()* @CTOR2 }, { i32, void ()* } { i32 65535, void ()* @CTOR3 }, { i32, void ()* } { i32 65535, void ()* @CTOR4 }, { i32, void ()* } { i32 65535, void ()* @CTOR5 }, { i32, void ()* } { i32 65535, void ()* @CTOR6 }, { i32, void ()* } { i32 65535, void ()* @CTOR7 }, { i32, void ()* } { i32 65535, void ()* @CTOR8 }, { i32, void ()* } { i32 2147483647, void ()* null } ] ; <[10 x { i32, void ()* }]*> [#uses=0] +; RUN: opt < %s -globalopt -S | FileCheck %s +; CHECK-NOT: CTOR +%ini = type { i32, void()*, i8* } +@llvm.global_ctors = appending global [11 x %ini] [ + %ini { i32 65535, void ()* @CTOR1, i8* null }, + %ini { i32 65535, void ()* @CTOR1, i8* null }, + %ini { i32 65535, void ()* @CTOR2, i8* null }, + %ini { i32 65535, void ()* @CTOR3, i8* null }, + %ini { i32 65535, void ()* @CTOR4, i8* null }, + %ini { i32 65535, void ()* @CTOR5, i8* null }, + %ini { i32 65535, void ()* @CTOR6, i8* null }, + %ini { i32 65535, void ()* @CTOR7, i8* null }, + %ini { i32 65535, void ()* @CTOR8, i8* null }, + %ini { i32 65535, void ()* @CTOR9, i8* null }, + %ini { i32 2147483647, void ()* null, i8* null } +] + @G = global i32 0 ; [#uses=1] @G2 = global i32 0 ; [#uses=1] @G3 = global i32 -123 ; [#uses=2] @@ -36,16 +51,16 @@ T: ; preds = %Cont } define internal void @CTOR4() { - %X = load i32* @G3 ; [#uses=1] + %X = load i32, i32* @G3 ; [#uses=1] %Y = add i32 %X, 123 ; [#uses=1] store i32 %Y, i32* @G3 ret void } define internal void @CTOR5() { - %X.2p = getelementptr inbounds { i32, [2 x i32] }* @X, i32 0, i32 1, i32 0 ; [#uses=2] - %X.2 = load i32* %X.2p ; [#uses=1] - %X.1p = getelementptr inbounds { i32, [2 x i32] }* @X, i32 0, i32 0 ; [#uses=1] + %X.2p = getelementptr inbounds { i32, [2 x i32] }, { i32, [2 x i32] }* @X, i32 0, i32 1, i32 0 ; [#uses=2] + %X.2 = load i32, i32* %X.2p ; [#uses=1] + %X.1p = getelementptr inbounds { i32, [2 x i32] }, { i32, [2 x i32] }* @X, i32 0, i32 0 ; [#uses=1] store i32 %X.2, i32* %X.1p store i32 42, i32* %X.2p ret void @@ -53,9 +68,9 @@ define internal void @CTOR5() { define internal void @CTOR6() { %A = alloca i32 ; [#uses=2] - %y = load i32* @Y ; [#uses=1] + %y = load i32, i32* @Y ; [#uses=1] store i32 %y, i32* %A - %Av = load i32* %A ; [#uses=1] + %Av = load i32, i32* %A ; [#uses=1] %Av1 = add i32 %Av, 1 ; [#uses=1] store i32 %Av1, i32* @Y ret void @@ -80,6 +95,21 @@ define internal void @CTOR8() { } define i1 @accessor() { - %V = load i1* @CTORGV ; [#uses=1] + %V = load i1, i1* @CTORGV ; [#uses=1] ret i1 %V } + +%struct.A = type { i32 } +%struct.B = type { i32 (...)**, i8*, [4 x i8] } +@GV1 = global %struct.B zeroinitializer, align 8 +@GV2 = constant [3 x i8*] [i8* inttoptr (i64 16 to i8*), i8* null, i8* bitcast ({ i8*, i8*, i32, i32, i8*, i64 }* null to i8*)] +; CHECK-NOT: CTOR9 +define internal void @CTOR9() { +entry: + %0 = bitcast %struct.B* @GV1 to i8* + %1 = getelementptr inbounds i8, i8* %0, i64 16 + %2 = bitcast i8* %1 to %struct.A* + %3 = bitcast %struct.B* @GV1 to i8*** + store i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @GV2, i64 1, i64 0), i8*** %3 + ret void +}