Skip to content

Commit 90e075c

Browse files
andrurogerzAnthony Tran
authored andcommitted
[llvm] annotate remaining Support and ADT library interfaces for DLL export (llvm#145354)
## Purpose This patch is one in a series of code-mods that annotate LLVM’s public interface for export. This patch annotates the remaining LLVM Support and ADT interfaces that were missed in, or modified since, previous patches. The annotations currently have no meaningful impact on the LLVM build; however, they are a prerequisite to support an LLVM Windows DLL (shared library) build. ## Background This effort is tracked in llvm#109483. Additional context is provided in [this discourse](https://discourse.llvm.org/t/psa-annotating-llvm-public-interface/85307), and documentation for `LLVM_ABI` and related annotations is found in the LLVM repo [here](https://github.com/llvm/llvm-project/blob/main/llvm/docs/InterfaceExportAnnotations.rst). ## Overview The bulk of these changes were generated automatically using the [Interface Definition Scanner (IDS)](https://github.com/compnerd/ids) tool, followed formatting with `git clang-format`. The following manual adjustments were also applied after running IDS: - Annotate the private method `IEEEFloat::addOrSubtractSignificand` with `LLVM_ABI` because it is used by a unit test friend class. - Annotate several `friend` function declarations with `LLVM_ABI_FRIEND` since the corresponding function declarations are annotated with `LLVM_ABI` (required by MSVC). ## Validation Local builds and tests to validate cross-platform compatibility. This included llvm, clang, and lldb on the following configurations: - Windows with MSVC - Windows with Clang - Linux with GCC - Linux with Clang - Darwin with Clang
1 parent f8a0e93 commit 90e075c

File tree

8 files changed

+25
-18
lines changed

8 files changed

+25
-18
lines changed

llvm/include/llvm/ADT/APFloat.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,9 @@ class IEEEFloat final {
672672

673673
integerPart addSignificand(const IEEEFloat &);
674674
integerPart subtractSignificand(const IEEEFloat &, integerPart);
675-
lostFraction addOrSubtractSignificand(const IEEEFloat &, bool subtract);
675+
// Exported for IEEEFloatUnitTestHelper.
676+
LLVM_ABI lostFraction addOrSubtractSignificand(const IEEEFloat &,
677+
bool subtract);
676678
lostFraction multiplySignificand(const IEEEFloat &, IEEEFloat,
677679
bool ignoreAddend = false);
678680
lostFraction multiplySignificand(const IEEEFloat&);

llvm/include/llvm/ADT/APInt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ class [[nodiscard]] APInt {
561561
}
562562

563563
/// Overload to compute a hash_code for an APInt value.
564-
friend hash_code hash_value(const APInt &Arg);
564+
LLVM_ABI friend hash_code hash_value(const APInt &Arg);
565565

566566
/// This function returns a pointer to the internal storage of the APInt.
567567
/// This is useful for writing out the APInt in binary form without any

llvm/include/llvm/ADT/DynamicAPInt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ class DynamicAPInt {
212212
friend DynamicAPInt operator/(int64_t A, const DynamicAPInt &B);
213213
friend DynamicAPInt operator%(int64_t A, const DynamicAPInt &B);
214214

215-
friend hash_code hash_value(const DynamicAPInt &x); // NOLINT
215+
LLVM_ABI friend hash_code hash_value(const DynamicAPInt &x); // NOLINT
216216

217217
LLVM_ABI void static_assert_layout(); // NOLINT
218218

llvm/include/llvm/Support/ConvertUTF.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,9 @@ LLVM_ABI bool convertUTF32ToUTF8String(ArrayRef<UTF32> Src, std::string &Out);
346346
LLVM_ABI bool convertUTF8ToUTF16String(StringRef SrcUTF8,
347347
SmallVectorImpl<UTF16> &DstUTF16);
348348

349-
bool IsSingleCodeUnitUTF8Codepoint(unsigned);
350-
bool IsSingleCodeUnitUTF16Codepoint(unsigned);
351-
bool IsSingleCodeUnitUTF32Codepoint(unsigned);
349+
LLVM_ABI bool IsSingleCodeUnitUTF8Codepoint(unsigned);
350+
LLVM_ABI bool IsSingleCodeUnitUTF16Codepoint(unsigned);
351+
LLVM_ABI bool IsSingleCodeUnitUTF32Codepoint(unsigned);
352352

353353
#if defined(_WIN32)
354354
namespace sys {

llvm/include/llvm/Support/KnownFPClass.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#define LLVM_SUPPORT_KNOWNFPCLASS_H
1616

1717
#include "llvm/ADT/FloatingPointMode.h"
18+
#include "llvm/Support/Compiler.h"
1819
#include <optional>
1920

2021
namespace llvm {
@@ -78,13 +79,13 @@ struct KnownFPClass {
7879
/// Return true if it's know this can never be interpreted as a zero. This
7980
/// extends isKnownNeverZero to cover the case where the assumed
8081
/// floating-point mode for the function interprets denormals as zero.
81-
bool isKnownNeverLogicalZero(DenormalMode Mode) const;
82+
LLVM_ABI bool isKnownNeverLogicalZero(DenormalMode Mode) const;
8283

8384
/// Return true if it's know this can never be interpreted as a negative zero.
84-
bool isKnownNeverLogicalNegZero(DenormalMode Mode) const;
85+
LLVM_ABI bool isKnownNeverLogicalNegZero(DenormalMode Mode) const;
8586

8687
/// Return true if it's know this can never be interpreted as a positive zero.
87-
bool isKnownNeverLogicalPosZero(DenormalMode Mode) const;
88+
LLVM_ABI bool isKnownNeverLogicalPosZero(DenormalMode Mode) const;
8889

8990
static constexpr FPClassTest OrderedLessThanZeroMask =
9091
fcNegSubnormal | fcNegNormal | fcNegInf;
@@ -209,15 +210,16 @@ struct KnownFPClass {
209210
///
210211
/// This assumes a copy-like operation and will replace any currently known
211212
/// information.
212-
void propagateDenormal(const KnownFPClass &Src, DenormalMode Mode);
213+
LLVM_ABI void propagateDenormal(const KnownFPClass &Src, DenormalMode Mode);
213214

214215
/// Report known classes if \p Src is evaluated through a potentially
215216
/// canonicalizing operation. We can assume signaling nans will not be
216217
/// introduced, but cannot assume a denormal will be flushed under FTZ/DAZ.
217218
///
218219
/// This assumes a copy-like operation and will replace any currently known
219220
/// information.
220-
void propagateCanonicalizingSrc(const KnownFPClass &Src, DenormalMode Mode);
221+
LLVM_ABI void propagateCanonicalizingSrc(const KnownFPClass &Src,
222+
DenormalMode Mode);
221223

222224
void resetAll() { *this = KnownFPClass(); }
223225
};

llvm/include/llvm/Support/ProgramStack.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define LLVM_SUPPORT_PROGRAMSTACK_H
1111

1212
#include "llvm/ADT/STLFunctionalExtras.h"
13+
#include "llvm/Support/Compiler.h"
1314

1415
// LLVM_HAS_SPLIT_STACKS is exposed in the header because CrashRecoveryContext
1516
// needs to know if it's running on another thread or not.
@@ -28,12 +29,12 @@ namespace llvm {
2829
///
2930
/// The value is not guaranteed to point to anything specific. It can be used to
3031
/// estimate how much stack space has been used since the previous call.
31-
uintptr_t getStackPointer();
32+
LLVM_ABI uintptr_t getStackPointer();
3233

3334
/// \returns the default stack size for this platform.
3435
///
3536
/// Based on \p RLIMIT_STACK or the equivalent.
36-
unsigned getDefaultStackSize();
37+
LLVM_ABI unsigned getDefaultStackSize();
3738

3839
/// Runs Fn on a new stack of at least the given size.
3940
///
@@ -42,7 +43,7 @@ unsigned getDefaultStackSize();
4243
///
4344
/// The preferred implementation is split stacks on platforms that have a good
4445
/// debugging experience for them. On other platforms a new thread is used.
45-
void runOnNewStack(unsigned StackSize, function_ref<void()> Fn);
46+
LLVM_ABI void runOnNewStack(unsigned StackSize, function_ref<void()> Fn);
4647

4748
template <typename R, typename... Ts>
4849
std::enable_if_t<!std::is_same_v<R, void>, R>

llvm/include/llvm/Support/TextEncoding.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "llvm/ADT/SmallString.h"
1919
#include "llvm/ADT/StringRef.h"
2020
#include "llvm/Config/config.h"
21+
#include "llvm/Support/Compiler.h"
2122
#include "llvm/Support/ErrorOr.h"
2223

2324
#include <string>
@@ -92,16 +93,17 @@ class TextEncodingConverter {
9293
/// \param[in] From the source character encoding
9394
/// \param[in] To the target character encoding
9495
/// \return a TextEncodingConverter instance or an error code
95-
static ErrorOr<TextEncodingConverter> create(TextEncoding From,
96-
TextEncoding To);
96+
LLVM_ABI static ErrorOr<TextEncodingConverter> create(TextEncoding From,
97+
TextEncoding To);
9798

9899
/// Creates a TextEncodingConverter instance.
99100
/// Returns std::errc::invalid_argument in case the requested conversion is
100101
/// not supported.
101102
/// \param[in] From name of the source character encoding
102103
/// \param[in] To name of the target character encoding
103104
/// \return a TextEncodingConverter instance or an error code
104-
static ErrorOr<TextEncodingConverter> create(StringRef From, StringRef To);
105+
LLVM_ABI static ErrorOr<TextEncodingConverter> create(StringRef From,
106+
StringRef To);
105107

106108
TextEncodingConverter(const TextEncodingConverter &) = delete;
107109
TextEncodingConverter &operator=(const TextEncodingConverter &) = delete;

llvm/include/llvm/Support/Timer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ class TimerGroup {
258258

259259
private:
260260
friend class Timer;
261-
friend void PrintStatisticsJSON(raw_ostream &OS);
261+
LLVM_ABI friend void PrintStatisticsJSON(raw_ostream &OS);
262262
void addTimer(Timer &T);
263263
void removeTimer(Timer &T);
264264
void prepareToPrintList(bool reset_time = false);

0 commit comments

Comments
 (0)