[clang] [compiler-rt] [llvm] [PGO][AMDGPU] Add offload profiling with uniformity-aware optimization (PR #177665)
Yaxun Liu via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 9 07:43:45 PDT 2026
================
@@ -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;
----------------
yxsamliu wrote:
will trust verifier
https://github.com/llvm/llvm-project/pull/177665
More information about the llvm-commits
mailing list