From: Daniel Neilson Date: Fri, 13 Oct 2017 15:59:13 +0000 (+0000) Subject: [RS4GC] Look through vector bitcasts when looking for base pointer X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=043ceffa29cd0673aecc3b568442096fd7ac9b06;p=llvm [RS4GC] Look through vector bitcasts when looking for base pointer Summary: In RS4GC it is possible that a base pointer is contained in a vector that has undergone a bitcast from one element-pointertype to another. We teach RS4GC how to look through bitcasts of vector types when looking for a base pointer. Reviewers: anna Reviewed By: anna Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D38849 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315694 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp index 4b8ddb7cc24..1ca77cfec32 100644 --- a/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp +++ b/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp @@ -421,6 +421,11 @@ findBaseDefiningValueOfVector(Value *I) { if (auto *GEP = dyn_cast(I)) return findBaseDefiningValue(GEP->getPointerOperand()); + // If the pointer comes through a bitcast of a vector of pointers to + // a vector of another type of pointer, then look through the bitcast + if (auto *BC = dyn_cast(I)) + return findBaseDefiningValue(BC->getOperand(0)); + // A PHI or Select is a base defining value. The outer findBasePointer // algorithm is responsible for constructing a base value for this BDV. assert((isa(I) || isa(I)) && diff --git a/test/Transforms/RewriteStatepointsForGC/vector-bitcast.ll b/test/Transforms/RewriteStatepointsForGC/vector-bitcast.ll new file mode 100644 index 00000000000..981942a91ee --- /dev/null +++ b/test/Transforms/RewriteStatepointsForGC/vector-bitcast.ll @@ -0,0 +1,26 @@ +; RUN: opt -S -rewrite-statepoints-for-gc < %s | FileCheck %s +; +; A test to make sure that we can look through bitcasts of +; vector types when a base pointer is contained in a vector. + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:1" +target triple = "x86_64-unknown-linux-gnu" + +; Function Attrs: uwtable +define void @test() gc "statepoint-example" { +; CHECK-LABEL: @test +entry: +; CHECK-LABEL: entry +; CHECK: %bc = bitcast +; CHECK: %[[p1:[A-Za-z0-9_]+]] = extractelement +; CHECK: %[[p2:[A-Za-z0-9_]+]] = extractelement +; CHECK: llvm.experimental.gc.statepoint +; CHECK: %[[p2]].relocated = {{.+}} @llvm.experimental.gc.relocate +; CHECK: %[[p1]].relocated = {{.+}} @llvm.experimental.gc.relocate +; CHECK: load atomic + %bc = bitcast <8 x i8 addrspace(1)*> undef to <8 x i32 addrspace(1)*> + %ptr= extractelement <8 x i32 addrspace(1)*> %bc, i32 7 + %0 = call i8 addrspace(1)* undef() [ "deopt"() ] + %1 = load atomic i32, i32 addrspace(1)* %ptr unordered, align 4 + unreachable +}