[llvm] [llvm] annotate remaining Analysis library interfaces for DLL export (PR #145359)
Andrew Rogers via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 23 15:53:41 PDT 2025
https://github.com/andrurogerz updated https://github.com/llvm/llvm-project/pull/145359
>From ab107a58deaa3e756637317813b6fd9fdd6cc0bf Mon Sep 17 00:00:00 2001
From: Andrew Rogers <andrurogerz at gmail.com>
Date: Mon, 23 Jun 2025 09:29:43 -0700
Subject: [PATCH 1/3] [llvm] auto-annotate remaining Analysis lib interface
with IDS
---
llvm/include/llvm/Analysis/DXILResource.h | 2 +-
llvm/include/llvm/Analysis/IR2Vec.h | 49 +++++++++++-----------
llvm/include/llvm/Analysis/ValueTracking.h | 4 +-
3 files changed, 28 insertions(+), 27 deletions(-)
diff --git a/llvm/include/llvm/Analysis/DXILResource.h b/llvm/include/llvm/Analysis/DXILResource.h
index cfc21b3ec202b..07b0e97a20fce 100644
--- a/llvm/include/llvm/Analysis/DXILResource.h
+++ b/llvm/include/llvm/Analysis/DXILResource.h
@@ -34,7 +34,7 @@ namespace dxil {
// Returns the resource name from dx_resource_handlefrombinding or
// dx_resource_handlefromimplicitbinding call
-StringRef getResourceNameFromBindingCall(CallInst *CI);
+LLVM_ABI StringRef getResourceNameFromBindingCall(CallInst *CI);
/// The dx.RawBuffer target extension type
///
diff --git a/llvm/include/llvm/Analysis/IR2Vec.h b/llvm/include/llvm/Analysis/IR2Vec.h
index de67955d85d7c..d0e594494dc3e 100644
--- a/llvm/include/llvm/Analysis/IR2Vec.h
+++ b/llvm/include/llvm/Analysis/IR2Vec.h
@@ -29,6 +29,7 @@
#ifndef LLVM_ANALYSIS_IR2VEC_H
#define LLVM_ANALYSIS_IR2VEC_H
+#include "llvm/Support/Compiler.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Support/CommandLine.h"
@@ -57,9 +58,9 @@ enum class IR2VecKind { Symbolic };
namespace ir2vec {
-extern cl::opt<float> OpcWeight;
-extern cl::opt<float> TypeWeight;
-extern cl::opt<float> ArgWeight;
+LLVM_ABI extern cl::opt<float> OpcWeight;
+LLVM_ABI extern cl::opt<float> TypeWeight;
+LLVM_ABI extern cl::opt<float> ArgWeight;
/// Embedding is a datatype that wraps std::vector<double>. It provides
/// additional functionality for arithmetic and comparison operations.
@@ -106,16 +107,16 @@ struct Embedding {
const std::vector<double> &getData() const { return Data; }
/// Arithmetic operators
- Embedding &operator+=(const Embedding &RHS);
- Embedding &operator-=(const Embedding &RHS);
+ LLVM_ABI Embedding &operator+=(const Embedding &RHS);
+ LLVM_ABI Embedding &operator-=(const Embedding &RHS);
/// Adds Src Embedding scaled by Factor with the called Embedding.
/// Called_Embedding += Src * Factor
- Embedding &scaleAndAdd(const Embedding &Src, float Factor);
+ LLVM_ABI Embedding &scaleAndAdd(const Embedding &Src, float Factor);
/// Returns true if the embedding is approximately equal to the RHS embedding
/// within the specified tolerance.
- bool approximatelyEquals(const Embedding &RHS, double Tolerance = 1e-6) const;
+ LLVM_ABI bool approximatelyEquals(const Embedding &RHS, double Tolerance = 1e-6) const;
};
using InstEmbeddingsMap = DenseMap<const Instruction *, Embedding>;
@@ -148,7 +149,7 @@ class Embedder {
mutable BBEmbeddingsMap BBVecMap;
mutable InstEmbeddingsMap InstVecMap;
- Embedder(const Function &F, const Vocab &Vocabulary);
+ LLVM_ABI Embedder(const Function &F, const Vocab &Vocabulary);
/// Helper function to compute embeddings. It generates embeddings for all
/// the instructions and basic blocks in the function F. Logic of computing
@@ -161,38 +162,38 @@ class Embedder {
/// Lookup vocabulary for a given Key. If the key is not found, it returns a
/// zero vector.
- Embedding lookupVocab(const std::string &Key) const;
+ LLVM_ABI Embedding lookupVocab(const std::string &Key) const;
public:
virtual ~Embedder() = default;
/// Factory method to create an Embedder object.
- static Expected<std::unique_ptr<Embedder>>
+ LLVM_ABI static Expected<std::unique_ptr<Embedder>>
create(IR2VecKind Mode, const Function &F, const Vocab &Vocabulary);
/// Returns a map containing instructions and the corresponding embeddings for
/// the function F if it has been computed. If not, it computes the embeddings
/// for the function and returns the map.
- const InstEmbeddingsMap &getInstVecMap() const;
+ LLVM_ABI const InstEmbeddingsMap &getInstVecMap() const;
/// Returns a map containing basic block and the corresponding embeddings for
/// the function F if it has been computed. If not, it computes the embeddings
/// for the function and returns the map.
- const BBEmbeddingsMap &getBBVecMap() const;
+ LLVM_ABI const BBEmbeddingsMap &getBBVecMap() const;
/// Returns the embedding for a given basic block in the function F if it has
/// been computed. If not, it computes the embedding for the basic block and
/// returns it.
- const Embedding &getBBVector(const BasicBlock &BB) const;
+ LLVM_ABI const Embedding &getBBVector(const BasicBlock &BB) const;
/// Computes and returns the embedding for the current function.
- const Embedding &getFunctionVector() const;
+ LLVM_ABI const Embedding &getFunctionVector() const;
};
/// Class for computing the Symbolic embeddings of IR2Vec.
/// Symbolic embeddings are constructed based on the entity-level
/// representations obtained from the Vocabulary.
-class SymbolicEmbedder : public Embedder {
+class LLVM_ABI SymbolicEmbedder : public Embedder {
private:
/// Utility function to compute the embedding for a given type.
Embedding getTypeEmbedding(const Type *Ty) const;
@@ -219,12 +220,12 @@ class IR2VecVocabResult {
public:
IR2VecVocabResult() = default;
- IR2VecVocabResult(ir2vec::Vocab &&Vocabulary);
+ LLVM_ABI IR2VecVocabResult(ir2vec::Vocab &&Vocabulary);
bool isValid() const { return Valid; }
- const ir2vec::Vocab &getVocabulary() const;
- unsigned getDimension() const;
- bool invalidate(Module &M, const PreservedAnalyses &PA,
+ LLVM_ABI const ir2vec::Vocab &getVocabulary() const;
+ LLVM_ABI unsigned getDimension() const;
+ LLVM_ABI bool invalidate(Module &M, const PreservedAnalyses &PA,
ModuleAnalysisManager::Invalidator &Inv) const;
};
@@ -237,12 +238,12 @@ class IR2VecVocabAnalysis : public AnalysisInfoMixin<IR2VecVocabAnalysis> {
void emitError(Error Err, LLVMContext &Ctx);
public:
- static AnalysisKey Key;
+ LLVM_ABI static AnalysisKey Key;
IR2VecVocabAnalysis() = default;
- explicit IR2VecVocabAnalysis(const ir2vec::Vocab &Vocab);
- explicit IR2VecVocabAnalysis(ir2vec::Vocab &&Vocab);
+ LLVM_ABI explicit IR2VecVocabAnalysis(const ir2vec::Vocab &Vocab);
+ LLVM_ABI explicit IR2VecVocabAnalysis(ir2vec::Vocab &&Vocab);
using Result = IR2VecVocabResult;
- Result run(Module &M, ModuleAnalysisManager &MAM);
+ LLVM_ABI Result run(Module &M, ModuleAnalysisManager &MAM);
};
/// This pass prints the IR2Vec embeddings for instructions, basic blocks, and
@@ -253,7 +254,7 @@ class IR2VecPrinterPass : public PassInfoMixin<IR2VecPrinterPass> {
public:
explicit IR2VecPrinterPass(raw_ostream &OS) : OS(OS) {}
- PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
+ LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
static bool isRequired() { return true; }
};
diff --git a/llvm/include/llvm/Analysis/ValueTracking.h b/llvm/include/llvm/Analysis/ValueTracking.h
index 4596b2563c1d8..c804f551f5a75 100644
--- a/llvm/include/llvm/Analysis/ValueTracking.h
+++ b/llvm/include/llvm/Analysis/ValueTracking.h
@@ -311,11 +311,11 @@ LLVM_ABI std::optional<bool> computeKnownFPSignBit(const Value *V,
/// Return true if the sign bit of the FP value can be ignored by the user when
/// the value is zero.
-bool canIgnoreSignBitOfZero(const Use &U);
+LLVM_ABI bool canIgnoreSignBitOfZero(const Use &U);
/// Return true if the sign bit of the FP value can be ignored by the user when
/// the value is NaN.
-bool canIgnoreSignBitOfNaN(const Use &U);
+LLVM_ABI bool canIgnoreSignBitOfNaN(const Use &U);
/// If the specified value can be set by repeating the same byte in memory,
/// return the i8 value that it is represented with. This is true for all i8
>From 6dc49158ea3e44dcc3501c16eb67924179427de7 Mon Sep 17 00:00:00 2001
From: Andrew Rogers <andrurogerz at gmail.com>
Date: Mon, 23 Jun 2025 09:30:35 -0700
Subject: [PATCH 2/3] [llmv] manual fixups to Analysis unit test for Windows
DLL build
---
llvm/unittests/Analysis/MemoryProfileInfoTest.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/llvm/unittests/Analysis/MemoryProfileInfoTest.cpp b/llvm/unittests/Analysis/MemoryProfileInfoTest.cpp
index 6eef0b5f91719..aa4d712cde09e 100644
--- a/llvm/unittests/Analysis/MemoryProfileInfoTest.cpp
+++ b/llvm/unittests/Analysis/MemoryProfileInfoTest.cpp
@@ -14,6 +14,7 @@
#include "llvm/IR/Module.h"
#include "llvm/IR/ModuleSummaryIndex.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/SourceMgr.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
@@ -23,7 +24,7 @@
using namespace llvm;
using namespace llvm::memprof;
-extern cl::opt<bool> MemProfKeepAllNotColdContexts;
+LLVM_ABI extern cl::opt<bool> MemProfKeepAllNotColdContexts;
namespace {
>From 73a7078988b41607c0a8eaf6897065daa209ef0c Mon Sep 17 00:00:00 2001
From: Andrew Rogers <andrurogerz at gmail.com>
Date: Mon, 23 Jun 2025 09:30:57 -0700
Subject: [PATCH 3/3] [llvm] clang-format changes
---
llvm/include/llvm/Analysis/IR2Vec.h | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/llvm/include/llvm/Analysis/IR2Vec.h b/llvm/include/llvm/Analysis/IR2Vec.h
index d0e594494dc3e..1eb4a9b8aaf9e 100644
--- a/llvm/include/llvm/Analysis/IR2Vec.h
+++ b/llvm/include/llvm/Analysis/IR2Vec.h
@@ -29,10 +29,10 @@
#ifndef LLVM_ANALYSIS_IR2VEC_H
#define LLVM_ANALYSIS_IR2VEC_H
-#include "llvm/Support/Compiler.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/JSON.h"
#include <map>
@@ -116,7 +116,8 @@ struct Embedding {
/// Returns true if the embedding is approximately equal to the RHS embedding
/// within the specified tolerance.
- LLVM_ABI bool approximatelyEquals(const Embedding &RHS, double Tolerance = 1e-6) const;
+ LLVM_ABI bool approximatelyEquals(const Embedding &RHS,
+ double Tolerance = 1e-6) const;
};
using InstEmbeddingsMap = DenseMap<const Instruction *, Embedding>;
@@ -226,7 +227,7 @@ class IR2VecVocabResult {
LLVM_ABI const ir2vec::Vocab &getVocabulary() const;
LLVM_ABI unsigned getDimension() const;
LLVM_ABI bool invalidate(Module &M, const PreservedAnalyses &PA,
- ModuleAnalysisManager::Invalidator &Inv) const;
+ ModuleAnalysisManager::Invalidator &Inv) const;
};
/// This analysis provides the vocabulary for IR2Vec. The vocabulary provides a
More information about the llvm-commits
mailing list