summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:41 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:41 +0000
commit4f9fe856a25ab29345b90e7725509e9ee38a37be (patch)
treee4ffd8a9374cae7b21f7cbfb352927e0e074aff6 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
parentAdding upstream version 1.68.2+dfsg1. (diff)
downloadrustc-4f9fe856a25ab29345b90e7725509e9ee38a37be.tar.xz
rustc-4f9fe856a25ab29345b90e7725509e9ee38a37be.zip
Adding upstream version 1.69.0+dfsg1.upstream/1.69.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
-rw-r--r--compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
index 87b0e1273..e3493caaa 100644
--- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
+++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
@@ -63,11 +63,7 @@ static LLVM_THREAD_LOCAL char *LastError;
//
// Notably it exits the process with code 101, unlike LLVM's default of 1.
static void FatalErrorHandler(void *UserData,
-#if LLVM_VERSION_LT(14, 0)
- const std::string& Reason,
-#else
const char* Reason,
-#endif
bool GenCrashDiag) {
// Do the same thing that the default error handler does.
std::cerr << "LLVM ERROR: " << Reason << std::endl;
@@ -249,18 +245,10 @@ static Attribute::AttrKind fromRust(LLVMRustAttribute Kind) {
template<typename T> static inline void AddAttributes(T *t, unsigned Index,
LLVMAttributeRef *Attrs, size_t AttrsLen) {
AttributeList PAL = t->getAttributes();
- AttributeList PALNew;
-#if LLVM_VERSION_LT(14, 0)
- AttrBuilder B;
- for (LLVMAttributeRef Attr : makeArrayRef(Attrs, AttrsLen))
- B.addAttribute(unwrap(Attr));
- PALNew = PAL.addAttributes(t->getContext(), Index, B);
-#else
AttrBuilder B(t->getContext());
for (LLVMAttributeRef Attr : ArrayRef<LLVMAttributeRef>(Attrs, AttrsLen))
B.addAttribute(unwrap(Attr));
- PALNew = PAL.addAttributesAtIndex(t->getContext(), Index, B);
-#endif
+ AttributeList PALNew = PAL.addAttributesAtIndex(t->getContext(), Index, B);
t->setAttributes(PALNew);
}
@@ -1763,6 +1751,19 @@ LLVMRustModuleCost(LLVMModuleRef M) {
return std::distance(std::begin(f), std::end(f));
}
+extern "C" void
+LLVMRustModuleInstructionStats(LLVMModuleRef M, RustStringRef Str)
+{
+ RawRustStringOstream OS(Str);
+ llvm::json::OStream JOS(OS);
+ auto Module = unwrap(M);
+
+ JOS.object([&] {
+ JOS.attribute("module", Module->getName());
+ JOS.attribute("total", Module->getInstructionCount());
+ });
+}
+
// Vector reductions:
extern "C" LLVMValueRef
LLVMRustBuildVectorReduceFAdd(LLVMBuilderRef B, LLVMValueRef Acc, LLVMValueRef Src) {