[llvm] [DXIL] Consume Metadata Analysis information in passes (PR #108034)
S. Bharadwaj Yadavalli via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 19 10:05:25 PDT 2024
================
@@ -7,26 +7,57 @@
//===----------------------------------------------------------------------===//
#include "DXILTranslateMetadata.h"
-#include "DXILMetadata.h"
#include "DXILResource.h"
#include "DXILResourceAnalysis.h"
#include "DXILShaderFlags.h"
#include "DirectX.h"
-#include "llvm/ADT/StringSet.h"
+#include "llvm/ADT/SmallVector.h"
#include "llvm/Analysis/DXILMetadataAnalysis.h"
#include "llvm/Analysis/DXILResource.h"
#include "llvm/IR/Constants.h"
+#include "llvm/IR/DiagnosticInfo.h"
+#include "llvm/IR/DiagnosticPrinter.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/VersionTuple.h"
#include "llvm/TargetParser/Triple.h"
+#include <cstdint>
using namespace llvm;
using namespace llvm::dxil;
-static void emitResourceMetadata(Module &M, const DXILResourceMap &DRM,
- const dxil::Resources &MDResources) {
+/// A simple Wrapper DiagnosticInfo that generates Module-level diagnostic
+class DiagnosticInfoModuleFormat : public DiagnosticInfo {
+private:
+ const Twine Msg;
+ const Module &Mod;
+
+public:
+ /// \p M is the module for which the diagnostic is being emitted. \p Msg is
+ /// the message to show. Note that this class does not copy this message, so
+ /// this reference must be valid for the whole life time of the diagnostic.
+ DiagnosticInfoModuleFormat(const Module &M, const Twine &Msg,
+ DiagnosticSeverity Severity = DS_Error)
+ : DiagnosticInfo(DK_Unsupported, Severity), Msg(Msg), Mod(M) {}
+
+ void print(DiagnosticPrinter &DP) const override {
+ std::string Str;
+ raw_string_ostream OS(Str);
+
+ OS << Mod.getName() << ": " << Msg << '\n';
+ OS.flush();
+ DP << Str;
----------------
bharadwajy wrote:
> Why use a string here rather than printing into the `DiagnosticPrinter` directly?
Changed.
https://github.com/llvm/llvm-project/pull/108034
More information about the llvm-commits
mailing list