Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/include/llvm/Analysis/DXILResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down
52 changes: 27 additions & 25 deletions llvm/include/llvm/Analysis/IR2Vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#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>
Expand All @@ -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.
Expand Down Expand Up @@ -106,16 +107,17 @@ 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>;
Expand Down Expand Up @@ -148,7 +150,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
Expand All @@ -161,38 +163,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;
Expand All @@ -219,13 +221,13 @@ 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,
ModuleAnalysisManager::Invalidator &Inv) const;
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;
};

/// This analysis provides the vocabulary for IR2Vec. The vocabulary provides a
Expand All @@ -237,12 +239,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
Expand All @@ -253,7 +255,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; }
};

Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/Analysis/ValueTracking.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion llvm/unittests/Analysis/MemoryProfileInfoTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -23,7 +24,7 @@
using namespace llvm;
using namespace llvm::memprof;

extern cl::opt<bool> MemProfKeepAllNotColdContexts;
LLVM_ABI extern cl::opt<bool> MemProfKeepAllNotColdContexts;

namespace {

Expand Down