The create handle intrinsic calls can't be removed, so it was incorrect
to mark them as IntrNoMem.
def int_dx_flattened_thread_id_in_group : Intrinsic<[llvm_i32_ty], [], [IntrNoMem, IntrWillReturn]>;
def int_dx_create_handle : ClangBuiltin<"__builtin_hlsl_create_handle">,
- Intrinsic<[ llvm_ptr_ty ], [llvm_i8_ty], [IntrNoMem, IntrWillReturn]>;
+ Intrinsic<[ llvm_ptr_ty ], [llvm_i8_ty], [IntrWillReturn]>;
}
--- /dev/null
+; RUN: opt %s -early-cse -S | FileCheck %s
+
+define void @fn() {
+entry:
+ %0 = tail call ptr @llvm.dx.create.handle(i8 1)
+ %1 = tail call ptr @llvm.dx.create.handle(i8 1)
+ ret void
+}
+
+; Function Attrs: mustprogress nounwind willreturn
+declare ptr @llvm.dx.create.handle(i8) #0
+
+attributes #0 = { mustprogress nounwind willreturn }
+
+; CSE needs to leave this alone
+; CHECK: %0 = tail call ptr @llvm.dx.create.handle(i8 1)
+; CHECK: %1 = tail call ptr @llvm.dx.create.handle(i8 1)
\ No newline at end of file