Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only strip invariant.load from special pointers #57386

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/llvm-late-gc-lowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1979,8 +1979,10 @@ bool LateLowerGCFrame::CleanupIR(Function &F, State *S, bool *CFGModified) {
// strip all constant alias information, as it might depend on the gc having
// preserved a gc root, which stops being true after this pass (#32215)
// similar to RewriteStatepointsForGC::stripNonValidData, but less aggressive
if (I->getMetadata(LLVMContext::MD_invariant_load))
I->setMetadata(LLVMContext::MD_invariant_load, NULL);
if (auto *LI = dyn_cast<LoadInst>(I)){
if (isSpecialPtr(LI->getPointerOperand()->getType()) && LI->getMetadata(LLVMContext::MD_invariant_load))
LI->setMetadata(LLVMContext::MD_invariant_load, NULL);
}
if (MDNode *TBAA = I->getMetadata(LLVMContext::MD_tbaa)) {
if (TBAA->getNumOperands() == 4 && isTBAA(TBAA, {"jtbaa_const", "jtbaa_memoryptr", "jtbaa_memorylen", "tbaa_memoryown"})) {
MDNode *MutableTBAA = createMutableTBAAAccessTag(TBAA);
Expand Down
14 changes: 14 additions & 0 deletions test/llvmpasses/late-lower-gc.ll
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,20 @@ top:
ret void
}

; Confirm that `invariant.load` on other loads survive
define void @gc_keep_invariant(float addrspace(1)* %0) {
top:
; CHECK-LABEL: @gc_keep_invariant
%pgcstack = call {}*** @julia.get_pgcstack()
%1 = bitcast {}*** %pgcstack to {}**
%current_task = getelementptr inbounds {}*, {}** %1, i64 -12

; CHECK: %current_task = getelementptr inbounds ptr, ptr %1, i64 -12
%2 = load float, ptr addrspace(1) %0, align 4, !invariant.load !1
; CHECK-NEXT: %2 = load float, ptr addrspace(1) %0, align 4, !invariant.load
ret void
}

define i32 @callee_root({} addrspace(10)* %v0, {} addrspace(10)* %v1) {
top:
; CHECK-LABEL: @callee_root
Expand Down