Skip to content

Commit f1988f4

Browse files
committed
Expect only Load and GEP users of Globals, and report error otherwise
1 parent 34be09a commit f1988f4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

llvm/lib/Target/DirectX/DXILCBufferAccess.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111
#include "llvm/Frontend/HLSL/CBuffer.h"
1212
#include "llvm/Frontend/HLSL/HLSLResource.h"
1313
#include "llvm/IR/IRBuilder.h"
14+
#include "llvm/IR/IntrinsicInst.h"
1415
#include "llvm/IR/IntrinsicsDirectX.h"
16+
#include "llvm/IR/Operator.h"
1517
#include "llvm/InitializePasses.h"
1618
#include "llvm/Pass.h"
19+
#include "llvm/Support/ErrorHandling.h"
1720
#include "llvm/Transforms/Utils/Local.h"
1821

1922
#define DEBUG_TYPE "dxil-cbuffer-access"
@@ -161,7 +164,12 @@ static void replaceAccessesWithHandle(GlobalVariable *Global,
161164
}
162165

163166
// Otherwise, walk users looking for a load...
164-
ToProcess.append(Cur->user_begin(), Cur->user_end());
167+
if (isa<GetElementPtrInst>(Cur) || isa<GEPOperator>(Cur)) {
168+
ToProcess.append(Cur->user_begin(), Cur->user_end());
169+
continue;
170+
}
171+
172+
reportFatalInternalError("Unexpected user of Global");
165173
}
166174
RecursivelyDeleteTriviallyDeadInstructions(DeadInsts);
167175
}

0 commit comments

Comments
 (0)