[llvm] [DirectX] Infrastructure to collect shader flags for each function (PR #112967)
Chris B via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 18 13:39:22 PST 2024
================
@@ -13,36 +13,79 @@
#include "DXILShaderFlags.h"
#include "DirectX.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/IR/DiagnosticInfo.h"
+#include "llvm/IR/DiagnosticPrinter.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Module.h"
+#include "llvm/Support/Error.h"
#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/raw_ostream.h"
using namespace llvm;
using namespace llvm::dxil;
-static void updateFlags(ComputedShaderFlags &Flags, const Instruction &I) {
- Type *Ty = I.getType();
- if (Ty->isDoubleTy()) {
- Flags.Doubles = true;
+namespace {
+/// A simple Wrapper DiagnosticInfo that generates Module-level diagnostic
+/// for Shader Flags Analysis pass
+class DiagnosticInfoShaderFlags : public DiagnosticInfo {
+private:
+ const Twine &Msg;
----------------
llvm-beanz wrote:
I get really nervous when someone stores a Twine. This effectively means that you must create and destroy this object in a single expression, otherwise the Twine or its attached arguments can go out of scope and you have a memory error.
It seems to me like what you really need is an adapter that converts an `llvm::Error` to a `DiagnosticInfo`, so that you can just pass the Error object right through.
We should add a utility to llvm/Support/Error to facilitate that.
https://github.com/llvm/llvm-project/pull/112967
More information about the llvm-commits
mailing list