[clang] [llvm] [HLSL] Adding Flatten and Branch if attributes (PR #116331)
Chris B via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 3 07:32:00 PST 2024
================
@@ -1206,6 +1202,21 @@ class SPIRVStructurizer : public FunctionPass {
AU.addPreserved<SPIRVConvergenceRegionAnalysisWrapperPass>();
FunctionPass::getAnalysisUsage(AU);
}
+
+ void createOpSelectMerge(IRBuilder<> *Builder, BlockAddress *MergeAddress) {
+ Instruction *BBTerminatorInst = Builder->GetInsertBlock()->getTerminator();
+
+ MDNode *MDNode = BBTerminatorInst->getMetadata("hlsl.controlflow.hint");
+ if (MDNode)
+ assert(MDNode->getNumOperands() == 2 &&
----------------
llvm-beanz wrote:
You shouldn't put an `assert` as the only statement on an `if` block, it is better to fold it into the assert condition.
Today most C runtimes are nice about the `assert` macro defining to a no-op statement because the spec defines it as such, but people do replace `assert`, and lots of horrible things can happen if a single-statement `if`'s body is a macro expansion and the macro doesn't expand to a complete statement. Things like the _next_ statement becoming the body of the `if`.
https://github.com/llvm/llvm-project/pull/116331
More information about the cfe-commits
mailing list