From a42b0ca3b82f18803fc8a3135a13dd75ef77e8d0 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Sat, 26 Nov 2022 10:54:38 -0500 Subject: [PATCH] SpeculativeExecution: Convert tests to opaque pointers --- .../Transforms/SpeculativeExecution/PR46267.ll | 36 ++++++++++------------ .../Transforms/SpeculativeExecution/spec-casts.ll | 6 ++-- llvm/test/Transforms/SpeculativeExecution/spec.ll | 8 ++--- 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/llvm/test/Transforms/SpeculativeExecution/PR46267.ll b/llvm/test/Transforms/SpeculativeExecution/PR46267.ll index fcf34f3..98352af 100644 --- a/llvm/test/Transforms/SpeculativeExecution/PR46267.ll +++ b/llvm/test/Transforms/SpeculativeExecution/PR46267.ll @@ -1,33 +1,29 @@ ; RUN: opt < %s -S -passes='speculative-execution' | FileCheck %s -%class.B = type { i32 (...)** } +%class.B = type { ptr } ; Testing that two bitcasts are not hoisted to the first BB -define i8* @foo(%class.B* readonly %b) { +define ptr @foo(ptr readonly %b) { ; CHECK-LABEL: foo ; CHECK-LABEL: entry -; CHECK-NEXT: %i = icmp eq %class.B* %b, null +; CHECK-NEXT: %i = icmp eq ptr %b, null ; CHECK-NEXT: br i1 %i, label %end, label %notnull entry: - %i = icmp eq %class.B* %b, null + %i = icmp eq ptr %b, null br i1 %i, label %end, label %notnull ; CHECK-LABEL: notnull: -; CHECK-NEXT: %i1 = bitcast %class.B* %b to i32** -; CHECK: %i3 = bitcast %class.B* %b to i8* notnull: ; preds = %entry - %i1 = bitcast %class.B* %b to i32** - %vtable = load i32*, i32** %i1, align 8 - %i2 = getelementptr inbounds i32, i32* %vtable, i64 -2 - %offset.to.top = load i32, i32* %i2, align 4 - %i3 = bitcast %class.B* %b to i8* + %vtable = load ptr, ptr %b, align 8 + %i2 = getelementptr inbounds i32, ptr %vtable, i64 -2 + %offset.to.top = load i32, ptr %i2, align 4 %i4 = sext i32 %offset.to.top to i64 - %i5 = getelementptr inbounds i8, i8* %i3, i64 %i4 + %i5 = getelementptr inbounds i8, ptr %b, i64 %i4 br label %end end: ; preds = %notnull, %entry - %i6 = phi i8* [ %i5, %notnull ], [ null, %entry ] - ret i8* %i6 + %i6 = phi ptr [ %i5, %notnull ], [ null, %entry ] + ret ptr %i6 } define void @f(i32 %i) { @@ -41,18 +37,18 @@ land.rhs: ; preds = %entry ; CHECK: land.rhs: ; CHECK-NEXT: call void @llvm.dbg.label ; CHECK-NEXT: %x = alloca i32, align 4 -; CHECK-NEXT: call void @llvm.dbg.addr(metadata i32* %x +; CHECK-NEXT: call void @llvm.dbg.addr(metadata ptr %x ; CHECK-NEXT: %y = alloca i32, align 4 -; CHECK-NEXT: call void @llvm.dbg.declare(metadata i32* %y -; CHECK-NEXT: %a0 = load i32, i32* undef, align 1 +; CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %y +; CHECK-NEXT: %a0 = load i32, ptr undef, align 1 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 %a0 call void @llvm.dbg.label(metadata !11), !dbg !10 %x = alloca i32, align 4 - call void @llvm.dbg.addr(metadata i32* %x, metadata !12, metadata !DIExpression()), !dbg !10 + call void @llvm.dbg.addr(metadata ptr %x, metadata !12, metadata !DIExpression()), !dbg !10 %y = alloca i32, align 4 - call void @llvm.dbg.declare(metadata i32* %y, metadata !14, metadata !DIExpression()), !dbg !10 + call void @llvm.dbg.declare(metadata ptr %y, metadata !14, metadata !DIExpression()), !dbg !10 - %a0 = load i32, i32* undef, align 1 + %a0 = load i32, ptr undef, align 1 call void @llvm.dbg.value(metadata i32 %a0, metadata !9, metadata !DIExpression()), !dbg !10 %a2 = add i32 %i, 0 diff --git a/llvm/test/Transforms/SpeculativeExecution/spec-casts.ll b/llvm/test/Transforms/SpeculativeExecution/spec-casts.ll index 396f7ab..c966bed 100644 --- a/llvm/test/Transforms/SpeculativeExecution/spec-casts.ll +++ b/llvm/test/Transforms/SpeculativeExecution/spec-casts.ll @@ -23,7 +23,7 @@ define void @ifThen_ptrtoint() { br i1 true, label %a, label %b a: - %x = ptrtoint i32* undef to i64 + %x = ptrtoint ptr undef to i64 br label %b b: @@ -37,7 +37,7 @@ define void @ifThen_inttoptr() { br i1 true, label %a, label %b a: - %x = inttoptr i64 undef to i32* + %x = inttoptr i64 undef to ptr br label %b b: @@ -50,7 +50,7 @@ b: define void @ifThen_addrspacecast() { br i1 true, label %a, label %b a: - %x = addrspacecast i32* undef to i32 addrspace(1)* + %x = addrspacecast ptr undef to ptr addrspace(1) br label %b b: diff --git a/llvm/test/Transforms/SpeculativeExecution/spec.ll b/llvm/test/Transforms/SpeculativeExecution/spec.ll index 3150e5b..9f409eb 100644 --- a/llvm/test/Transforms/SpeculativeExecution/spec.ll +++ b/llvm/test/Transforms/SpeculativeExecution/spec.ll @@ -108,7 +108,7 @@ define void @doNotHoistPastDef() { ; CHECK: a: a: ; CHECK: %def = load - %def = load i32, i32* null + %def = load i32, ptr null ; CHECK: %use = add %use = add i32 %def, 0 br label %b @@ -124,7 +124,7 @@ define void @nothingToSpeculate() { ; CHECK: a: a: ; CHECK: %def = load - %def = load i32, i32* null + %def = load i32, ptr null br label %b ; CHECK: b: b: @@ -135,7 +135,7 @@ b: define void @hoistIfNotPastDef() { ; CHECK-LABEL: @hoistIfNotPastDef( ; CHECK: %x = load - %x = load i32, i32* null + %x = load i32, ptr null ; CHECK: %y = add i32 %x, 1 ; CHECK: %z = add i32 %y, 1 ; CHECK: br @@ -181,7 +181,7 @@ define void @tooMuchLeftBehind() { ; CHECK: a: a: ; CHECK: %x = load - %x = load i32, i32* null + %x = load i32, ptr null ; CHECK: %r1 = add %r1 = add i32 %x, 1 ; CHECK: %r2 = add -- 2.7.4