================ @@ -0,0 +1,87 @@ +//===- OffloadBlockUniformity.cpp - Offload block uniformity info +//----------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "llvm/CodeGen/OffloadBlockUniformity.h" +#include "llvm/CodeGen/MachineBasicBlock.h" +#include "llvm/CodeGen/MachineFunction.h" +#include "llvm/IR/BasicBlock.h" +#include "llvm/IR/Constants.h" +#include "llvm/IR/Instruction.h" +#include "llvm/IR/Metadata.h" +#include <optional> + +using namespace llvm; + +static std::optional<bool> getIRBlockUniformity(const BasicBlock &BB) { + const Instruction *TI = BB.getTerminator(); + if (!TI) + return std::nullopt; + + MDNode *MD = TI->getMetadata(OffloadBlockUniformityInfo::MetadataName); + if (!MD || MD->getNumOperands() != 1) + return std::nullopt; + + const auto *CI = mdconst::extract_or_null<ConstantInt>(MD->getOperand(0)); + if (!CI) + return std::nullopt; ---------------- arsenm wrote:
Structural rules should be enforced in IR verifier, no https://github.com/llvm/llvm-project/pull/177665 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
