Skip to content

Commit 127d582

Browse files
author
Greg Roth
committed
Make GV removal more robust add opt dxil-op-lower test
1 parent d013656 commit 127d582

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

llvm/lib/Target/DirectX/DXILOpLowering.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,13 @@ class OpLowerer {
209209
void removeResourceGlobals(CallInst *CI) {
210210
for (User *User : make_early_inc_range(CI->users())) {
211211
if(StoreInst *Store = dyn_cast<StoreInst>(User)) {
212-
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(Store->getOperand(1))) {
213-
Store->eraseFromParent();
214-
assert(GV->use_empty() && "Buffer global still has users");
215-
GV->removeDeadConstantUsers();
216-
GV->eraseFromParent();
217-
}
212+
Value *V = Store->getOperand(1);
213+
Store->eraseFromParent();
214+
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(V))
215+
if(GV->use_empty()) {
216+
GV->removeDeadConstantUsers();
217+
GV->eraseFromParent();
218+
}
218219
}
219220
}
220221
}

llvm/test/CodeGen/DirectX/ResourceGlobalElimination.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
; RUN: opt -S -passes='early-cse<memssa>' %s -o %t
22
; RUN: FileCheck --check-prefixes=CSE,CHECK %s < %t
33
; finish compiling to verify that dxil-op-lower removes the globals entirely
4+
; RUN: opt -S -dxil-op-lower %t -o - | FileCheck --check-prefixes=LLC,CHECK %s
45
; RUN: llc -mtriple=dxil-pc-shadermodel6.0-compute --filetype=asm -o - %t | FileCheck --check-prefixes=LLC,CHECK %s
56
; RUN: llc -mtriple=dxil-pc-shadermodel6.6-compute --filetype=asm -o - %t | FileCheck --check-prefixes=LLC,CHECK %s
67

0 commit comments

Comments
 (0)