[clang] [llvm] [HLSL] Handle WaveActiveBallot struct return type appropriately (PR #175105)
Finn Plummer via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 9 12:28:37 PST 2026
================
@@ -160,6 +160,26 @@ static Value *handleHlslSplitdouble(const CallExpr *E, CodeGenFunction *CGF) {
return LastInst;
}
+static Value *handleHlslWaveActiveBallot(const CallExpr *E,
+ CodeGenFunction *CGF) {
+ Value *Cond = CGF->EmitScalarExpr(E->getArg(0));
+ llvm::Type *I32 = CGF->Int32Ty;
+
+ if (CGF->CGM.getTarget().getTriple().isDXIL()) {
+ return CGF->EmitRuntimeCall(
+ CGF->CGM.getIntrinsic(Intrinsic::dx_wave_ballot, {I32}), Cond);
+ }
+
+ if (CGF->CGM.getTarget().getTriple().isSPIRV())
+ return CGF->EmitRuntimeCall(
+ CGF->CGM.getIntrinsic(Intrinsic::spv_wave_ballot), Cond);
+
+ CGF->CGM.Error(E->getExprLoc(),
+ "WaveActiveBallot is not supported for this target");
+
+ return llvm::PoisonValue::get(llvm::FixedVectorType::get(I32, 4));
----------------
inbelic wrote:
I think we tend to have an llvm_unreachable when it isn't a valid triple rather than reporting an error.
If this error is actually reachable then we should probably update the other implementations here.
https://github.com/llvm/llvm-project/pull/175105
More information about the cfe-commits
mailing list