From 8570893cfde8a82c723eaa4608c1e2ebe764a285 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Sat, 26 Nov 2022 19:12:18 -0500 Subject: [PATCH] GlobalDCE: Convert tests to opaque pointers The script mangled both virtual-functions-base-pointer-call.ll and virtual-functions-derived-pointer-call.ll pretty badly, deleting the run line and most of the block comment. Replaced the bitcast with and addrspacecast in 2002-07-17-CastRef.ll, based on the apparent intent of the test. For 2003-07-01-SelfReference.ll, the script produced "call ptr () @getfunc" which surprisingly parses as valid. --- .../GlobalDCE/2002-07-17-CastRef.ll | 2 +- .../GlobalDCE/2002-07-17-ConstantRef.ll | 2 +- .../GlobalDCE/2002-08-17-FunctionDGE.ll | 6 +- .../GlobalDCE/2002-08-17-WorkListTest.ll | 12 ++-- .../GlobalDCE/2002-09-12-Redeletion.ll | 6 +- .../GlobalDCE/2003-07-01-SelfReference.ll | 8 +-- .../GlobalDCE/2009-01-05-DeadAliases.ll | 14 ++--- .../GlobalDCE/2009-02-17-AliasUsesAliasee.ll | 2 +- .../GlobalDCE/call-with-ptrtoint.ll | 4 +- llvm/test/Transforms/GlobalDCE/comdats.ll | 30 ++++----- .../GlobalDCE/complex-constantexpr.ll | 34 +++++----- .../Transforms/GlobalDCE/deadblockaddr.ll | 2 +- .../GlobalDCE/externally_available.ll | 2 +- .../test/Transforms/GlobalDCE/global-ifunc.ll | 10 +-- .../test/Transforms/GlobalDCE/global_ctors.ll | 6 +- .../GlobalDCE/global_ctors_integration.ll | 30 ++++----- llvm/test/Transforms/GlobalDCE/indirectbr.ll | 8 +-- .../GlobalDCE/virtual-functions-base-call.ll | 38 +++++------- .../virtual-functions-base-pointer-call.ll | 58 ++++++++--------- .../virtual-functions-derived-call.ll | 38 +++++------- .../virtual-functions-derived-pointer-call.ll | 58 ++++++++--------- .../GlobalDCE/virtual-functions-nonptr.ll | 22 +++---- .../GlobalDCE/virtual-functions-novfe.ll | 27 ++++---- .../GlobalDCE/virtual-functions-null.ll | 34 +++++----- ...virtual-functions-relative-pointers-bad.ll | 10 +-- ...virtual-functions-relative-pointers-gep.ll | 12 ++-- .../virtual-functions-relative-pointers.ll | 12 ++-- .../virtual-functions-visibility-post-lto.ll | 62 +++++++++---------- .../virtual-functions-visibility-pre-lto.ll | 62 +++++++++---------- .../Transforms/GlobalDCE/virtual-functions.ll | 27 ++++---- llvm/test/Transforms/GlobalDCE/vtable-rtti.ll | 28 ++++----- 31 files changed, 313 insertions(+), 353 deletions(-) diff --git a/llvm/test/Transforms/GlobalDCE/2002-07-17-CastRef.ll b/llvm/test/Transforms/GlobalDCE/2002-07-17-CastRef.ll index ac548404ec92..d08c32e415c4 100644 --- a/llvm/test/Transforms/GlobalDCE/2002-07-17-CastRef.ll +++ b/llvm/test/Transforms/GlobalDCE/2002-07-17-CastRef.ll @@ -5,7 +5,7 @@ define internal void @func() { } define void @main() { - %X = bitcast void ()* @func to i32* ; [#uses=0] + %X = addrspacecast ptr @func to ptr addrspace(1) ; [#uses=0] ret void } diff --git a/llvm/test/Transforms/GlobalDCE/2002-07-17-ConstantRef.ll b/llvm/test/Transforms/GlobalDCE/2002-07-17-ConstantRef.ll index 6ed1612917bd..67eac0023678 100644 --- a/llvm/test/Transforms/GlobalDCE/2002-07-17-ConstantRef.ll +++ b/llvm/test/Transforms/GlobalDCE/2002-07-17-ConstantRef.ll @@ -1,7 +1,7 @@ ; RUN: opt < %s -passes=globaldce ; -@X = global void ()* @func ; [#uses=0] +@X = global ptr @func ; [#uses=0] ; Not dead, can be reachable via X define internal void @func() { diff --git a/llvm/test/Transforms/GlobalDCE/2002-08-17-FunctionDGE.ll b/llvm/test/Transforms/GlobalDCE/2002-08-17-FunctionDGE.ll index 086e3c10b488..bea532a94afd 100644 --- a/llvm/test/Transforms/GlobalDCE/2002-08-17-FunctionDGE.ll +++ b/llvm/test/Transforms/GlobalDCE/2002-08-17-FunctionDGE.ll @@ -5,14 +5,14 @@ ; CHECK-NOT: foo ;; Unused, kills %foo -@b = internal global i32 ()* @foo ; [#uses=0] +@b = internal global ptr @foo ; [#uses=0] ;; Should die when function %foo is killed -@foo.upgrd.1 = internal global i32 7 ; [#uses=1] +@foo.upgrd.1 = internal global i32 7 ; [#uses=1] ;; dies when %b dies. define internal i32 @foo() { - %ret = load i32, i32* @foo.upgrd.1 ; [#uses=1] + %ret = load i32, ptr @foo.upgrd.1 ; [#uses=1] ret i32 %ret } diff --git a/llvm/test/Transforms/GlobalDCE/2002-08-17-WorkListTest.ll b/llvm/test/Transforms/GlobalDCE/2002-08-17-WorkListTest.ll index c1dda1a760f1..e1bb5ac017c3 100644 --- a/llvm/test/Transforms/GlobalDCE/2002-08-17-WorkListTest.ll +++ b/llvm/test/Transforms/GlobalDCE/2002-08-17-WorkListTest.ll @@ -5,10 +5,10 @@ ; CHECK-NOT: global -@t0 = internal global [4 x i8] c"foo\00" ; <[4 x i8]*> [#uses=1] -@t1 = internal global [4 x i8] c"bar\00" ; <[4 x i8]*> [#uses=1] -@s1 = internal global [1 x i8*] [ i8* getelementptr ([4 x i8], [4 x i8]* @t0, i32 0, i32 0) ] ; <[1 x i8*]*> [#uses=0] -@s2 = internal global [1 x i8*] [ i8* getelementptr ([4 x i8], [4 x i8]* @t1, i64 0, i64 0) ] ; <[1 x i8*]*> [#uses=0] -@b = internal global i32* @a ; [#uses=0] -@a = internal global i32 7 ; [#uses=1] +@t0 = internal global [4 x i8] c"foo\00" ; [#uses=1] +@t1 = internal global [4 x i8] c"bar\00" ; [#uses=1] +@s1 = internal global [1 x ptr] [ ptr @t0 ] ; [#uses=0] +@s2 = internal global [1 x ptr] [ ptr @t1 ] ; [#uses=0] +@b = internal global ptr @a ; [#uses=0] +@a = internal global i32 7 ; [#uses=1] diff --git a/llvm/test/Transforms/GlobalDCE/2002-09-12-Redeletion.ll b/llvm/test/Transforms/GlobalDCE/2002-09-12-Redeletion.ll index d664357dd546..0397c73f7653 100644 --- a/llvm/test/Transforms/GlobalDCE/2002-09-12-Redeletion.ll +++ b/llvm/test/Transforms/GlobalDCE/2002-09-12-Redeletion.ll @@ -1,11 +1,11 @@ ; RUN: opt < %s -passes=globaldce ;; Should die when function %foo is killed -@foo.upgrd.1 = internal global i32 7 ; [#uses=3] -@bar = internal global [2 x { i32*, i32 }] [ { i32*, i32 } { i32* @foo.upgrd.1, i32 7 }, { i32*, i32 } { i32* @foo.upgrd.1, i32 1 } ] ; <[2 x { i32*, i32 }]*> [#uses=0] +@foo.upgrd.1 = internal global i32 7 ; [#uses=3] +@bar = internal global [2 x { ptr, i32 }] [ { ptr, i32 } { ptr @foo.upgrd.1, i32 7 }, { ptr, i32 } { ptr @foo.upgrd.1, i32 1 } ] ; [#uses=0] define internal i32 @foo() { - %ret = load i32, i32* @foo.upgrd.1 ; [#uses=1] + %ret = load i32, ptr @foo.upgrd.1 ; [#uses=1] ret i32 %ret } diff --git a/llvm/test/Transforms/GlobalDCE/2003-07-01-SelfReference.ll b/llvm/test/Transforms/GlobalDCE/2003-07-01-SelfReference.ll index ed72946c710f..67b096d4cda7 100644 --- a/llvm/test/Transforms/GlobalDCE/2003-07-01-SelfReference.ll +++ b/llvm/test/Transforms/GlobalDCE/2003-07-01-SelfReference.ll @@ -3,11 +3,11 @@ ; CHECK-NOT: testfunc -declare i1 ()* @getfunc() +declare ptr @getfunc() define internal i1 @testfunc() { - %F = call i1 ()* () @getfunc( ) ; [#uses=1] - %c = icmp eq i1 ()* %F, @testfunc ; [#uses=1] - ret i1 %c + %F = call ptr @getfunc() ; [#uses=1] + %c = icmp eq ptr %F, @testfunc ; [#uses=1] + ret i1 %c } diff --git a/llvm/test/Transforms/GlobalDCE/2009-01-05-DeadAliases.ll b/llvm/test/Transforms/GlobalDCE/2009-01-05-DeadAliases.ll index 7d83e860d8c7..79c1c67f7bca 100644 --- a/llvm/test/Transforms/GlobalDCE/2009-01-05-DeadAliases.ll +++ b/llvm/test/Transforms/GlobalDCE/2009-01-05-DeadAliases.ll @@ -5,14 +5,14 @@ @A = global i32 0 ; CHECK: @A = global i32 0 -@D = internal alias i32, i32* @A +@D = internal alias i32, ptr @A ; DEAD-NOT: @D -@L1 = alias i32, i32* @A -; CHECK: @L1 = alias i32, i32* @A +@L1 = alias i32, ptr @A +; CHECK: @L1 = alias i32, ptr @A -@L2 = internal alias i32, i32* @L1 -; CHECK: @L2 = internal alias i32, i32* @L1 +@L2 = internal alias i32, ptr @L1 +; CHECK: @L2 = internal alias i32, ptr @L1 -@L3 = alias i32, i32* @L2 -; CHECK: @L3 = alias i32, i32* @L2 +@L3 = alias i32, ptr @L2 +; CHECK: @L3 = alias i32, ptr @L2 diff --git a/llvm/test/Transforms/GlobalDCE/2009-02-17-AliasUsesAliasee.ll b/llvm/test/Transforms/GlobalDCE/2009-02-17-AliasUsesAliasee.ll index 703a3cca36dd..d3f7999bb7b9 100644 --- a/llvm/test/Transforms/GlobalDCE/2009-02-17-AliasUsesAliasee.ll +++ b/llvm/test/Transforms/GlobalDCE/2009-02-17-AliasUsesAliasee.ll @@ -1,4 +1,4 @@ ; RUN: opt < %s -passes=globaldce -@A = internal alias void (), void ()* @F +@A = internal alias void (), ptr @F define internal void @F() { ret void } diff --git a/llvm/test/Transforms/GlobalDCE/call-with-ptrtoint.ll b/llvm/test/Transforms/GlobalDCE/call-with-ptrtoint.ll index 07508b4dcf13..025a86e1fcf4 100644 --- a/llvm/test/Transforms/GlobalDCE/call-with-ptrtoint.ll +++ b/llvm/test/Transforms/GlobalDCE/call-with-ptrtoint.ll @@ -2,10 +2,10 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" -declare { i8*, i1 } @llvm.type.checked.load(i8*, i32, metadata) +declare { ptr, i1 } @llvm.type.checked.load(ptr, i32, metadata) define internal void @foo() { - call void @bar_with_fptr_argument(i64 ptrtoint (void ()* @baz to i64)) + call void @bar_with_fptr_argument(i64 ptrtoint (ptr @baz to i64)) ret void } diff --git a/llvm/test/Transforms/GlobalDCE/comdats.ll b/llvm/test/Transforms/GlobalDCE/comdats.ll index 2f5ac59a68a1..8cc29f9c79d9 100644 --- a/llvm/test/Transforms/GlobalDCE/comdats.ll +++ b/llvm/test/Transforms/GlobalDCE/comdats.ll @@ -70,22 +70,22 @@ $test10_c = comdat any @test9_gv = linkonce_odr unnamed_addr global i32 42, comdat($test9_c) ; CHECK-NOT: @test9_gv -@test10_gv = linkonce_odr unnamed_addr global void ()* @test10_f, comdat($test10_c) +@test10_gv = linkonce_odr unnamed_addr global ptr @test10_f, comdat($test10_c) ; CHECK-NOT: @test10_gv -@test3_a = linkonce_odr unnamed_addr alias void (), void ()* @test3_f +@test3_a = linkonce_odr unnamed_addr alias void (), ptr @test3_f ; CHECK: @test3_a = linkonce_odr unnamed_addr alias -@test4_a = linkonce_odr unnamed_addr alias void (), void ()* @test4_f +@test4_a = linkonce_odr unnamed_addr alias void (), ptr @test4_f ; CHECK: @test4_a = linkonce_odr unnamed_addr alias -@test10_a = linkonce_odr unnamed_addr alias void (), void ()* @test10_g +@test10_a = linkonce_odr unnamed_addr alias void (), ptr @test10_g ; CHECK-NOT: @test10_a -@test5_if = linkonce_odr ifunc void (), void ()* ()* @test5_f +@test5_if = linkonce_odr ifunc void (), ptr @test5_f ; CHECK-NOT: @test5_if -@test6_if = linkonce_odr ifunc void (), void ()* ()* @test6_f +@test6_if = linkonce_odr ifunc void (), ptr @test6_f ; CHECK: @test6_if = linkonce_odr ifunc ; This function is directly used and so cannot be eliminated. @@ -123,16 +123,16 @@ entry: declare void @test_external() -define linkonce_odr void ()* @test5_f() comdat($test5_c) { -; CHECK: define linkonce_odr void ()* @test5_f() +define linkonce_odr ptr @test5_f() comdat($test5_c) { +; CHECK: define linkonce_odr ptr @test5_f() entry: - ret void ()* @test_external + ret ptr @test_external } -define linkonce_odr void ()* @test6_f() comdat($test6_c) { -; CHECK: define linkonce_odr void ()* @test6_f() +define linkonce_odr ptr @test6_f() comdat($test6_c) { +; CHECK: define linkonce_odr ptr @test6_f() entry: - ret void ()* @test_external + ret ptr @test_external } define linkonce_odr void @test7_f() comdat($test7_c) { @@ -150,7 +150,7 @@ entry: define linkonce_odr void @test10_f() comdat($test10_c) { ; CHECK-NOT: @test10_f entry: - %gv = load void ()*, void ()** @test10_gv + %gv = load ptr, ptr @test10_gv call void @test10_a() ret void } @@ -167,12 +167,12 @@ entry: ; eliminated. define void @external_user() { call void @test1_used() - %gv = load i32, i32* @test2_used + %gv = load i32, ptr @test2_used call void @test3_f() call void @test4_a() - %fptr = call void() *@test5_f() + %fptr = call ptr @test5_f() call void @test6_if() ret void } diff --git a/llvm/test/Transforms/GlobalDCE/complex-constantexpr.ll b/llvm/test/Transforms/GlobalDCE/complex-constantexpr.ll index b4eed02eff23..5083f707c168 100644 --- a/llvm/test/Transforms/GlobalDCE/complex-constantexpr.ll +++ b/llvm/test/Transforms/GlobalDCE/complex-constantexpr.ll @@ -14,19 +14,19 @@ define void @zot12() { bb: - store i32 0, i32* @global5, align 4 - store i32 0, i32* @global6, align 4 + store i32 0, ptr @global5, align 4 + store i32 0, ptr @global6, align 4 br label %bb2 bb1: ; preds = %bb11 - %tmp = load i32, i32* @global5, align 4 + %tmp = load i32, ptr @global5, align 4 br label %bb2 bb2: ; preds = %bb1, %bb %tmp3 = phi i32 [ %tmp, %bb1 ], [ 0, %bb ] - %tmp4 = xor i32 %tmp3, zext (i1 icmp ne (i64 ptrtoint (i32* @global5 to i64), i64 1) to i32) - store i32 %tmp4, i32* @global5, align 4 - %tmp5 = icmp eq i32 %tmp3, zext (i1 icmp ne (i64 ptrtoint (i32* @global5 to i64), i64 1) to i32) + %tmp4 = xor i32 %tmp3, zext (i1 icmp ne (i64 ptrtoint (ptr @global5 to i64), i64 1) to i32) + store i32 %tmp4, ptr @global5, align 4 + %tmp5 = icmp eq i32 %tmp3, zext (i1 icmp ne (i64 ptrtoint (ptr @global5 to i64), i64 1) to i32) br i1 %tmp5, label %bb8, label %bb6 bb6: ; preds = %bb2 @@ -34,14 +34,14 @@ bb6: ; preds = %bb2 br label %bb8 bb8: ; preds = %bb6, %bb2 - %tmp9 = load i32, i32* @global7, align 4 + %tmp9 = load i32, ptr @global7, align 4 %tmp10 = icmp eq i32 %tmp9, 0 br i1 %tmp10, label %bb11, label %bb15 bb11: ; preds = %bb8 - %tmp12 = load i32, i32* @global6, align 4 + %tmp12 = load i32, ptr @global6, align 4 %tmp13 = add nsw i32 %tmp12, 1 - store i32 %tmp13, i32* @global6, align 4 + store i32 %tmp13, ptr @global6, align 4 %tmp14 = icmp slt i32 %tmp13, 42 br i1 %tmp14, label %bb1, label %bb15 @@ -51,7 +51,7 @@ bb15: ; preds = %bb11, %bb8 define i32 @quux13() { bb: - store i32 1, i32* @global5, align 4 + store i32 1, ptr @global5, align 4 ret i32 1 } @@ -69,9 +69,9 @@ bb: define void @blam() { bb: - store i32 ptrtoint (i32* @global to i32), i32* getelementptr inbounds (%struct.ham, %struct.ham* @global8, i64 0, i32 0), align 4 - store i32 0, i32* @global9, align 4 - %tmp = load i32, i32* getelementptr inbounds (%struct.ham, %struct.ham* @global8, i64 0, i32 0), align 4 + store i32 ptrtoint (ptr @global to i32), ptr @global8, align 4 + store i32 0, ptr @global9, align 4 + %tmp = load i32, ptr @global8, align 4 br label %bb1 bb1: ; preds = %bb1, %bb @@ -89,9 +89,9 @@ bb1: ; preds = %bb1, %bb br i1 %tmp12, label %bb13, label %bb1 bb13: ; preds = %bb1 - store i32 %tmp10, i32* getelementptr inbounds (%struct.ham, %struct.ham* @global8, i64 0, i32 0), align 4 - store i32 0, i32* @global10, align 4 - store i32 %tmp6, i32* @global11, align 4 - store i32 20, i32* @global9, align 4 + store i32 %tmp10, ptr @global8, align 4 + store i32 0, ptr @global10, align 4 + store i32 %tmp6, ptr @global11, align 4 + store i32 20, ptr @global9, align 4 ret void } diff --git a/llvm/test/Transforms/GlobalDCE/deadblockaddr.ll b/llvm/test/Transforms/GlobalDCE/deadblockaddr.ll index 2aea5f1cf8d0..4b3cec043e8a 100644 --- a/llvm/test/Transforms/GlobalDCE/deadblockaddr.ll +++ b/llvm/test/Transforms/GlobalDCE/deadblockaddr.ll @@ -3,7 +3,7 @@ ; Tests whether globaldce does the right cleanup while removing @bar ; so that a dead BlockAddress reference to foo won't prevent other passes ; to work properly, e.g. simplifycfg -@bar = internal unnamed_addr constant i8* blockaddress(@foo, %L1) +@bar = internal unnamed_addr constant ptr blockaddress(@foo, %L1) ; CHECK-LABEL: foo ; CHECK-NOT: br label %L1 diff --git a/llvm/test/Transforms/GlobalDCE/externally_available.ll b/llvm/test/Transforms/GlobalDCE/externally_available.ll index fc721b2dba14..4c10d192308e 100644 --- a/llvm/test/Transforms/GlobalDCE/externally_available.ll +++ b/llvm/test/Transforms/GlobalDCE/externally_available.ll @@ -6,7 +6,7 @@ ; test_global2 is a normal global using an available externally function. ; CHECK: @test_global2 = -@test_global2 = global i32 ()* @test_function2 +@test_global2 = global ptr @test_function2 ; test_function should not be emitted to the .s file. ; CHECK-NOT: define {{.*}} @test_function() diff --git a/llvm/test/Transforms/GlobalDCE/global-ifunc.ll b/llvm/test/Transforms/GlobalDCE/global-ifunc.ll index e887b3129f8a..caf40cf8e811 100644 --- a/llvm/test/Transforms/GlobalDCE/global-ifunc.ll +++ b/llvm/test/Transforms/GlobalDCE/global-ifunc.ll @@ -2,12 +2,12 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" -@if = ifunc void (), void ()* ()* @fn +@if = ifunc void (), ptr @fn -define internal void ()* @fn() { +define internal ptr @fn() { entry: - ret void ()* null + ret ptr null } -; CHECK-DAG: @if = ifunc void (), void ()* ()* @fn -; CHECK-DAG: define internal void ()* @fn( +; CHECK-DAG: @if = ifunc void (), ptr @fn +; CHECK-DAG: define internal ptr @fn( diff --git a/llvm/test/Transforms/GlobalDCE/global_ctors.ll b/llvm/test/Transforms/GlobalDCE/global_ctors.ll index 1433c7c92da6..e9dd944b98df 100644 --- a/llvm/test/Transforms/GlobalDCE/global_ctors.ll +++ b/llvm/test/Transforms/GlobalDCE/global_ctors.ll @@ -1,12 +1,12 @@ ; RUN: opt -S -passes=globaldce < %s | FileCheck %s ; Test that the presence of debug intrinsics isn't affecting GlobalDCE. -; CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_notremovable, i8* null }] +; CHECK: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @_notremovable, ptr null }] ; CHECK-NOT: @_GLOBAL__I_a declare void @_notremovable() -@llvm.global_ctors = appending global [3 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I_a, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I_b, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @_notremovable, i8* null }] +@llvm.global_ctors = appending global [3 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__I_a, ptr null }, { i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__I_b, ptr null }, { i32, ptr, ptr } { i32 65535, ptr @_notremovable, ptr null }] @x = internal unnamed_addr constant i8 undef, align 1 @@ -19,7 +19,7 @@ entry: ; Function Attrs: nounwind readnone define internal void @_GLOBAL__I_b() #1 section "__TEXT,__StaticInit,regular,pure_instructions" { entry: - tail call void @llvm.dbg.value(metadata i8* @x, metadata !4, metadata !DIExpression(DW_OP_deref, DW_OP_constu, 0, DW_OP_swap, DW_OP_xderef)), !dbg !5 + tail call void @llvm.dbg.value(metadata ptr @x, metadata !4, metadata !DIExpression(DW_OP_deref, DW_OP_constu, 0, DW_OP_swap, DW_OP_xderef)), !dbg !5 ret void } diff --git a/llvm/test/Transforms/GlobalDCE/global_ctors_integration.ll b/llvm/test/Transforms/GlobalDCE/global_ctors_integration.ll index 47a1d0d1ab53..45650d7a52f4 100644 --- a/llvm/test/Transforms/GlobalDCE/global_ctors_integration.ll +++ b/llvm/test/Transforms/GlobalDCE/global_ctors_integration.ll @@ -9,33 +9,33 @@ @foo = global %class.Foo zeroinitializer, align 4 @_ZN3Bar18LINKER_INITIALIZEDE = external constant i32 -@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__I_a, i8* null }] +@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__I_a, ptr null }] define internal void @__cxx_global_var_init() section "__TEXT,__StaticInit,regular,pure_instructions" { - %1 = load i32, i32* @_ZN3Bar18LINKER_INITIALIZEDE, align 4 - call void @_ZN3FooC1E17LinkerInitialized(%class.Foo* @foo, i32 %1) + %1 = load i32, ptr @_ZN3Bar18LINKER_INITIALIZEDE, align 4 + call void @_ZN3FooC1E17LinkerInitialized(ptr @foo, i32 %1) ret void } ; Function Attrs: ssp uwtable -define linkonce_odr void @_ZN3FooC1E17LinkerInitialized(%class.Foo* %this, i32) unnamed_addr #0 align 2 { - %2 = alloca %class.Foo*, align 8 +define linkonce_odr void @_ZN3FooC1E17LinkerInitialized(ptr %this, i32) unnamed_addr #0 align 2 { + %2 = alloca ptr, align 8 %3 = alloca i32, align 4 - store %class.Foo* %this, %class.Foo** %2, align 8 - store i32 %0, i32* %3, align 4 - %4 = load %class.Foo*, %class.Foo** %2 - %5 = load i32, i32* %3, align 4 - call void @_ZN3FooC2E17LinkerInitialized(%class.Foo* %4, i32 %5) + store ptr %this, ptr %2, align 8 + store i32 %0, ptr %3, align 4 + %4 = load ptr, ptr %2 + %5 = load i32, ptr %3, align 4 + call void @_ZN3FooC2E17LinkerInitialized(ptr %4, i32 %5) ret void } ; Function Attrs: nounwind ssp uwtable -define linkonce_odr void @_ZN3FooC2E17LinkerInitialized(%class.Foo* %this, i32) unnamed_addr #1 align 2 { - %2 = alloca %class.Foo*, align 8 +define linkonce_odr void @_ZN3FooC2E17LinkerInitialized(ptr %this, i32) unnamed_addr #1 align 2 { + %2 = alloca ptr, align 8 %3 = alloca i32, align 4 - store %class.Foo* %this, %class.Foo** %2, align 8 - store i32 %0, i32* %3, align 4 - %4 = load %class.Foo*, %class.Foo** %2 + store ptr %this, ptr %2, align 8 + store i32 %0, ptr %3, align 4 + %4 = load ptr, ptr %2 ret void } diff --git a/llvm/test/Transforms/GlobalDCE/indirectbr.ll b/llvm/test/Transforms/GlobalDCE/indirectbr.ll index 27bcabf709b4..498edab69b57 100644 --- a/llvm/test/Transforms/GlobalDCE/indirectbr.ll +++ b/llvm/test/Transforms/GlobalDCE/indirectbr.ll @@ -1,6 +1,6 @@ ; RUN: opt -S -passes=globaldce < %s | FileCheck %s -@L = internal unnamed_addr constant [3 x i8*] [i8* blockaddress(@test1, %L1), i8* blockaddress(@test1, %L2), i8* null], align 16 +@L = internal unnamed_addr constant [3 x ptr] [ptr blockaddress(@test1, %L1), ptr blockaddress(@test1, %L2), ptr null], align 16 ; CHECK: @L = internal unnamed_addr constant @@ -9,9 +9,9 @@ entry: br label %L1 L1: - %arrayidx = getelementptr inbounds [3 x i8*], [3 x i8*]* @L, i32 0, i32 %idx - %l = load i8*, i8** %arrayidx - indirectbr i8* %l, [label %L1, label %L2] + %arrayidx = getelementptr inbounds [3 x ptr], ptr @L, i32 0, i32 %idx + %l = load ptr, ptr %arrayidx + indirectbr ptr %l, [label %L1, label %L2] L2: ret void diff --git a/llvm/test/Transforms/GlobalDCE/virtual-functions-base-call.ll b/llvm/test/Transforms/GlobalDCE/virtual-functions-base-call.ll index 0badf792e8e4..8ef2d895a029 100644 --- a/llvm/test/Transforms/GlobalDCE/virtual-functions-base-call.ll +++ b/llvm/test/Transforms/GlobalDCE/virtual-functions-base-call.ll @@ -22,53 +22,49 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" ; The virtual call in test could be dispatched to either A::foo or B::foo, so ; both must be retained. -%struct.A = type { i32 (...)** } +%struct.A = type { ptr } %struct.B = type { %struct.A } -; CHECK: @_ZTV1A = internal unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* null, i8* bitcast (i32 (%struct.A*)* @_ZN1A3fooEv to i8*)] } -@_ZTV1A = internal unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* null, i8* bitcast (i32 (%struct.A*)* @_ZN1A3fooEv to i8*)] }, align 8, !type !0, !type !1, !vcall_visibility !2 +; CHECK: @_ZTV1A = internal unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr @_ZN1A3fooEv] } +@_ZTV1A = internal unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr @_ZN1A3fooEv] }, align 8, !type !0, !type !1, !vcall_visibility !2 -; CHECK: @_ZTV1B = internal unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* null, i8* bitcast (i32 (%struct.B*)* @_ZN1B3fooEv to i8*)] } -@_ZTV1B = internal unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* null, i8* bitcast (i32 (%struct.B*)* @_ZN1B3fooEv to i8*)] }, align 8, !type !0, !type !1, !type !3, !type !4, !vcall_visibility !2 +; CHECK: @_ZTV1B = internal unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr @_ZN1B3fooEv] } +@_ZTV1B = internal unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr @_ZN1B3fooEv] }, align 8, !type !0, !type !1, !type !3, !type !4, !vcall_visibility !2 ; CHECK: define internal i32 @_ZN1A3fooEv( -define internal i32 @_ZN1A3fooEv(%struct.A* nocapture readnone %this) { +define internal i32 @_ZN1A3fooEv(ptr nocapture readnone %this) { entry: ret i32 42 } ; CHECK: define internal i32 @_ZN1B3fooEv( -define internal i32 @_ZN1B3fooEv(%struct.B* nocapture readnone %this) { +define internal i32 @_ZN1B3fooEv(ptr nocapture readnone %this) { entry: ret i32 1337 } -define hidden void @_ZN1AC2Ev(%struct.A* nocapture %this) { +define hidden void @_ZN1AC2Ev(ptr nocapture %this) { entry: - %0 = getelementptr inbounds %struct.A, %struct.A* %this, i64 0, i32 0 - store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV1A, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8 + store ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTV1A, i64 0, inrange i32 0, i64 2), ptr %this, align 8 ret void } -define hidden void @_ZN1BC2Ev(%struct.B* nocapture %this) { +define hidden void @_ZN1BC2Ev(ptr nocapture %this) { entry: - %0 = getelementptr inbounds %struct.B, %struct.B* %this, i64 0, i32 0, i32 0 - store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV1B, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8 + store ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTV1B, i64 0, inrange i32 0, i64 2), ptr %this, align 8 ret void } -define hidden i32 @test(%struct.A* %p) { +define hidden i32 @test(ptr %p) { entry: - %0 = bitcast %struct.A* %p to i8** - %vtable1 = load i8*, i8** %0, align 8 - %1 = tail call { i8*, i1 } @llvm.type.checked.load(i8* %vtable1, i32 0, metadata !"_ZTS1A"), !nosanitize !10 - %2 = extractvalue { i8*, i1 } %1, 0, !nosanitize !10 - %3 = bitcast i8* %2 to i32 (%struct.A*)*, !nosanitize !10 - %call = tail call i32 %3(%struct.A* %p) + %vtable1 = load ptr, ptr %p, align 8 + %0 = tail call { ptr, i1 } @llvm.type.checked.load(ptr %vtable1, i32 0, metadata !"_ZTS1A"), !nosanitize !10 + %1 = extractvalue { ptr, i1 } %0, 0, !nosanitize !10 + %call = tail call i32 %1(ptr %p) ret i32 %call } -declare { i8*, i1 } @llvm.type.checked.load(i8*, i32, metadata) #2 +declare { ptr, i1 } @llvm.type.checked.load(ptr, i32, metadata) #2 !llvm.module.flags = !{!5} diff --git a/llvm/test/Transforms/GlobalDCE/virtual-functions-base-pointer-call.ll b/llvm/test/Transforms/GlobalDCE/virtual-functions-base-pointer-call.ll index 13d97c633815..09979690da6d 100644 --- a/llvm/test/Transforms/GlobalDCE/virtual-functions-base-pointer-call.ll +++ b/llvm/test/Transforms/GlobalDCE/virtual-functions-base-pointer-call.ll @@ -29,84 +29,78 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" ; or B::foo. It can't be dispatched to A::bar or B::bar as the function pointer ; does not match, so those can be removed. -%struct.A = type { i32 (...)** } +%struct.A = type { ptr } %struct.B = type { %struct.A } -; CHECK: @_ZTV1A = internal unnamed_addr constant { [4 x i8*] } { [4 x i8*] [i8* null, i8* null, i8* bitcast (i32 (%struct.A*, i32)* @_ZN1A3fooEi to i8*), i8* null] } -@_ZTV1A = internal unnamed_addr constant { [4 x i8*] } { [4 x i8*] [i8* null, i8* null, i8* bitcast (i32 (%struct.A*, i32)* @_ZN1A3fooEi to i8*), i8* bitcast (i32 (%struct.A*, float)* @_ZN1A3barEf to i8*)] }, align 8, !type !0, !type !1, !type !2, !vcall_visibility !3 -; CHECK: @_ZTV1B = internal unnamed_addr constant { [4 x i8*] } { [4 x i8*] [i8* null, i8* null, i8* bitcast (i32 (%struct.B*, i32)* @_ZN1B3fooEi to i8*), i8* null] } -@_ZTV1B = internal unnamed_addr constant { [4 x i8*] } { [4 x i8*] [i8* null, i8* null, i8* bitcast (i32 (%struct.B*, i32)* @_ZN1B3fooEi to i8*), i8* bitcast (i32 (%struct.B*, float)* @_ZN1B3barEf to i8*)] }, align 8, !type !0, !type !1, !type !2, !type !4, !type !5, !type !6, !vcall_visibility !3 +; CHECK: @_ZTV1A = internal unnamed_addr constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr null, ptr @_ZN1A3fooEi, ptr null] } +@_ZTV1A = internal unnamed_addr constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr null, ptr @_ZN1A3fooEi, ptr @_ZN1A3barEf] }, align 8, !type !0, !type !1, !type !2, !vcall_visibility !3 +; CHECK: @_ZTV1B = internal unnamed_addr constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr null, ptr @_ZN1B3fooEi, ptr null] } +@_ZTV1B = internal unnamed_addr constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr null, ptr @_ZN1B3fooEi, ptr @_ZN1B3barEf] }, align 8, !type !0, !type !1, !type !2, !type !4, !type !5, !type !6, !vcall_visibility !3 ; CHECK: define internal i32 @_ZN1A3fooEi( -define internal i32 @_ZN1A3fooEi(%struct.A* nocapture readnone %this, i32) unnamed_addr #1 align 2 { +define internal i32 @_ZN1A3fooEi(ptr nocapture readnone %this, i32) unnamed_addr #1 align 2 { entry: ret i32 1 } ; CHECK-NOT: define internal i32 @_ZN1A3barEf( -define internal i32 @_ZN1A3barEf(%struct.A* nocapture readnone %this, float) unnamed_addr #1 align 2 { +define internal i32 @_ZN1A3barEf(ptr nocapture readnone %this, float) unnamed_addr #1 align 2 { entry: ret i32 2 } ; CHECK: define internal i32 @_ZN1B3fooEi( -define internal i32 @_ZN1B3fooEi(%struct.B* nocapture readnone %this, i32) unnamed_addr #1 align 2 { +define internal i32 @_ZN1B3fooEi(ptr nocapture readnone %this, i32) unnamed_addr #1 align 2 { entry: ret i32 3 } ; CHECK-NOT: define internal i32 @_ZN1B3barEf( -define internal i32 @_ZN1B3barEf(%struct.B* nocapture readnone %this, float) unnamed_addr #1 align 2 { +define internal i32 @_ZN1B3barEf(ptr nocapture readnone %this, float) unnamed_addr #1 align 2 { entry: ret i32 4 } -define hidden void @_ZN1AC2Ev(%struct.A* nocapture %this) { +define hidden void @_ZN1AC2Ev(ptr nocapture %this) { entry: - %0 = getelementptr inbounds %struct.A, %struct.A* %this, i64 0, i32 0 - store i32 (...)** bitcast (i8** getelementptr inbounds ({ [4 x i8*] }, { [4 x i8*] }* @_ZTV1A, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8 + store ptr getelementptr inbounds ({ [4 x ptr] }, ptr @_ZTV1A, i64 0, inrange i32 0, i64 2), ptr %this, align 8 ret void } -define hidden void @_ZN1BC2Ev(%struct.B* nocapture %this) { +define hidden void @_ZN1BC2Ev(ptr nocapture %this) { entry: - %0 = getelementptr inbounds %struct.B, %struct.B* %this, i64 0, i32 0, i32 0 - store i32 (...)** bitcast (i8** getelementptr inbounds ({ [4 x i8*] }, { [4 x i8*] }* @_ZTV1B, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8 + store ptr getelementptr inbounds ({ [4 x ptr] }, ptr @_ZTV1B, i64 0, inrange i32 0, i64 2), ptr %this, align 8 ret void } -define hidden i32 @test(%struct.A* %p, i64 %q.coerce0, i64 %q.coerce1) { +define hidden i32 @test(ptr %p, i64 %q.coerce0, i64 %q.coerce1) { entry: - %0 = bitcast %struct.A* %p to i8* - %1 = getelementptr inbounds i8, i8* %0, i64 %q.coerce1 - %this.adjusted = bitcast i8* %1 to %struct.A* - %2 = and i64 %q.coerce0, 1 - %memptr.isvirtual = icmp eq i64 %2, 0 + %0 = getelementptr inbounds i8, ptr %p, i64 %q.coerce1 + %1 = and i64 %q.coerce0, 1 + %memptr.isvirtual = icmp eq i64 %1, 0 br i1 %memptr.isvirtual, label %memptr.nonvirtual, label %memptr.virtual memptr.virtual: ; preds = %entry - %3 = bitcast i8* %1 to i8** - %vtable = load i8*, i8** %3, align 8 - %4 = add i64 %q.coerce0, -1 - %5 = getelementptr i8, i8* %vtable, i64 %4, !nosanitize !12 - %6 = tail call { i8*, i1 } @llvm.type.checked.load(i8* %5, i32 0, metadata !"_ZTSM1AFiiE.virtual"), !nosanitize !12 - %7 = extractvalue { i8*, i1 } %6, 0, !nosanitize !12 - %memptr.virtualfn = bitcast i8* %7 to i32 (%struct.A*, i32)*, !nosanitize !12 + %vtable = load ptr, ptr %0, align 8 + %2 = add i64 %q.coerce0, -1 + %3 = getelementptr i8, ptr %vtable, i64 %2, !nosanitize !12 + %4 = tail call { ptr, i1 } @llvm.type.checked.load(ptr %3, i32 0, metadata !"_ZTSM1AFiiE.virtual"), !nosanitize !12 + %5 = extractvalue { ptr, i1 } %4, 0, !nosanitize !12 br label %memptr.end memptr.nonvirtual: ; preds = %entry - %memptr.nonvirtualfn = inttoptr i64 %q.coerce0 to i32 (%struct.A*, i32)* + %memptr.nonvirtualfn = inttoptr i64 %q.coerce0 to ptr br label %memptr.end memptr.end: ; preds = %memptr.nonvirtual, %memptr.virtual - %8 = phi i32 (%struct.A*, i32)* [ %memptr.virtualfn, %memptr.virtual ], [ %memptr.nonvirtualfn, %memptr.nonvirtual ] - %call = tail call i32 %8(%struct.A* %this.adjusted, i32 42) + %6 = phi ptr [ %5, %memptr.virtual ], [ %memptr.nonvirtualfn, %memptr.nonvirtual ] + %call = tail call i32 %6(ptr %0, i32 42) ret i32 %call } -declare { i8*, i1 } @llvm.type.checked.load(i8*, i32, metadata) +declare { ptr, i1 } @llvm.type.checked.load(ptr, i32, metadata) !llvm.module.flags = !{!7} diff --git a/llvm/test/Transforms/GlobalDCE/virtual-functions-derived-call.ll b/llvm/test/Transforms/GlobalDCE/virtual-functions-derived-call.ll index 49573f9f335a..896675f7655f 100644 --- a/llvm/test/Transforms/GlobalDCE/virtual-functions-derived-call.ll +++ b/llvm/test/Transforms/GlobalDCE/virtual-functions-derived-call.ll @@ -22,53 +22,49 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" ; The virtual call in test can only be dispatched to B::foo (or a more-derived ; class, if there was one), so A::foo can be removed. -%struct.A = type { i32 (...)** } +%struct.A = type { ptr } %struct.B = type { %struct.A } -; CHECK: @_ZTV1A = internal unnamed_addr constant { [3 x i8*] } zeroinitializer -@_ZTV1A = internal unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* null, i8* bitcast (i32 (%struct.A*)* @_ZN1A3fooEv to i8*)] }, align 8, !type !0, !type !1, !vcall_visibility !2 +; CHECK: @_ZTV1A = internal unnamed_addr constant { [3 x ptr] } zeroinitializer +@_ZTV1A = internal unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr @_ZN1A3fooEv] }, align 8, !type !0, !type !1, !vcall_visibility !2 -; CHECK: @_ZTV1B = internal unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* null, i8* bitcast (i32 (%struct.B*)* @_ZN1B3fooEv to i8*)] } -@_ZTV1B = internal unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* null, i8* bitcast (i32 (%struct.B*)* @_ZN1B3fooEv to i8*)] }, align 8, !type !0, !type !1, !type !3, !type !4, !vcall_visibility !2 +; CHECK: @_ZTV1B = internal unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr @_ZN1B3fooEv] } +@_ZTV1B = internal unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr @_ZN1B3fooEv] }, align 8, !type !0, !type !1, !type !3, !type !4, !vcall_visibility !2 ; CHECK-NOT: define internal i32 @_ZN1A3fooEv( -define internal i32 @_ZN1A3fooEv(%struct.A* nocapture readnone %this) { +define internal i32 @_ZN1A3fooEv(ptr nocapture readnone %this) { entry: ret i32 42 } ; CHECK: define internal i32 @_ZN1B3fooEv( -define internal i32 @_ZN1B3fooEv(%struct.B* nocapture readnone %this) { +define internal i32 @_ZN1B3fooEv(ptr nocapture readnone %this) { entry: ret i32 1337 } -define hidden void @_ZN1AC2Ev(%struct.A* nocapture %this) { +define hidden void @_ZN1AC2Ev(ptr nocapture %this) { entry: - %0 = getelementptr inbounds %struct.A, %struct.A* %this, i64 0, i32 0 - store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV1A, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8 + store ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTV1A, i64 0, inrange i32 0, i64 2), ptr %this, align 8 ret void } -define hidden void @_ZN1BC2Ev(%struct.B* nocapture %this) { +define hidden void @_ZN1BC2Ev(ptr nocapture %this) { entry: - %0 = getelementptr inbounds %struct.B, %struct.B* %this, i64 0, i32 0, i32 0 - store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV1B, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8 + store ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTV1B, i64 0, inrange i32 0, i64 2), ptr %this, align 8 ret void } -define hidden i32 @test(%struct.B* %p) { +define hidden i32 @test(ptr %p) { entry: - %0 = bitcast %struct.B* %p to i8** - %vtable1 = load i8*, i8** %0, align 8 - %1 = tail call { i8*, i1 } @llvm.type.checked.load(i8* %vtable1, i32 0, metadata !"_ZTS1B"), !nosanitize !10 - %2 = extractvalue { i8*, i1 } %1, 0, !nosanitize !10 - %3 = bitcast i8* %2 to i32 (%struct.B*)*, !nosanitize !10 - %call = tail call i32 %3(%struct.B* %p) + %vtable1 = load ptr, ptr %p, align 8 + %0 = tail call { ptr, i1 } @llvm.type.checked.load(ptr %vtable1, i32 0, metadata !"_ZTS1B"), !nosanitize !10 + %1 = extractvalue { ptr, i1 } %0, 0, !nosanitize !10 + %call = tail call i32 %1(ptr %p) ret i32 %call } -declare { i8*, i1 } @llvm.type.checked.load(i8*, i32, metadata) #2 +declare { ptr, i1 } @llvm.type.checked.load(ptr, i32, metadata) #2 !llvm.module.flags = !{!5} diff --git a/llvm/test/Transforms/GlobalDCE/virtual-functions-derived-pointer-call.ll b/llvm/test/Transforms/GlobalDCE/virtual-functions-derived-pointer-call.ll index a11d8d731bcf..bdf97d25ac3f 100644 --- a/llvm/test/Transforms/GlobalDCE/virtual-functions-derived-pointer-call.ll +++ b/llvm/test/Transforms/GlobalDCE/virtual-functions-derived-pointer-call.ll @@ -31,84 +31,78 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" ; does not match, and it can't be dispatched to A::foo as the object type ; doesn't match, so those can be removed. -%struct.A = type { i32 (...)** } +%struct.A = type { ptr } %struct.B = type { %struct.A } -; CHECK: @_ZTV1A = internal unnamed_addr constant { [4 x i8*] } zeroinitializer -@_ZTV1A = internal unnamed_addr constant { [4 x i8*] } { [4 x i8*] [i8* null, i8* null, i8* bitcast (i32 (%struct.A*, i32)* @_ZN1A3fooEi to i8*), i8* bitcast (i32 (%struct.A*, float)* @_ZN1A3barEf to i8*)] }, align 8, !type !0, !type !1, !type !2, !vcall_visibility !3 -; CHECK: @_ZTV1B = internal unnamed_addr constant { [4 x i8*] } { [4 x i8*] [i8* null, i8* null, i8* bitcast (i32 (%struct.B*, i32)* @_ZN1B3fooEi to i8*), i8* null] } -@_ZTV1B = internal unnamed_addr constant { [4 x i8*] } { [4 x i8*] [i8* null, i8* null, i8* bitcast (i32 (%struct.B*, i32)* @_ZN1B3fooEi to i8*), i8* bitcast (i32 (%struct.B*, float)* @_ZN1B3barEf to i8*)] }, align 8, !type !0, !type !1, !type !2, !type !4, !type !5, !type !6, !vcall_visibility !3 +; CHECK: @_ZTV1A = internal unnamed_addr constant { [4 x ptr] } zeroinitializer +@_ZTV1A = internal unnamed_addr constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr null, ptr @_ZN1A3fooEi, ptr @_ZN1A3barEf] }, align 8, !type !0, !type !1, !type !2, !vcall_visibility !3 +; CHECK: @_ZTV1B = internal unnamed_addr constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr null, ptr @_ZN1B3fooEi, ptr null] } +@_ZTV1B = internal unnamed_addr constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr null, ptr @_ZN1B3fooEi, ptr @_ZN1B3barEf] }, align 8, !type !0, !type !1, !type !2, !type !4, !type !5, !type !6, !vcall_visibility !3 ; CHECK-NOT: define internal i32 @_ZN1A3fooEi( -define internal i32 @_ZN1A3fooEi(%struct.A* nocapture readnone %this, i32) unnamed_addr #1 align 2 { +define internal i32 @_ZN1A3fooEi(ptr nocapture readnone %this, i32) unnamed_addr #1 align 2 { entry: ret i32 1 } ; CHECK-NOT: define internal i32 @_ZN1A3barEf( -define internal i32 @_ZN1A3barEf(%struct.A* nocapture readnone %this, float) unnamed_addr #1 align 2 { +define internal i32 @_ZN1A3barEf(ptr nocapture readnone %this, float) unnamed_addr #1 align 2 { entry: ret i32 2 } ; CHECK: define internal i32 @_ZN1B3fooEi( -define internal i32 @_ZN1B3fooEi(%struct.B* nocapture readnone %this, i32) unnamed_addr #1 align 2 { +define internal i32 @_ZN1B3fooEi(ptr nocapture readnone %this, i32) unnamed_addr #1 align 2 { entry: ret i32 3 } ; CHECK-NOT: define internal i32 @_ZN1B3barEf( -define internal i32 @_ZN1B3barEf(%struct.B* nocapture readnone %this, float) unnamed_addr #1 align 2 { +define internal i32 @_ZN1B3barEf(ptr nocapture readnone %this, float) unnamed_addr #1 align 2 { entry: ret i32 4 } -define hidden void @_ZN1AC2Ev(%struct.A* nocapture %this) { +define hidden void @_ZN1AC2Ev(ptr nocapture %this) { entry: - %0 = getelementptr inbounds %struct.A, %struct.A* %this, i64 0, i32 0 - store i32 (...)** bitcast (i8** getelementptr inbounds ({ [4 x i8*] }, { [4 x i8*] }* @_ZTV1A, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8 + store ptr getelementptr inbounds ({ [4 x ptr] }, ptr @_ZTV1A, i64 0, inrange i32 0, i64 2), ptr %this, align 8 ret void } -define hidden void @_ZN1BC2Ev(%struct.B* nocapture %this) { +define hidden void @_ZN1BC2Ev(ptr nocapture %this) { entry: - %0 = getelementptr inbounds %struct.B, %struct.B* %this, i64 0, i32 0, i32 0 - store i32 (...)** bitcast (i8** getelementptr inbounds ({ [4 x i8*] }, { [4 x i8*] }* @_ZTV1B, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8 + store ptr getelementptr inbounds ({ [4 x ptr] }, ptr @_ZTV1B, i64 0, inrange i32 0, i64 2), ptr %this, align 8 ret void } -define hidden i32 @test(%struct.B* %p, i64 %q.coerce0, i64 %q.coerce1) { +define hidden i32 @test(ptr %p, i64 %q.coerce0, i64 %q.coerce1) { entry: - %0 = bitcast %struct.B* %p to i8* - %1 = getelementptr inbounds i8, i8* %0, i64 %q.coerce1 - %this.adjusted = bitcast i8* %1 to %struct.B* - %2 = and i64 %q.coerce0, 1 - %memptr.isvirtual = icmp eq i64 %2, 0 + %0 = getelementptr inbounds i8, ptr %p, i64 %q.coerce1 + %1 = and i64 %q.coerce0, 1 + %memptr.isvirtual = icmp eq i64 %1, 0 br i1 %memptr.isvirtual, label %memptr.nonvirtual, label %memptr.virtual memptr.virtual: ; preds = %entry - %3 = bitcast i8* %1 to i8** - %vtable = load i8*, i8** %3, align 8 - %4 = add i64 %q.coerce0, -1 - %5 = getelementptr i8, i8* %vtable, i64 %4, !nosanitize !12 - %6 = tail call { i8*, i1 } @llvm.type.checked.load(i8* %5, i32 0, metadata !"_ZTSM1BFiiE.virtual"), !nosanitize !12 - %7 = extractvalue { i8*, i1 } %6, 0, !nosanitize !12 - %memptr.virtualfn = bitcast i8* %7 to i32 (%struct.B*, i32)*, !nosanitize !12 + %vtable = load ptr, ptr %0, align 8 + %2 = add i64 %q.coerce0, -1 + %3 = getelementptr i8, ptr %vtable, i64 %2, !nosanitize !12 + %4 = tail call { ptr, i1 } @llvm.type.checked.load(ptr %3, i32 0, metadata !"_ZTSM1BFiiE.virtual"), !nosanitize !12 + %5 = extractvalue { ptr, i1 } %4, 0, !nosanitize !12 br label %memptr.end memptr.nonvirtual: ; preds = %entry - %memptr.nonvirtualfn = inttoptr i64 %q.coerce0 to i32 (%struct.B*, i32)* + %memptr.nonvirtualfn = inttoptr i64 %q.coerce0 to ptr br label %memptr.end memptr.end: ; preds = %memptr.nonvirtual, %memptr.virtual - %8 = phi i32 (%struct.B*, i32)* [ %memptr.virtualfn, %memptr.virtual ], [ %memptr.nonvirtualfn, %memptr.nonvirtual ] - %call = tail call i32 %8(%struct.B* %this.adjusted, i32 42) + %6 = phi ptr [ %5, %memptr.virtual ], [ %memptr.nonvirtualfn, %memptr.nonvirtual ] + %call = tail call i32 %6(ptr %0, i32 42) ret i32 %call } -declare { i8*, i1 } @llvm.type.checked.load(i8*, i32, metadata) +declare { ptr, i1 } @llvm.type.checked.load(ptr, i32, metadata) !llvm.module.flags = !{!7} diff --git a/llvm/test/Transforms/GlobalDCE/virtual-functions-nonptr.ll b/llvm/test/Transforms/GlobalDCE/virtual-functions-nonptr.ll index 695a0b55327f..29fd130aab58 100644 --- a/llvm/test/Transforms/GlobalDCE/virtual-functions-nonptr.ll +++ b/llvm/test/Transforms/GlobalDCE/virtual-functions-nonptr.ll @@ -2,26 +2,26 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" -declare { i8*, i1 } @llvm.type.checked.load(i8*, i32, metadata) +declare { ptr, i1 } @llvm.type.checked.load(ptr, i32, metadata) @vtableA = internal unnamed_addr constant { [2 x i32] } { [2 x i32] [ i32 0, - i32 trunc (i64 sub (i64 ptrtoint (void ()* @vfunc2 to i64), i64 ptrtoint ({ [2 x i32] }* @vtableA to i64)) to i32) + i32 trunc (i64 sub (i64 ptrtoint (ptr @vfunc2 to i64), i64 ptrtoint (ptr @vtableA to i64)) to i32) ]}, align 8, !type !{i64 0, !"vfunc1.type"}, !type !{i64 4, !"vfunc2.type"}, !vcall_visibility !{i64 2} ; CHECK: @vtableA = internal unnamed_addr constant { [2 x i32] } { [2 x i32] [ ; CHECK-SAME: i32 0, -; CHECK-SAME: i32 trunc (i64 sub (i64 ptrtoint (void ()* @vfunc2 to i64), i64 ptrtoint ({ [2 x i32] }* @vtableA to i64)) to i32) +; CHECK-SAME: i32 trunc (i64 sub (i64 ptrtoint (ptr @vfunc2 to i64), i64 ptrtoint (ptr @vtableA to i64)) to i32) ; CHECK-SAME: ] }, align 8 @vtableB = internal unnamed_addr constant { [2 x i32] } { [2 x i32] [ - i32 trunc (i64 sub (i64 ptrtoint (void ()* @vfunc1 to i64), i64 ptrtoint ({ [2 x i32] }* @vtableB to i64)) to i32), - i32 trunc (i64 sub (i64 ptrtoint (void ()* @vfunc2 to i64), i64 ptrtoint ({ [2 x i32] }* @vtableB to i64)) to i32) + i32 trunc (i64 sub (i64 ptrtoint (ptr @vfunc1 to i64), i64 ptrtoint (ptr @vtableB to i64)) to i32), + i32 trunc (i64 sub (i64 ptrtoint (ptr @vfunc2 to i64), i64 ptrtoint (ptr @vtableB to i64)) to i32) ]}, align 8, !type !{i64 0, !"vfunc1.type"}, !type !{i64 4, !"vfunc2.type"}, !vcall_visibility !{i64 2} ; CHECK: @vtableB = internal unnamed_addr constant { [2 x i32] } { [2 x i32] [ -; CHECK-SAME: i32 trunc (i64 sub (i64 ptrtoint (void ()* @vfunc1 to i64), i64 ptrtoint ({ [2 x i32] }* @vtableB to i64)) to i32), -; CHECK-SAME: i32 trunc (i64 sub (i64 ptrtoint (void ()* @vfunc2 to i64), i64 ptrtoint ({ [2 x i32] }* @vtableB to i64)) to i32) +; CHECK-SAME: i32 trunc (i64 sub (i64 ptrtoint (ptr @vfunc1 to i64), i64 ptrtoint (ptr @vtableB to i64)) to i32), +; CHECK-SAME: i32 trunc (i64 sub (i64 ptrtoint (ptr @vfunc2 to i64), i64 ptrtoint (ptr @vtableB to i64)) to i32) ; CHECK-SAME: ] }, align 8 define internal void @vfunc1() { @@ -33,10 +33,10 @@ define internal void @vfunc2() { } define void @main() { - %1 = ptrtoint { [2 x i32] }* @vtableA to i64 ; to keep @vtableA alive - %2 = ptrtoint { [2 x i32] }* @vtableB to i64 ; to keep @vtableB alive - %3 = tail call { i8*, i1 } @llvm.type.checked.load(i8* null, i32 0, metadata !"vfunc1.type") - %4 = tail call { i8*, i1 } @llvm.type.checked.load(i8* null, i32 0, metadata !"vfunc2.type") + %1 = ptrtoint ptr @vtableA to i64 ; to keep @vtableA alive + %2 = ptrtoint ptr @vtableB to i64 ; to keep @vtableB alive + %3 = tail call { ptr, i1 } @llvm.type.checked.load(ptr null, i32 0, metadata !"vfunc1.type") + %4 = tail call { ptr, i1 } @llvm.type.checked.load(ptr null, i32 0, metadata !"vfunc2.type") ret void } diff --git a/llvm/test/Transforms/GlobalDCE/virtual-functions-novfe.ll b/llvm/test/Transforms/GlobalDCE/virtual-functions-novfe.ll index 9491a56d6a64..01475c8911fc 100644 --- a/llvm/test/Transforms/GlobalDCE/virtual-functions-novfe.ll +++ b/llvm/test/Transforms/GlobalDCE/virtual-functions-novfe.ll @@ -4,8 +4,8 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" -declare dso_local noalias nonnull i8* @_Znwm(i64) -declare { i8*, i1 } @llvm.type.checked.load(i8*, i32, metadata) +declare dso_local noalias nonnull ptr @_Znwm(i64) +declare { ptr, i1 } @llvm.type.checked.load(ptr, i32, metadata) ; %struct.A is a C++ struct with two virtual functions, A::foo and A::bar. The ; !vcall_visibility metadata is set on the vtable, so we know that all virtual @@ -15,15 +15,15 @@ declare { i8*, i1 } @llvm.type.checked.load(i8*, i32, metadata) ; null. ; However, with the metadata set to 0 we should not perform this VFE. -%struct.A = type { i32 (...)** } +%struct.A = type { ptr } ; We should retain @_ZN1A3barEv in the vtable. -; CHECK: @_ZTV1A = internal unnamed_addr constant { [4 x i8*] } { [4 x i8*] [i8* null, i8* null, i8* bitcast (i32 (%struct.A*)* @_ZN1A3fooEv to i8*), i8* bitcast (i32 (%struct.A*)* @_ZN1A3barEv to i8*)] } -@_ZTV1A = internal unnamed_addr constant { [4 x i8*] } { [4 x i8*] [i8* null, i8* null, i8* bitcast (i32 (%struct.A*)* @_ZN1A3fooEv to i8*), i8* bitcast (i32 (%struct.A*)* @_ZN1A3barEv to i8*)] }, align 8, !type !0, !type !1, !type !2, !vcall_visibility !3 +; CHECK: @_ZTV1A = internal unnamed_addr constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr null, ptr @_ZN1A3fooEv, ptr @_ZN1A3barEv] } +@_ZTV1A = internal unnamed_addr constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr null, ptr @_ZN1A3fooEv, ptr @_ZN1A3barEv] }, align 8, !type !0, !type !1, !type !2, !vcall_visibility !3 ; A::foo is called, so must be retained. ; CHECK: define internal i32 @_ZN1A3fooEv( -define internal i32 @_ZN1A3fooEv(%struct.A* nocapture readnone %this) { +define internal i32 @_ZN1A3fooEv(ptr nocapture readnone %this) { entry: ret i32 42 } @@ -31,21 +31,18 @@ entry: ; A::bar is not used, so can be deleted with VFE, however, we should not be ; performing that elimination here. ; CHECK: define internal i32 @_ZN1A3barEv( -define internal i32 @_ZN1A3barEv(%struct.A* nocapture readnone %this) { +define internal i32 @_ZN1A3barEv(ptr nocapture readnone %this) { entry: ret i32 1337 } define dso_local i32 @test_A() { entry: - %call = tail call i8* @_Znwm(i64 8) - %0 = bitcast i8* %call to %struct.A* - %1 = bitcast i8* %call to i32 (...)*** - store i32 (...)** bitcast (i8** getelementptr inbounds ({ [4 x i8*] }, { [4 x i8*] }* @_ZTV1A, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %1, align 8 - %2 = tail call { i8*, i1 } @llvm.type.checked.load(i8* bitcast (i8** getelementptr inbounds ({ [4 x i8*] }, { [4 x i8*] }* @_ZTV1A, i64 0, inrange i32 0, i64 2) to i8*), i32 0, metadata !"_ZTS1A"), !nosanitize !9 - %3 = extractvalue { i8*, i1 } %2, 0, !nosanitize !9 - %4 = bitcast i8* %3 to i32 (%struct.A*)*, !nosanitize !9 - %call1 = tail call i32 %4(%struct.A* nonnull %0) + %call = tail call ptr @_Znwm(i64 8) + store ptr getelementptr inbounds ({ [4 x ptr] }, ptr @_ZTV1A, i64 0, inrange i32 0, i64 2), ptr %call, align 8 + %0 = tail call { ptr, i1 } @llvm.type.checked.load(ptr getelementptr inbounds ({ [4 x ptr] }, ptr @_ZTV1A, i64 0, inrange i32 0, i64 2), i32 0, metadata !"_ZTS1A"), !nosanitize !9 + %1 = extractvalue { ptr, i1 } %0, 0, !nosanitize !9 + %call1 = tail call i32 %1(ptr nonnull %call) ret i32 %call1 } diff --git a/llvm/test/Transforms/GlobalDCE/virtual-functions-null.ll b/llvm/test/Transforms/GlobalDCE/virtual-functions-null.ll index 186967b6311a..8dc4512fb1b2 100644 --- a/llvm/test/Transforms/GlobalDCE/virtual-functions-null.ll +++ b/llvm/test/Transforms/GlobalDCE/virtual-functions-null.ll @@ -2,26 +2,26 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" -declare { i8*, i1 } @llvm.type.checked.load(i8*, i32, metadata) +declare { ptr, i1 } @llvm.type.checked.load(ptr, i32, metadata) -@vtableA = internal unnamed_addr constant { [2 x i8*] } { [2 x i8*] [ - i8* null, - i8* bitcast (void ()* @vfunc2 to i8*) +@vtableA = internal unnamed_addr constant { [2 x ptr] } { [2 x ptr] [ + ptr null, + ptr @vfunc2 ]}, align 8, !type !{i64 0, !"vfunc1.type"}, !type !{i64 8, !"vfunc2.type"}, !vcall_visibility !{i64 2} -; CHECK: @vtableA = internal unnamed_addr constant { [2 x i8*] } { [2 x i8*] [ -; CHECK-SAME: i8* null, -; CHECK-SAME: i8* bitcast (void ()* @vfunc2 to i8*) +; CHECK: @vtableA = internal unnamed_addr constant { [2 x ptr] } { [2 x ptr] [ +; CHECK-SAME: ptr null, +; CHECK-SAME: ptr @vfunc2 ; CHECK-SAME: ] }, align 8 -@vtableB = internal unnamed_addr constant { [2 x i8*] } { [2 x i8*] [ - i8* bitcast (void ()* @vfunc1 to i8*), - i8* bitcast (void ()* @vfunc2 to i8*) +@vtableB = internal unnamed_addr constant { [2 x ptr] } { [2 x ptr] [ + ptr @vfunc1, + ptr @vfunc2 ]}, align 8, !type !{i64 0, !"vfunc1.type"}, !type !{i64 8, !"vfunc2.type"}, !vcall_visibility !{i64 2} -; CHECK: @vtableB = internal unnamed_addr constant { [2 x i8*] } { [2 x i8*] [ -; CHECK-SAME: i8* bitcast (void ()* @vfunc1 to i8*), -; CHECK-SAME: i8* bitcast (void ()* @vfunc2 to i8*) +; CHECK: @vtableB = internal unnamed_addr constant { [2 x ptr] } { [2 x ptr] [ +; CHECK-SAME: ptr @vfunc1, +; CHECK-SAME: ptr @vfunc2 ; CHECK-SAME: ] }, align 8 define internal void @vfunc1() { @@ -33,10 +33,10 @@ define internal void @vfunc2() { } define void @main() { - %1 = ptrtoint { [2 x i8*] }* @vtableA to i64 ; to keep @vtableA alive - %2 = ptrtoint { [2 x i8*] }* @vtableB to i64 ; to keep @vtableB alive - %3 = tail call { i8*, i1 } @llvm.type.checked.load(i8* null, i32 0, metadata !"vfunc1.type") - %4 = tail call { i8*, i1 } @llvm.type.checked.load(i8* null, i32 0, metadata !"vfunc2.type") + %1 = ptrtoint ptr @vtableA to i64 ; to keep @vtableA alive + %2 = ptrtoint ptr @vtableB to i64 ; to keep @vtableB alive + %3 = tail call { ptr, i1 } @llvm.type.checked.load(ptr null, i32 0, metadata !"vfunc1.type") + %4 = tail call { ptr, i1 } @llvm.type.checked.load(ptr null, i32 0, metadata !"vfunc2.type") ret void } diff --git a/llvm/test/Transforms/GlobalDCE/virtual-functions-relative-pointers-bad.ll b/llvm/test/Transforms/GlobalDCE/virtual-functions-relative-pointers-bad.ll index a62951d01b98..9d87fdb084a1 100644 --- a/llvm/test/Transforms/GlobalDCE/virtual-functions-relative-pointers-bad.ll +++ b/llvm/test/Transforms/GlobalDCE/virtual-functions-relative-pointers-bad.ll @@ -2,14 +2,14 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" -declare { i8*, i1 } @llvm.type.checked.load(i8*, i32, metadata) +declare { ptr, i1 } @llvm.type.checked.load(ptr, i32, metadata) @vtable = internal unnamed_addr constant { [3 x i32] } { [3 x i32] [ - i32 trunc (i64 sub (i64 ptrtoint (void ()* @vfunc1 to i64), i64 ptrtoint ({ [3 x i32] }* @vtable to i64)) to i32), - i32 trunc (i64 sub (i64 ptrtoint (void ()* @vfunc2 to i64), i64 ptrtoint ({ [3 x i32] }* @vtable to i64)) to i32), + i32 trunc (i64 sub (i64 ptrtoint (ptr @vfunc1 to i64), i64 ptrtoint (ptr @vtable to i64)) to i32), + i32 trunc (i64 sub (i64 ptrtoint (ptr @vfunc2 to i64), i64 ptrtoint (ptr @vtable to i64)) to i32), ; a "bad" relative pointer because it's base is not the @vtable symbol - i32 trunc (i64 sub (i64 ptrtoint (void ()* @weird_ref_1 to i64), i64 ptrtoint (void ()* @weird_ref_2 to i64)) to i32) + i32 trunc (i64 sub (i64 ptrtoint (ptr @weird_ref_1 to i64), i64 ptrtoint (ptr @weird_ref_2 to i64)) to i32) ]}, align 8, !type !0, !type !1, !vcall_visibility !{i64 2} !0 = !{i64 0, !"vfunc1.type"} !1 = !{i64 4, !"vfunc2.type"} @@ -22,7 +22,7 @@ define internal void @weird_ref_1() { ret void } define internal void @weird_ref_2() { ret void } define void @main() { - %1 = ptrtoint { [3 x i32] }* @vtable to i64 ; to keep @vtable alive + %1 = ptrtoint ptr @vtable to i64 ; to keep @vtable alive call void @weird_ref_2() ret void } diff --git a/llvm/test/Transforms/GlobalDCE/virtual-functions-relative-pointers-gep.ll b/llvm/test/Transforms/GlobalDCE/virtual-functions-relative-pointers-gep.ll index 7ec29cc26f13..fb45d37dde6e 100644 --- a/llvm/test/Transforms/GlobalDCE/virtual-functions-relative-pointers-gep.ll +++ b/llvm/test/Transforms/GlobalDCE/virtual-functions-relative-pointers-gep.ll @@ -2,20 +2,20 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" -declare { i8*, i1 } @llvm.type.checked.load(i8*, i32, metadata) +declare { ptr, i1 } @llvm.type.checked.load(ptr, i32, metadata) ; A vtable with "relative pointers", slots don't contain pointers to implementations, but instead have an i32 offset from the vtable itself to the implementation. @vtable = internal unnamed_addr constant { [4 x i32] } { [4 x i32] [ i32 42, i32 1337, - i32 trunc (i64 sub (i64 ptrtoint (void ()* @vfunc1_live to i64), i64 ptrtoint (i32* getelementptr inbounds ({ [4 x i32] }, { [4 x i32] }* @vtable, i32 0, i32 0, i32 2) to i64)) to i32), - i32 trunc (i64 sub (i64 ptrtoint (void ()* @vfunc2_dead to i64), i64 ptrtoint (i32* getelementptr inbounds ({ [4 x i32] }, { [4 x i32] }* @vtable, i32 0, i32 0, i32 2) to i64)) to i32) + i32 trunc (i64 sub (i64 ptrtoint (ptr @vfunc1_live to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [4 x i32] }, ptr @vtable, i32 0, i32 0, i32 2) to i64)) to i32), + i32 trunc (i64 sub (i64 ptrtoint (ptr @vfunc2_dead to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [4 x i32] }, ptr @vtable, i32 0, i32 0, i32 2) to i64)) to i32) ]}, align 8, !type !0, !type !1, !vcall_visibility !{i64 2} !0 = !{i64 8, !"vfunc1.type"} !1 = !{i64 12, !"vfunc2.type"} ; CHECK: @vtable = internal unnamed_addr constant { [4 x i32] } { [4 x i32] [ -; CHECK-SAME: i32 trunc (i64 sub (i64 ptrtoint (void ()* @vfunc1_live to i64), i64 ptrtoint (i32* getelementptr inbounds ({ [4 x i32] }, { [4 x i32] }* @vtable, i32 0, i32 0, i32 2) to i64)) to i32), +; CHECK-SAME: i32 trunc (i64 sub (i64 ptrtoint (ptr @vfunc1_live to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [4 x i32] }, ptr @vtable, i32 0, i32 0, i32 2) to i64)) to i32), ; CHECK-SAME: i32 0 ; CHECK-SAME: ] }, align 8, !type !0, !type !1, !vcall_visibility !2 @@ -32,8 +32,8 @@ define internal void @vfunc2_dead() { } define void @main() { - %1 = ptrtoint { [4 x i32] }* @vtable to i64 ; to keep @vtable alive - %2 = tail call { i8*, i1 } @llvm.type.checked.load(i8* null, i32 0, metadata !"vfunc1.type") + %1 = ptrtoint ptr @vtable to i64 ; to keep @vtable alive + %2 = tail call { ptr, i1 } @llvm.type.checked.load(ptr null, i32 0, metadata !"vfunc1.type") ret void } diff --git a/llvm/test/Transforms/GlobalDCE/virtual-functions-relative-pointers.ll b/llvm/test/Transforms/GlobalDCE/virtual-functions-relative-pointers.ll index 57803997a0b6..76a617ea99e6 100644 --- a/llvm/test/Transforms/GlobalDCE/virtual-functions-relative-pointers.ll +++ b/llvm/test/Transforms/GlobalDCE/virtual-functions-relative-pointers.ll @@ -2,18 +2,18 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" -declare { i8*, i1 } @llvm.type.checked.load(i8*, i32, metadata) +declare { ptr, i1 } @llvm.type.checked.load(ptr, i32, metadata) ; A vtable with "relative pointers", slots don't contain pointers to implementations, but instead have an i32 offset from the vtable itself to the implementation. @vtable = internal unnamed_addr constant { [2 x i32] } { [2 x i32] [ - i32 trunc (i64 sub (i64 ptrtoint (void ()* @vfunc1_live to i64), i64 ptrtoint ({ [2 x i32] }* @vtable to i64)) to i32), - i32 trunc (i64 sub (i64 ptrtoint (void ()* @vfunc2_dead to i64), i64 ptrtoint ({ [2 x i32] }* @vtable to i64)) to i32) + i32 trunc (i64 sub (i64 ptrtoint (ptr @vfunc1_live to i64), i64 ptrtoint (ptr @vtable to i64)) to i32), + i32 trunc (i64 sub (i64 ptrtoint (ptr @vfunc2_dead to i64), i64 ptrtoint (ptr @vtable to i64)) to i32) ]}, align 8, !type !0, !type !1, !vcall_visibility !{i64 2} !0 = !{i64 0, !"vfunc1.type"} !1 = !{i64 4, !"vfunc2.type"} ; CHECK: @vtable = internal unnamed_addr constant { [2 x i32] } { [2 x i32] [ -; CHECK-SAME: i32 trunc (i64 sub (i64 ptrtoint (void ()* @vfunc1_live to i64), i64 ptrtoint ({ [2 x i32] }* @vtable to i64)) to i32), +; CHECK-SAME: i32 trunc (i64 sub (i64 ptrtoint (ptr @vfunc1_live to i64), i64 ptrtoint (ptr @vtable to i64)) to i32), ; CHECK-SAME: i32 0 ; CHECK-SAME: ] }, align 8, !type !0, !type !1, !vcall_visibility !2 @@ -30,8 +30,8 @@ define internal void @vfunc2_dead() { } define void @main() { - %1 = ptrtoint { [2 x i32] }* @vtable to i64 ; to keep @vtable alive - %2 = tail call { i8*, i1 } @llvm.type.checked.load(i8* null, i32 0, metadata !"vfunc1.type") + %1 = ptrtoint ptr @vtable to i64 ; to keep @vtable alive + %2 = tail call { ptr, i1 } @llvm.type.checked.load(ptr null, i32 0, metadata !"vfunc1.type") ret void } diff --git a/llvm/test/Transforms/GlobalDCE/virtual-functions-visibility-post-lto.ll b/llvm/test/Transforms/GlobalDCE/virtual-functions-visibility-post-lto.ll index 8a450fb6dc0a..7cb2a9601945 100644 --- a/llvm/test/Transforms/GlobalDCE/virtual-functions-visibility-post-lto.ll +++ b/llvm/test/Transforms/GlobalDCE/virtual-functions-visibility-post-lto.ll @@ -6,84 +6,78 @@ target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" -%struct.A = type { i32 (...)** } +%struct.A = type { ptr } -@_ZTV1A = hidden unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* null, i8* bitcast (void (%struct.A*)* @_ZN1A3fooEv to i8*)] }, align 8, !type !0, !type !1, !vcall_visibility !2 +@_ZTV1A = hidden unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr @_ZN1A3fooEv] }, align 8, !type !0, !type !1, !vcall_visibility !2 -define internal void @_ZN1AC2Ev(%struct.A* %this) { +define internal void @_ZN1AC2Ev(ptr %this) { entry: - %0 = getelementptr inbounds %struct.A, %struct.A* %this, i64 0, i32 0 - store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV1A, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8 + store ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTV1A, i64 0, inrange i32 0, i64 2), ptr %this, align 8 ret void } ; CHECK: define {{.*}} @_ZN1A3fooEv( -define internal void @_ZN1A3fooEv(%struct.A* nocapture %this) { +define internal void @_ZN1A3fooEv(ptr nocapture %this) { entry: ret void } -define dso_local i8* @_Z6make_Av() { +define dso_local ptr @_Z6make_Av() { entry: - %call = tail call i8* @_Znwm(i64 8) - %0 = bitcast i8* %call to %struct.A* - tail call void @_ZN1AC2Ev(%struct.A* %0) - ret i8* %call + %call = tail call ptr @_Znwm(i64 8) + tail call void @_ZN1AC2Ev(ptr %call) + ret ptr %call } -%struct.B = type { i32 (...)** } +%struct.B = type { ptr } -@_ZTV1B = hidden unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* null, i8* bitcast (void (%struct.B*)* @_ZN1B3fooEv to i8*)] }, align 8, !type !0, !type !1, !vcall_visibility !3 +@_ZTV1B = hidden unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr @_ZN1B3fooEv] }, align 8, !type !0, !type !1, !vcall_visibility !3 -define internal void @_ZN1BC2Ev(%struct.B* %this) { +define internal void @_ZN1BC2Ev(ptr %this) { entry: - %0 = getelementptr inbounds %struct.B, %struct.B* %this, i64 0, i32 0 - store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV1B, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8 + store ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTV1B, i64 0, inrange i32 0, i64 2), ptr %this, align 8 ret void } ; CHECK-NOT: define {{.*}} @_ZN1B3fooEv( -define internal void @_ZN1B3fooEv(%struct.B* nocapture %this) { +define internal void @_ZN1B3fooEv(ptr nocapture %this) { entry: ret void } -define dso_local i8* @_Z6make_Bv() { +define dso_local ptr @_Z6make_Bv() { entry: - %call = tail call i8* @_Znwm(i64 8) - %0 = bitcast i8* %call to %struct.B* - tail call void @_ZN1BC2Ev(%struct.B* %0) - ret i8* %call + %call = tail call ptr @_Znwm(i64 8) + tail call void @_ZN1BC2Ev(ptr %call) + ret ptr %call } -%struct.C = type { i32 (...)** } +%struct.C = type { ptr } -@_ZTV1C = hidden unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* null, i8* bitcast (void (%struct.C*)* @_ZN1C3fooEv to i8*)] }, align 8, !type !0, !type !1, !vcall_visibility !4 +@_ZTV1C = hidden unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr @_ZN1C3fooEv] }, align 8, !type !0, !type !1, !vcall_visibility !4 -define internal void @_ZN1CC2Ev(%struct.C* %this) { +define internal void @_ZN1CC2Ev(ptr %this) { entry: - %0 = getelementptr inbounds %struct.C, %struct.C* %this, i64 0, i32 0 - store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV1C, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8 + store ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTV1C, i64 0, inrange i32 0, i64 2), ptr %this, align 8 ret void } ; CHECK-NOT: define {{.*}} @_ZN1C3fooEv( -define internal void @_ZN1C3fooEv(%struct.C* nocapture %this) { +define internal void @_ZN1C3fooEv(ptr nocapture %this) { entry: ret void } -define dso_local i8* @_Z6make_Cv() { +define dso_local ptr @_Z6make_Cv() { entry: - %call = tail call i8* @_Znwm(i64 8) - %0 = bitcast i8* %call to %struct.C* - tail call void @_ZN1CC2Ev(%struct.C* %0) - ret i8* %call + %call = tail call ptr @_Znwm(i64 8) + tail call void @_ZN1CC2Ev(ptr %call) + ret ptr %call } -declare dso_local noalias nonnull i8* @_Znwm(i64) +declare dso_local noalias nonnull ptr @_Znwm(i64) !llvm.module.flags = !{!5, !6} diff --git a/llvm/test/Transforms/GlobalDCE/virtual-functions-visibility-pre-lto.ll b/llvm/test/Transforms/GlobalDCE/virtual-functions-visibility-pre-lto.ll index 1378f84e3d6b..65d83311b421 100644 --- a/llvm/test/Transforms/GlobalDCE/virtual-functions-visibility-pre-lto.ll +++ b/llvm/test/Transforms/GlobalDCE/virtual-functions-visibility-pre-lto.ll @@ -6,84 +6,78 @@ target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" -%struct.A = type { i32 (...)** } +%struct.A = type { ptr } -@_ZTV1A = hidden unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* null, i8* bitcast (void (%struct.A*)* @_ZN1A3fooEv to i8*)] }, align 8, !type !0, !type !1, !vcall_visibility !2 +@_ZTV1A = hidden unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr @_ZN1A3fooEv] }, align 8, !type !0, !type !1, !vcall_visibility !2 -define internal void @_ZN1AC2Ev(%struct.A* %this) { +define internal void @_ZN1AC2Ev(ptr %this) { entry: - %0 = getelementptr inbounds %struct.A, %struct.A* %this, i64 0, i32 0 - store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV1A, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8 + store ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTV1A, i64 0, inrange i32 0, i64 2), ptr %this, align 8 ret void } ; CHECK: define {{.*}} @_ZN1A3fooEv( -define internal void @_ZN1A3fooEv(%struct.A* nocapture %this) { +define internal void @_ZN1A3fooEv(ptr nocapture %this) { entry: ret void } -define dso_local i8* @_Z6make_Av() { +define dso_local ptr @_Z6make_Av() { entry: - %call = tail call i8* @_Znwm(i64 8) - %0 = bitcast i8* %call to %struct.A* - tail call void @_ZN1AC2Ev(%struct.A* %0) - ret i8* %call + %call = tail call ptr @_Znwm(i64 8) + tail call void @_ZN1AC2Ev(ptr %call) + ret ptr %call } -%struct.B = type { i32 (...)** } +%struct.B = type { ptr } -@_ZTV1B = hidden unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* null, i8* bitcast (void (%struct.B*)* @_ZN1B3fooEv to i8*)] }, align 8, !type !0, !type !1, !vcall_visibility !3 +@_ZTV1B = hidden unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr @_ZN1B3fooEv] }, align 8, !type !0, !type !1, !vcall_visibility !3 -define internal void @_ZN1BC2Ev(%struct.B* %this) { +define internal void @_ZN1BC2Ev(ptr %this) { entry: - %0 = getelementptr inbounds %struct.B, %struct.B* %this, i64 0, i32 0 - store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV1B, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8 + store ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTV1B, i64 0, inrange i32 0, i64 2), ptr %this, align 8 ret void } ; CHECK: define {{.*}} @_ZN1B3fooEv( -define internal void @_ZN1B3fooEv(%struct.B* nocapture %this) { +define internal void @_ZN1B3fooEv(ptr nocapture %this) { entry: ret void } -define dso_local i8* @_Z6make_Bv() { +define dso_local ptr @_Z6make_Bv() { entry: - %call = tail call i8* @_Znwm(i64 8) - %0 = bitcast i8* %call to %struct.B* - tail call void @_ZN1BC2Ev(%struct.B* %0) - ret i8* %call + %call = tail call ptr @_Znwm(i64 8) + tail call void @_ZN1BC2Ev(ptr %call) + ret ptr %call } -%struct.C = type { i32 (...)** } +%struct.C = type { ptr } -@_ZTV1C = hidden unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* null, i8* bitcast (void (%struct.C*)* @_ZN1C3fooEv to i8*)] }, align 8, !type !0, !type !1, !vcall_visibility !4 +@_ZTV1C = hidden unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr @_ZN1C3fooEv] }, align 8, !type !0, !type !1, !vcall_visibility !4 -define internal void @_ZN1CC2Ev(%struct.C* %this) { +define internal void @_ZN1CC2Ev(ptr %this) { entry: - %0 = getelementptr inbounds %struct.C, %struct.C* %this, i64 0, i32 0 - store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV1C, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8 + store ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTV1C, i64 0, inrange i32 0, i64 2), ptr %this, align 8 ret void } ; CHECK-NOT: define {{.*}} @_ZN1C3fooEv( -define internal void @_ZN1C3fooEv(%struct.C* nocapture %this) { +define internal void @_ZN1C3fooEv(ptr nocapture %this) { entry: ret void } -define dso_local i8* @_Z6make_Cv() { +define dso_local ptr @_Z6make_Cv() { entry: - %call = tail call i8* @_Znwm(i64 8) - %0 = bitcast i8* %call to %struct.C* - tail call void @_ZN1CC2Ev(%struct.C* %0) - ret i8* %call + %call = tail call ptr @_Znwm(i64 8) + tail call void @_ZN1CC2Ev(ptr %call) + ret ptr %call } -declare dso_local noalias nonnull i8* @_Znwm(i64) +declare dso_local noalias nonnull ptr @_Znwm(i64) !llvm.module.flags = !{!5} diff --git a/llvm/test/Transforms/GlobalDCE/virtual-functions.ll b/llvm/test/Transforms/GlobalDCE/virtual-functions.ll index 7b349c539aea..e00f8a7fdfec 100644 --- a/llvm/test/Transforms/GlobalDCE/virtual-functions.ll +++ b/llvm/test/Transforms/GlobalDCE/virtual-functions.ll @@ -2,8 +2,8 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" -declare dso_local noalias nonnull i8* @_Znwm(i64) -declare { i8*, i1 } @llvm.type.checked.load(i8*, i32, metadata) +declare dso_local noalias nonnull ptr @_Znwm(i64) +declare { ptr, i1 } @llvm.type.checked.load(ptr, i32, metadata) ; %struct.A is a C++ struct with two virtual functions, A::foo and A::bar. The ; !vcall_visibility metadata is set on the vtable, so we know that all virtual @@ -12,39 +12,36 @@ declare { i8*, i1 } @llvm.type.checked.load(i8*, i32, metadata) ; A::bar anywhere, so A::bar can be deleted, and its vtable slot replaced with ; null. -%struct.A = type { i32 (...)** } +%struct.A = type { ptr } ; The pointer to A::bar in the vtable can be removed, because it will never be ; loaded. We replace it with null to keep the layout the same. Because it is at ; the end of the vtable we could potentially shrink the vtable, but don't ; currently do that. -; CHECK: @_ZTV1A = internal unnamed_addr constant { [4 x i8*] } { [4 x i8*] [i8* null, i8* null, i8* bitcast (i32 (%struct.A*)* @_ZN1A3fooEv to i8*), i8* null] } -@_ZTV1A = internal unnamed_addr constant { [4 x i8*] } { [4 x i8*] [i8* null, i8* null, i8* bitcast (i32 (%struct.A*)* @_ZN1A3fooEv to i8*), i8* bitcast (i32 (%struct.A*)* @_ZN1A3barEv to i8*)] }, align 8, !type !0, !type !1, !type !2, !vcall_visibility !3 +; CHECK: @_ZTV1A = internal unnamed_addr constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr null, ptr @_ZN1A3fooEv, ptr null] } +@_ZTV1A = internal unnamed_addr constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr null, ptr @_ZN1A3fooEv, ptr @_ZN1A3barEv] }, align 8, !type !0, !type !1, !type !2, !vcall_visibility !3 ; A::foo is called, so must be retained. ; CHECK: define internal i32 @_ZN1A3fooEv( -define internal i32 @_ZN1A3fooEv(%struct.A* nocapture readnone %this) { +define internal i32 @_ZN1A3fooEv(ptr nocapture readnone %this) { entry: ret i32 42 } ; A::bar is not used, so can be deleted. ; CHECK-NOT: define internal i32 @_ZN1A3barEv( -define internal i32 @_ZN1A3barEv(%struct.A* nocapture readnone %this) { +define internal i32 @_ZN1A3barEv(ptr nocapture readnone %this) { entry: ret i32 1337 } define dso_local i32 @test_A() { entry: - %call = tail call i8* @_Znwm(i64 8) - %0 = bitcast i8* %call to %struct.A* - %1 = bitcast i8* %call to i32 (...)*** - store i32 (...)** bitcast (i8** getelementptr inbounds ({ [4 x i8*] }, { [4 x i8*] }* @_ZTV1A, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %1, align 8 - %2 = tail call { i8*, i1 } @llvm.type.checked.load(i8* bitcast (i8** getelementptr inbounds ({ [4 x i8*] }, { [4 x i8*] }* @_ZTV1A, i64 0, inrange i32 0, i64 2) to i8*), i32 0, metadata !"_ZTS1A"), !nosanitize !9 - %3 = extractvalue { i8*, i1 } %2, 0, !nosanitize !9 - %4 = bitcast i8* %3 to i32 (%struct.A*)*, !nosanitize !9 - %call1 = tail call i32 %4(%struct.A* nonnull %0) + %call = tail call ptr @_Znwm(i64 8) + store ptr getelementptr inbounds ({ [4 x ptr] }, ptr @_ZTV1A, i64 0, inrange i32 0, i64 2), ptr %call, align 8 + %0 = tail call { ptr, i1 } @llvm.type.checked.load(ptr getelementptr inbounds ({ [4 x ptr] }, ptr @_ZTV1A, i64 0, inrange i32 0, i64 2), i32 0, metadata !"_ZTS1A"), !nosanitize !9 + %1 = extractvalue { ptr, i1 } %0, 0, !nosanitize !9 + %call1 = tail call i32 %1(ptr nonnull %call) ret i32 %call1 } diff --git a/llvm/test/Transforms/GlobalDCE/vtable-rtti.ll b/llvm/test/Transforms/GlobalDCE/vtable-rtti.ll index 49a2a77b33e1..e54d9a1446c9 100644 --- a/llvm/test/Transforms/GlobalDCE/vtable-rtti.ll +++ b/llvm/test/Transforms/GlobalDCE/vtable-rtti.ll @@ -6,38 +6,36 @@ target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" -%struct.A = type { i32 (...)** } +%struct.A = type { ptr } -; CHECK: @_ZTV1A = hidden unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI1A to i8*), i8* null] }, align 8, !type !0, !type !1, !vcall_visibility !2 +; CHECK: @_ZTV1A = hidden unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTI1A, ptr null] }, align 8, !type !0, !type !1, !vcall_visibility !2 -@_ZTV1A = hidden unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI1A to i8*), i8* bitcast (void (%struct.A*)* @_ZN1A3fooEv to i8*)] }, align 8, !type !0, !type !1, !vcall_visibility !2 +@_ZTV1A = hidden unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTI1A, ptr @_ZN1A3fooEv] }, align 8, !type !0, !type !1, !vcall_visibility !2 @_ZTS1A = hidden constant [3 x i8] c"1A\00", align 1 -@_ZTI1A = hidden constant { i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv117__class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @_ZTS1A, i32 0, i32 0) }, align 8 +@_ZTI1A = hidden constant { ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), ptr @_ZTS1A }, align 8 -define internal void @_ZN1AC2Ev(%struct.A* %this) { +define internal void @_ZN1AC2Ev(ptr %this) { entry: - %0 = getelementptr inbounds %struct.A, %struct.A* %this, i64 0, i32 0 - store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV1A, i64 0, inrange i32 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8 + store ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTV1A, i64 0, inrange i32 0, i64 2), ptr %this, align 8 ret void } ; CHECK-NOT: define {{.*}} @_ZN1A3fooEv( -define internal void @_ZN1A3fooEv(%struct.A* nocapture %this) { +define internal void @_ZN1A3fooEv(ptr nocapture %this) { entry: ret void } -define dso_local i8* @_Z6make_Av() { +define dso_local ptr @_Z6make_Av() { entry: - %call = tail call i8* @_Znwm(i64 8) - %0 = bitcast i8* %call to %struct.A* - tail call void @_ZN1AC2Ev(%struct.A* %0) - ret i8* %call + %call = tail call ptr @_Znwm(i64 8) + tail call void @_ZN1AC2Ev(ptr %call) + ret ptr %call } -declare dso_local noalias nonnull i8* @_Znwm(i64) -@_ZTVN10__cxxabiv117__class_type_infoE = external dso_local global i8* +declare dso_local noalias nonnull ptr @_Znwm(i64) +@_ZTVN10__cxxabiv117__class_type_infoE = external dso_local global ptr !llvm.module.flags = !{!3, !4}