Skip to content

Commit c1a89d6

Browse files
committed
add md node type filter, and test
1 parent 9ed4c70 commit c1a89d6

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %clang --driver-mode=dxc -T cs_6_0 -Fo x.dxil %s | FileCheck %s
2+
// CHECK-NOT: llvm.loop.mustprogress
3+
4+
StructuredBuffer<uint4> X : register(t0);
5+
StructuredBuffer<float4> In : register(t1);
6+
RWStructuredBuffer<float4> Out : register(u0);
7+
8+
[numthreads(1, 1, 1)]
9+
void main(uint3 dispatch_thread_id : SV_DispatchThreadID) {
10+
for (uint I = 0; I < X[dispatch_thread_id].x; ++I) {
11+
Out[dispatch_thread_id] = In[dispatch_thread_id];
12+
}
13+
}

llvm/lib/Target/DirectX/DXILPrepare.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,26 @@ class DXILPrepareModule : public ModulePass {
189189
for (auto &BB : F) {
190190
IRBuilder<> Builder(&BB);
191191
for (auto &I : make_early_inc_range(BB)) {
192+
193+
// TODO: Audit this list - is it enough? Too much?
194+
static unsigned DXILCompatibleMDs[] = {
195+
LLVMContext::MD_dbg,
196+
LLVMContext::MD_tbaa,
197+
LLVMContext::MD_prof,
198+
LLVMContext::MD_fpmath,
199+
LLVMContext::MD_range,
200+
LLVMContext::MD_tbaa_struct,
201+
LLVMContext::MD_invariant_load,
202+
LLVMContext::MD_alias_scope,
203+
LLVMContext::MD_noalias,
204+
LLVMContext::MD_nontemporal,
205+
LLVMContext::MD_mem_parallel_loop_access,
206+
LLVMContext::MD_nonnull,
207+
LLVMContext::MD_dereferenceable,
208+
LLVMContext::MD_dereferenceable_or_null,
209+
};
210+
I.dropUnknownNonDebugMetadata(DXILCompatibleMDs);
211+
192212
if (I.getOpcode() == Instruction::FNeg) {
193213
Builder.SetInsertPoint(&I);
194214
Value *In = I.getOperand(0);

0 commit comments

Comments
 (0)