Skip to content

Commit 2ac7284

Browse files
committed
Address comments
1 parent d2f17eb commit 2ac7284

File tree

3 files changed

+24
-25
lines changed

3 files changed

+24
-25
lines changed

llvm/include/llvm/Analysis/DXILResource.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,10 +448,10 @@ class DXILBindingMap {
448448

449449
/// Resolves a resource handle into a vector of ResourceBindingInfos that
450450
/// represent the possible unique creations of the handle. Certain cases are
451-
/// ambiguous so mulitple creation points may be returned. The resulting
451+
/// ambiguous so mulitple creation instructions may be returned. The resulting
452452
/// ResourceBindingInfo can be used to depuplicate unique handles that
453453
/// reference the same resource
454-
SmallVector<dxil::ResourceBindingInfo> findByUse(const Value *Key) const;
454+
SmallVector<dxil::ResourceBindingInfo> findCreationInfo(const Value *Key) const;
455455

456456
const_iterator find(const CallInst *Key) const {
457457
auto Pos = CallMap.find(Key);

llvm/lib/Analysis/DXILResource.cpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -771,11 +771,11 @@ void DXILBindingMap::print(raw_ostream &OS, DXILResourceTypeMap &DRTM,
771771
}
772772

773773
SmallVector<dxil::ResourceBindingInfo>
774-
DXILBindingMap::findByUse(const Value *Key) const {
774+
DXILBindingMap::findCreationInfo(const Value *Key) const {
775775
if (const PHINode *Phi = dyn_cast<PHINode>(Key)) {
776776
SmallVector<dxil::ResourceBindingInfo> Children;
777777
for (const Value *V : Phi->operands()) {
778-
Children.append(findByUse(V));
778+
Children.append(findCreationInfo(V));
779779
}
780780
return Children;
781781
}
@@ -784,30 +784,29 @@ DXILBindingMap::findByUse(const Value *Key) const {
784784
if (!CI)
785785
return {};
786786

787-
const Type *UseType = CI->getType();
788-
789787
switch (CI->getIntrinsicID()) {
790-
// Check if any of the parameters are the resource we are following. If so
791-
// keep searching
792-
case Intrinsic::not_intrinsic: {
793-
SmallVector<dxil::ResourceBindingInfo> Children;
794-
for (const Value *V : CI->args()) {
795-
if (V->getType() != UseType)
796-
continue;
797-
798-
Children.append(findByUse(V));
799-
}
800-
801-
return Children;
802-
}
803788
// Found the create, return the binding
804-
case Intrinsic::dx_resource_handlefrombinding:
789+
case Intrinsic::dx_resource_handlefrombinding: {
805790
const auto *It = find(CI);
806791
assert(It != Infos.end() && "HandleFromBinding must be in resource map");
807792
return {*It};
793+
}
794+
default:
795+
break;
796+
}
797+
798+
// Check if any of the parameters are the resource we are following. If so
799+
// keep searching. If none of them are return an empty list
800+
const Type *UseType = CI->getType();
801+
SmallVector<dxil::ResourceBindingInfo> Children;
802+
for (const Value *V : CI->args()) {
803+
if (V->getType() != UseType)
804+
continue;
805+
806+
Children.append(findCreationInfo(V));
808807
}
809808

810-
return {};
809+
return Children;
811810
}
812811

813812
//===----------------------------------------------------------------------===//

llvm/unittests/Target/DirectX/UniqueResourceFromUseTests.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ declare void @a.func(target("dx.RawBuffer", float, 1, 0) %handle)
7373
for (const User *U : F.users()) {
7474
const CallInst *CI = cast<CallInst>(U);
7575
const Value *Handle = CI->getArgOperand(0);
76-
const auto Bindings = DBM.findByUse(Handle);
76+
const auto Bindings = DBM.findCreationInfo(Handle);
7777
ASSERT_EQ(Bindings.size(), 1u)
7878
<< "Handle should resolve into one resource";
7979

@@ -123,7 +123,7 @@ declare target("dx.RawBuffer", float, 1, 0) @ind.func(target("dx.RawBuffer", flo
123123
for (const User *U : F.users()) {
124124
const CallInst *CI = cast<CallInst>(U);
125125
const Value *Handle = CI->getArgOperand(0);
126-
const auto Bindings = DBM.findByUse(Handle);
126+
const auto Bindings = DBM.findCreationInfo(Handle);
127127
ASSERT_EQ(Bindings.size(), 1u)
128128
<< "Handle should resolve into one resource";
129129

@@ -176,7 +176,7 @@ declare target("dx.RawBuffer", float, 1, 0) @ind.func(target("dx.RawBuffer", flo
176176
for (const User *U : F.users()) {
177177
const CallInst *CI = cast<CallInst>(U);
178178
const Value *Handle = CI->getArgOperand(0);
179-
const auto Bindings = DBM.findByUse(Handle);
179+
const auto Bindings = DBM.findCreationInfo(Handle);
180180
ASSERT_EQ(Bindings.size(), 4u)
181181
<< "Handle should resolve into four resources";
182182

@@ -256,7 +256,7 @@ declare target("dx.RawBuffer", float, 1, 0) @ind.func(target("dx.RawBuffer", flo
256256
for (const User *U : F.users()) {
257257
const CallInst *CI = cast<CallInst>(U);
258258
const Value *Handle = CI->getArgOperand(0);
259-
const auto Bindings = DBM.findByUse(Handle);
259+
const auto Bindings = DBM.findCreationInfo(Handle);
260260
ASSERT_EQ(Bindings.size(), 2u)
261261
<< "Handle should resolve into four resources";
262262

0 commit comments

Comments
 (0)