Skip to content

Commit

Permalink
Handle freeze instruction in FindBaseValue (JuliaLang#43728)
Browse files Browse the repository at this point in the history
  • Loading branch information
vchuravy authored and LilithHafner committed Feb 22, 2022
1 parent 9021ae8 commit 20bc09e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/llvm-late-gc-lowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,8 @@ static std::pair<Value*,int> FindBaseValue(const State &S, Value *V, bool UseCac
if (getValueAddrSpace(NewV) == 0)
break;
CurrentV = NewV;
} else if (auto *Freeze = dyn_cast<FreezeInst>(CurrentV)) {
CurrentV = Freeze->getOperand(0); // Can be formed by optimizations, treat as a no-op
} else if (auto *GEP = dyn_cast<GetElementPtrInst>(CurrentV)) {
CurrentV = GEP->getOperand(0);
// GEP can make vectors from a single base pointer
Expand Down
19 changes: 19 additions & 0 deletions test/llvmpasses/late-lower-gc.ll
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,25 @@ top:
; CHECK: ret i32
}

define i32 @freeze({} addrspace(10)* %v0, {} addrspace(10)* %v1) {
top:
; CHECK-LABEL: @freeze
; CHECK-NOT: @julia.new_gc_frame
%v2 = call {}*** @julia.get_pgcstack()
%v3 = bitcast {} addrspace(10)* %v0 to {} addrspace(10)* addrspace(10)*
%v4 = addrspacecast {} addrspace(10)* addrspace(10)* %v3 to {} addrspace(10)* addrspace(11)*
%v5 = load atomic {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %v4 unordered, align 8
%v6 = bitcast {} addrspace(10)* %v1 to {} addrspace(10)* addrspace(10)*
%v7 = addrspacecast {} addrspace(10)* addrspace(10)* %v6 to {} addrspace(10)* addrspace(11)*
%v8 = load atomic {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %v7 unordered, align 8
%fv8 = freeze {} addrspace(10)* %v8
%v9 = addrspacecast {} addrspace(10)* %v5 to {} addrspace(12)*
%v10 = addrspacecast {} addrspace(10)* %fv8 to {} addrspace(12)*
%v11 = call i32 @rooting_callee({} addrspace(12)* %v9, {} addrspace(12)* %v10)
ret i32 %v11
; CHECK: ret i32
}

!0 = !{i64 0, i64 23}
!1 = !{}
!2 = distinct !{!2}
Expand Down

0 comments on commit 20bc09e

Please sign in to comment.