[clang-tools-extra] [llvm] [Support] Remove raw_ostream::tie (PR #97396)

2024-07-02 Thread Alexis Engelke via cfe-commits

https://github.com/aengelke created 
https://github.com/llvm/llvm-project/pull/97396

Originally, tie was introduced by D81156 to flush stdout before writing to 
stderr. 030897523 reverted this due to race conditions. Nonetheless, it does 
cost performance, causing an extra check in the "cold" path, which is actually 
the hot path for raw_svector_ostream. Given that this feature sees almost no 
use, remove it.

Reverts commit 1ce831912c797df1cb6d313d8e576a3f86175b6d.

---

What was the motivation to keep this in llvm-dwarfdump? Is there any other way 
to achieve the same goal?

>From 04b794a8a02f06803f96c40de042b13fd4b12c5f Mon Sep 17 00:00:00 2001
From: Alexis Engelke 
Date: Mon, 1 Jul 2024 16:50:44 +0200
Subject: [PATCH] [Support] Remove raw_ostream::tie

Originally, tie was introduced by D81156 to flush stdout before writing
to stderr. 030897523 reverted this due to race conditions. Nonetheless,
it does cost performance, causing an extra check in the "cold" path,
which is actually the hot path for raw_svector_ostream. Given that this
feature sees almost no use, remove it.

Reverts commit 1ce831912c797df1cb6d313d8e576a3f86175b6d.
---
 .../clangd/index/remote/server/Server.cpp |  2 -
 clang-tools-extra/clangd/tool/ClangdMain.cpp  |  2 -
 llvm/include/llvm/Support/raw_ostream.h   | 11 ---
 llvm/lib/Support/raw_ostream.cpp  | 14 +---
 llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp  |  4 -
 llvm/unittests/Support/raw_ostream_test.cpp   | 82 ---
 6 files changed, 4 insertions(+), 111 deletions(-)

diff --git a/clang-tools-extra/clangd/index/remote/server/Server.cpp 
b/clang-tools-extra/clangd/index/remote/server/Server.cpp
index 4ef3ab6f9af9c..52fca53260a16 100644
--- a/clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ b/clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -499,8 +499,6 @@ int main(int argc, char *argv[]) {
   }
 
   llvm::errs().SetBuffered();
-  // Don't flush stdout when logging for thread safety.
-  llvm::errs().tie(nullptr);
   auto Logger = makeLogger(LogPrefix.getValue(), llvm::errs());
   clang::clangd::LoggingSession LoggingSession(*Logger);
 
diff --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp 
b/clang-tools-extra/clangd/tool/ClangdMain.cpp
index c3ba655ee2dc6..73000d96c6ca8 100644
--- a/clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -840,8 +840,6 @@ clangd accepts flags on the commandline, and in the 
CLANGD_FLAGS environment var
   // Use buffered stream to stderr (we still flush each log message). 
Unbuffered
   // stream can cause significant (non-deterministic) latency for the logger.
   llvm::errs().SetBuffered();
-  // Don't flush stdout when logging, this would be both slow and racy!
-  llvm::errs().tie(nullptr);
   StreamLogger Logger(llvm::errs(), LogLevel);
   LoggingSession LoggingSession(Logger);
   // Write some initial logs before we start doing any real work.
diff --git a/llvm/include/llvm/Support/raw_ostream.h 
b/llvm/include/llvm/Support/raw_ostream.h
index 0951ffb19ffa1..012915d341634 100644
--- a/llvm/include/llvm/Support/raw_ostream.h
+++ b/llvm/include/llvm/Support/raw_ostream.h
@@ -82,10 +82,6 @@ class raw_ostream {
   char *OutBufStart, *OutBufEnd, *OutBufCur;
   bool ColorEnabled = false;
 
-  /// Optional stream this stream is tied to. If this stream is written to, the
-  /// tied-to stream will be flushed first.
-  raw_ostream *TiedStream = nullptr;
-
   enum class BufferKind {
 Unbuffered = 0,
 InternalBuffer,
@@ -360,10 +356,6 @@ class raw_ostream {
 
   bool colors_enabled() const { return ColorEnabled; }
 
-  /// Tie this stream to the specified stream. Replaces any existing tied-to
-  /// stream. Specifying a nullptr unties the stream.
-  void tie(raw_ostream *TieTo) { TiedStream = TieTo; }
-
   
//======//
   // Subclass Interface
   
//======//
@@ -422,9 +414,6 @@ class raw_ostream {
   /// flushing. The result is affected by calls to enable_color().
   bool prepare_colors();
 
-  /// Flush the tied-to stream (if present) and then write the required data.
-  void flush_tied_then_write(const char *Ptr, size_t Size);
-
   virtual void anchor();
 };
 
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
index 0acb54f76c0bf..b202d0fe5a687 100644
--- a/llvm/lib/Support/raw_ostream.cpp
+++ b/llvm/lib/Support/raw_ostream.cpp
@@ -221,7 +221,7 @@ void raw_ostream::flush_nonempty() {
   assert(OutBufCur > OutBufStart && "Invalid call to flush_nonempty.");
   size_t Length = OutBufCur - OutBufStart;
   OutBufCur = OutBufStart;
-  flush_tied_then_write(OutBufStart, Length);
+  write_impl(OutBufStart, Length);
 }
 
 raw_ostream &raw_ostream::write(unsigned char C) {
@@ -229,7 +229,7 @@ raw_ostream &raw_ostream::write(unsigned char C) {
   if (LLVM_UNLIKELY(OutBufCur >= OutBufEnd)) {
   

[clang-tools-extra] [llvm] [Support] Remove raw_ostream::tie (PR #97396)

2024-07-02 Thread Alexis Engelke via cfe-commits

https://github.com/aengelke updated 
https://github.com/llvm/llvm-project/pull/97396

>From 04b794a8a02f06803f96c40de042b13fd4b12c5f Mon Sep 17 00:00:00 2001
From: Alexis Engelke 
Date: Mon, 1 Jul 2024 16:50:44 +0200
Subject: [PATCH 1/2] [Support] Remove raw_ostream::tie

Originally, tie was introduced by D81156 to flush stdout before writing
to stderr. 030897523 reverted this due to race conditions. Nonetheless,
it does cost performance, causing an extra check in the "cold" path,
which is actually the hot path for raw_svector_ostream. Given that this
feature sees almost no use, remove it.

Reverts commit 1ce831912c797df1cb6d313d8e576a3f86175b6d.
---
 .../clangd/index/remote/server/Server.cpp |  2 -
 clang-tools-extra/clangd/tool/ClangdMain.cpp  |  2 -
 llvm/include/llvm/Support/raw_ostream.h   | 11 ---
 llvm/lib/Support/raw_ostream.cpp  | 14 +---
 llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp  |  4 -
 llvm/unittests/Support/raw_ostream_test.cpp   | 82 ---
 6 files changed, 4 insertions(+), 111 deletions(-)

diff --git a/clang-tools-extra/clangd/index/remote/server/Server.cpp 
b/clang-tools-extra/clangd/index/remote/server/Server.cpp
index 4ef3ab6f9af9c..52fca53260a16 100644
--- a/clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ b/clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -499,8 +499,6 @@ int main(int argc, char *argv[]) {
   }
 
   llvm::errs().SetBuffered();
-  // Don't flush stdout when logging for thread safety.
-  llvm::errs().tie(nullptr);
   auto Logger = makeLogger(LogPrefix.getValue(), llvm::errs());
   clang::clangd::LoggingSession LoggingSession(*Logger);
 
diff --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp 
b/clang-tools-extra/clangd/tool/ClangdMain.cpp
index c3ba655ee2dc6..73000d96c6ca8 100644
--- a/clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -840,8 +840,6 @@ clangd accepts flags on the commandline, and in the 
CLANGD_FLAGS environment var
   // Use buffered stream to stderr (we still flush each log message). 
Unbuffered
   // stream can cause significant (non-deterministic) latency for the logger.
   llvm::errs().SetBuffered();
-  // Don't flush stdout when logging, this would be both slow and racy!
-  llvm::errs().tie(nullptr);
   StreamLogger Logger(llvm::errs(), LogLevel);
   LoggingSession LoggingSession(Logger);
   // Write some initial logs before we start doing any real work.
diff --git a/llvm/include/llvm/Support/raw_ostream.h 
b/llvm/include/llvm/Support/raw_ostream.h
index 0951ffb19ffa1..012915d341634 100644
--- a/llvm/include/llvm/Support/raw_ostream.h
+++ b/llvm/include/llvm/Support/raw_ostream.h
@@ -82,10 +82,6 @@ class raw_ostream {
   char *OutBufStart, *OutBufEnd, *OutBufCur;
   bool ColorEnabled = false;
 
-  /// Optional stream this stream is tied to. If this stream is written to, the
-  /// tied-to stream will be flushed first.
-  raw_ostream *TiedStream = nullptr;
-
   enum class BufferKind {
 Unbuffered = 0,
 InternalBuffer,
@@ -360,10 +356,6 @@ class raw_ostream {
 
   bool colors_enabled() const { return ColorEnabled; }
 
-  /// Tie this stream to the specified stream. Replaces any existing tied-to
-  /// stream. Specifying a nullptr unties the stream.
-  void tie(raw_ostream *TieTo) { TiedStream = TieTo; }
-
   
//======//
   // Subclass Interface
   
//======//
@@ -422,9 +414,6 @@ class raw_ostream {
   /// flushing. The result is affected by calls to enable_color().
   bool prepare_colors();
 
-  /// Flush the tied-to stream (if present) and then write the required data.
-  void flush_tied_then_write(const char *Ptr, size_t Size);
-
   virtual void anchor();
 };
 
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
index 0acb54f76c0bf..b202d0fe5a687 100644
--- a/llvm/lib/Support/raw_ostream.cpp
+++ b/llvm/lib/Support/raw_ostream.cpp
@@ -221,7 +221,7 @@ void raw_ostream::flush_nonempty() {
   assert(OutBufCur > OutBufStart && "Invalid call to flush_nonempty.");
   size_t Length = OutBufCur - OutBufStart;
   OutBufCur = OutBufStart;
-  flush_tied_then_write(OutBufStart, Length);
+  write_impl(OutBufStart, Length);
 }
 
 raw_ostream &raw_ostream::write(unsigned char C) {
@@ -229,7 +229,7 @@ raw_ostream &raw_ostream::write(unsigned char C) {
   if (LLVM_UNLIKELY(OutBufCur >= OutBufEnd)) {
 if (LLVM_UNLIKELY(!OutBufStart)) {
   if (BufferMode == BufferKind::Unbuffered) {
-flush_tied_then_write(reinterpret_cast(&C), 1);
+write_impl(reinterpret_cast(&C), 1);
 return *this;
   }
   // Set up a buffer and start over.
@@ -249,7 +249,7 @@ raw_ostream &raw_ostream::write(const char *Ptr, size_t 
Size) {
   if (LLVM_UNLIKELY(size_t(OutBufEnd - OutBufCur) < Size)) {
 if (LLVM_UNLIKELY(!OutBufStart)) {
   if (BufferMode == BufferKind::Unbuff

[clang-tools-extra] [llvm] [Support] Remove raw_ostream::tie (PR #97396)

2024-07-02 Thread Alexis Engelke via cfe-commits

aengelke wrote:

> What I feel the right initial question is, is this check actually making a 
> significant difference to performance in real-world use cases?

raw_ostream::write shows up in my (downstream application) profiles at ~0.6%, 
mostly through raw_svector_ostream, which is always unbuffered. The performance 
improvement of this one-condition-removal is [measureable 
(c-t-t)](http://llvm-compile-time-tracker.com/compare.php?from=8a25bb9b391bd13d824b1df43187b4c304011cee&to=04b794a8a02f06803f96c40de042b13fd4b12c5f&stat=instructions:u).

But I see your point. I reworked this so that tie() still works, but only on 
raw_fd_ostream (errs() is an raw_fd_ostream), so that other streams (svector, 
string) get performance gains. I also updated the comment to state the 
motivation/use case for this feature.

https://github.com/llvm/llvm-project/pull/97396
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [llvm] [Support] Move raw_ostream::tie to raw_fd_ostream (PR #97396)

2024-07-02 Thread Alexis Engelke via cfe-commits

https://github.com/aengelke edited 
https://github.com/llvm/llvm-project/pull/97396
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [llvm] [Support] Move raw_ostream::tie to raw_fd_ostream (PR #97396)

2024-07-02 Thread Alexis Engelke via cfe-commits

https://github.com/aengelke edited 
https://github.com/llvm/llvm-project/pull/97396
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [llvm] [Support] Move raw_ostream::tie to raw_fd_ostream (PR #97396)

2024-07-03 Thread Alexis Engelke via cfe-commits

https://github.com/aengelke closed 
https://github.com/llvm/llvm-project/pull/97396
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [MC] Remove Darwin SDK/Version from ObjFileInfo (PR #103025)

2024-08-13 Thread Alexis Engelke via cfe-commits

https://github.com/aengelke created 
https://github.com/llvm/llvm-project/pull/103025

There's only a single user (MCMachOStreamer), so it makes more sense to move 
the version emission to the source of the data.

(Not sure whether we want this, but I don't see benefits in storing this 
information in the MCObjectFileInfo.)

>From 90c48050f1e56613a4a68056e608de5fdc3e9cb6 Mon Sep 17 00:00:00 2001
From: Alexis Engelke 
Date: Tue, 13 Aug 2024 09:08:15 +
Subject: [PATCH] [MC] Remove Darwin SDK/Version from ObjFileInfo

There's only a single user (MCMachOStreamer), so it makes more sense to
move the version emission to the source of the data.
---
 clang/tools/driver/cc1as_main.cpp   | 11 +++
 llvm/include/llvm/MC/MCObjectFileInfo.h | 26 -
 llvm/lib/MC/MCMachOStreamer.cpp | 10 ++
 llvm/lib/Object/ModuleSymbolTable.cpp   |  1 -
 llvm/tools/llvm-mc/llvm-mc.cpp  |  3 +++
 5 files changed, 12 insertions(+), 39 deletions(-)

diff --git a/clang/tools/driver/cc1as_main.cpp 
b/clang/tools/driver/cc1as_main.cpp
index b661a43c88b08d..78019d39742e64 100644
--- a/clang/tools/driver/cc1as_main.cpp
+++ b/clang/tools/driver/cc1as_main.cpp
@@ -489,10 +489,6 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
   // MCObjectFileInfo needs a MCContext reference in order to initialize 
itself.
   std::unique_ptr MOFI(
   TheTarget->createMCObjectFileInfo(Ctx, PIC));
-  if (Opts.DarwinTargetVariantTriple)
-MOFI->setDarwinTargetVariantTriple(*Opts.DarwinTargetVariantTriple);
-  if (!Opts.DarwinTargetVariantSDKVersion.empty())
-MOFI->setDarwinTargetVariantSDKVersion(Opts.DarwinTargetVariantSDKVersion);
   Ctx.setObjectFileInfo(MOFI.get());
 
   if (Opts.GenDwarfForAssembly)
@@ -574,6 +570,13 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
 Str.reset(TheTarget->createMCObjectStreamer(
 T, Ctx, std::move(MAB), std::move(OW), std::move(CE), *STI));
 Str.get()->initSections(Opts.NoExecStack, *STI);
+if (T.isOSBinFormatMachO() && T.isOSDarwin()) {
+  Triple *TVT = Opts.DarwinTargetVariantTriple
+? &*Opts.DarwinTargetVariantTriple
+: nullptr;
+  Str->emitVersionForTarget(T, VersionTuple(), TVT,
+Opts.DarwinTargetVariantSDKVersion);
+}
   }
 
   // When -fembed-bitcode is passed to clang_as, a 1-byte marker
diff --git a/llvm/include/llvm/MC/MCObjectFileInfo.h 
b/llvm/include/llvm/MC/MCObjectFileInfo.h
index dda3e8a020f3ae..e2a2c84e47910b 100644
--- a/llvm/include/llvm/MC/MCObjectFileInfo.h
+++ b/llvm/include/llvm/MC/MCObjectFileInfo.h
@@ -458,9 +458,6 @@ class MCObjectFileInfo {
 private:
   bool PositionIndependent = false;
   MCContext *Ctx = nullptr;
-  VersionTuple SDKVersion;
-  std::optional DarwinTargetVariantTriple;
-  VersionTuple DarwinTargetVariantSDKVersion;
 
   void initMachOMCObjectFileInfo(const Triple &T);
   void initELFMCObjectFileInfo(const Triple &T, bool Large);
@@ -471,29 +468,6 @@ class MCObjectFileInfo {
   void initXCOFFMCObjectFileInfo(const Triple &T);
   void initDXContainerObjectFileInfo(const Triple &T);
   MCSection *getDwarfComdatSection(const char *Name, uint64_t Hash) const;
-
-public:
-  void setSDKVersion(const VersionTuple &TheSDKVersion) {
-SDKVersion = TheSDKVersion;
-  }
-
-  const VersionTuple &getSDKVersion() const { return SDKVersion; }
-
-  void setDarwinTargetVariantTriple(const Triple &T) {
-DarwinTargetVariantTriple = T;
-  }
-
-  const Triple *getDarwinTargetVariantTriple() const {
-return DarwinTargetVariantTriple ? &*DarwinTargetVariantTriple : nullptr;
-  }
-
-  void setDarwinTargetVariantSDKVersion(const VersionTuple &TheSDKVersion) {
-DarwinTargetVariantSDKVersion = TheSDKVersion;
-  }
-
-  const VersionTuple &getDarwinTargetVariantSDKVersion() const {
-return DarwinTargetVariantSDKVersion;
-  }
 };
 
 } // end namespace llvm
diff --git a/llvm/lib/MC/MCMachOStreamer.cpp b/llvm/lib/MC/MCMachOStreamer.cpp
index 528caa12ec2126..2e3b67eca08c1d 100644
--- a/llvm/lib/MC/MCMachOStreamer.cpp
+++ b/llvm/lib/MC/MCMachOStreamer.cpp
@@ -533,14 +533,8 @@ MCStreamer *llvm::createMachOStreamer(MCContext &Context,
   std::unique_ptr &&CE,
   bool DWARFMustBeAtTheEnd,
   bool LabelSections) {
-  MCMachOStreamer *S = new MCMachOStreamer(
-  Context, std::move(MAB), std::move(OW), std::move(CE), LabelSections);
-  const Triple &Target = Context.getTargetTriple();
-  S->emitVersionForTarget(
-  Target, Context.getObjectFileInfo()->getSDKVersion(),
-  Context.getObjectFileInfo()->getDarwinTargetVariantTriple(),
-  Context.getObjectFileInfo()->getDarwinTargetVariantSDKVersion());
-  return S;
+  return new MCMachOStreamer(Context, std::move(MAB), std::move(OW),
+ std::move(CE), LabelSections);
 }
 
 // The AddrSig section uses a s

[clang] [llvm] [MC] Remove Darwin SDK/Version from ObjFileInfo (PR #103025)

2024-08-13 Thread Alexis Engelke via cfe-commits

https://github.com/aengelke updated 
https://github.com/llvm/llvm-project/pull/103025

>From 90c48050f1e56613a4a68056e608de5fdc3e9cb6 Mon Sep 17 00:00:00 2001
From: Alexis Engelke 
Date: Tue, 13 Aug 2024 09:08:15 +
Subject: [PATCH 1/2] [MC] Remove Darwin SDK/Version from ObjFileInfo

There's only a single user (MCMachOStreamer), so it makes more sense to
move the version emission to the source of the data.
---
 clang/tools/driver/cc1as_main.cpp   | 11 +++
 llvm/include/llvm/MC/MCObjectFileInfo.h | 26 -
 llvm/lib/MC/MCMachOStreamer.cpp | 10 ++
 llvm/lib/Object/ModuleSymbolTable.cpp   |  1 -
 llvm/tools/llvm-mc/llvm-mc.cpp  |  3 +++
 5 files changed, 12 insertions(+), 39 deletions(-)

diff --git a/clang/tools/driver/cc1as_main.cpp 
b/clang/tools/driver/cc1as_main.cpp
index b661a43c88b08d..78019d39742e64 100644
--- a/clang/tools/driver/cc1as_main.cpp
+++ b/clang/tools/driver/cc1as_main.cpp
@@ -489,10 +489,6 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
   // MCObjectFileInfo needs a MCContext reference in order to initialize 
itself.
   std::unique_ptr MOFI(
   TheTarget->createMCObjectFileInfo(Ctx, PIC));
-  if (Opts.DarwinTargetVariantTriple)
-MOFI->setDarwinTargetVariantTriple(*Opts.DarwinTargetVariantTriple);
-  if (!Opts.DarwinTargetVariantSDKVersion.empty())
-MOFI->setDarwinTargetVariantSDKVersion(Opts.DarwinTargetVariantSDKVersion);
   Ctx.setObjectFileInfo(MOFI.get());
 
   if (Opts.GenDwarfForAssembly)
@@ -574,6 +570,13 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
 Str.reset(TheTarget->createMCObjectStreamer(
 T, Ctx, std::move(MAB), std::move(OW), std::move(CE), *STI));
 Str.get()->initSections(Opts.NoExecStack, *STI);
+if (T.isOSBinFormatMachO() && T.isOSDarwin()) {
+  Triple *TVT = Opts.DarwinTargetVariantTriple
+? &*Opts.DarwinTargetVariantTriple
+: nullptr;
+  Str->emitVersionForTarget(T, VersionTuple(), TVT,
+Opts.DarwinTargetVariantSDKVersion);
+}
   }
 
   // When -fembed-bitcode is passed to clang_as, a 1-byte marker
diff --git a/llvm/include/llvm/MC/MCObjectFileInfo.h 
b/llvm/include/llvm/MC/MCObjectFileInfo.h
index dda3e8a020f3ae..e2a2c84e47910b 100644
--- a/llvm/include/llvm/MC/MCObjectFileInfo.h
+++ b/llvm/include/llvm/MC/MCObjectFileInfo.h
@@ -458,9 +458,6 @@ class MCObjectFileInfo {
 private:
   bool PositionIndependent = false;
   MCContext *Ctx = nullptr;
-  VersionTuple SDKVersion;
-  std::optional DarwinTargetVariantTriple;
-  VersionTuple DarwinTargetVariantSDKVersion;
 
   void initMachOMCObjectFileInfo(const Triple &T);
   void initELFMCObjectFileInfo(const Triple &T, bool Large);
@@ -471,29 +468,6 @@ class MCObjectFileInfo {
   void initXCOFFMCObjectFileInfo(const Triple &T);
   void initDXContainerObjectFileInfo(const Triple &T);
   MCSection *getDwarfComdatSection(const char *Name, uint64_t Hash) const;
-
-public:
-  void setSDKVersion(const VersionTuple &TheSDKVersion) {
-SDKVersion = TheSDKVersion;
-  }
-
-  const VersionTuple &getSDKVersion() const { return SDKVersion; }
-
-  void setDarwinTargetVariantTriple(const Triple &T) {
-DarwinTargetVariantTriple = T;
-  }
-
-  const Triple *getDarwinTargetVariantTriple() const {
-return DarwinTargetVariantTriple ? &*DarwinTargetVariantTriple : nullptr;
-  }
-
-  void setDarwinTargetVariantSDKVersion(const VersionTuple &TheSDKVersion) {
-DarwinTargetVariantSDKVersion = TheSDKVersion;
-  }
-
-  const VersionTuple &getDarwinTargetVariantSDKVersion() const {
-return DarwinTargetVariantSDKVersion;
-  }
 };
 
 } // end namespace llvm
diff --git a/llvm/lib/MC/MCMachOStreamer.cpp b/llvm/lib/MC/MCMachOStreamer.cpp
index 528caa12ec2126..2e3b67eca08c1d 100644
--- a/llvm/lib/MC/MCMachOStreamer.cpp
+++ b/llvm/lib/MC/MCMachOStreamer.cpp
@@ -533,14 +533,8 @@ MCStreamer *llvm::createMachOStreamer(MCContext &Context,
   std::unique_ptr &&CE,
   bool DWARFMustBeAtTheEnd,
   bool LabelSections) {
-  MCMachOStreamer *S = new MCMachOStreamer(
-  Context, std::move(MAB), std::move(OW), std::move(CE), LabelSections);
-  const Triple &Target = Context.getTargetTriple();
-  S->emitVersionForTarget(
-  Target, Context.getObjectFileInfo()->getSDKVersion(),
-  Context.getObjectFileInfo()->getDarwinTargetVariantTriple(),
-  Context.getObjectFileInfo()->getDarwinTargetVariantSDKVersion());
-  return S;
+  return new MCMachOStreamer(Context, std::move(MAB), std::move(OW),
+ std::move(CE), LabelSections);
 }
 
 // The AddrSig section uses a series of relocations to refer to the symbols 
that
diff --git a/llvm/lib/Object/ModuleSymbolTable.cpp 
b/llvm/lib/Object/ModuleSymbolTable.cpp
index d8f520ad02c2f2..fb36a88b9c7149 100644
--- a/llvm/lib/Object/ModuleSymbolTable.cpp
+++ b

[clang] [llvm] [MC] Remove Darwin SDK/Version from ObjFileInfo (PR #103025)

2024-08-13 Thread Alexis Engelke via cfe-commits


@@ -559,6 +559,9 @@ int main(int argc, char **argv) {
 std::unique_ptr(CE), *STI));
 if (NoExecStack)
   Str->initSections(true, *STI);
+if (TheTriple.isOSBinFormatMachO() && TheTriple.isOSDarwin())

aengelke wrote:

No. I just put it in front of all emitVersionForTarget for clarity.

https://github.com/llvm/llvm-project/pull/103025
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [MC] Remove Darwin SDK/Version from ObjFileInfo (PR #103025)

2024-08-13 Thread Alexis Engelke via cfe-commits


@@ -109,7 +109,6 @@ initializeRecordStreamer(const Module &M,
   MCContext MCCtx(TT, MAI.get(), MRI.get(), STI.get(), &SrcMgr);
   std::unique_ptr MOFI(
   T->createMCObjectFileInfo(MCCtx, /*PIC=*/false));
-  MOFI->setSDKVersion(M.getSDKVersion());

aengelke wrote:

I don't think so? I would *expect* that the information is always stored in the 
module -- and all call sites that create a MCObjectStreamer take the 
information from the module (the only reader of the MOFI fields was 
createMachOStreamer, but emitVersionForTarget is always (also) called from the 
AsmPrinter). I'm just 95% confident: tests pass + local code changes seem 
reasonable to me, but I certainly miss the "big picture" regarding LTO.

https://github.com/llvm/llvm-project/pull/103025
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libcxx] [lldb] [llvm] [mlir] [InstCombine] Don't look at ConstantData users (PR #103302)

2024-08-13 Thread Alexis Engelke via cfe-commits

https://github.com/aengelke edited 
https://github.com/llvm/llvm-project/pull/103302
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libcxx] [lldb] [llvm] [mlir] [InstCombine] Don't look at ConstantData users (PR #103302)

2024-08-13 Thread Alexis Engelke via cfe-commits

https://github.com/aengelke closed 
https://github.com/llvm/llvm-project/pull/103302
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [MC] Remove Darwin SDK/Version from ObjFileInfo (PR #103025)

2024-08-14 Thread Alexis Engelke via cfe-commits

https://github.com/aengelke closed 
https://github.com/llvm/llvm-project/pull/103025
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [MC] Emit a jump table size section (PR #101962)

2024-08-05 Thread Alexis Engelke via cfe-commits

aengelke wrote:

Is there a previous discussion (e.g., RFC) about this? Did you consider 
alternative approaches? (E.g., just a spontaneous idea, adding a specially 
named symbol for every jump table where the symbol size is the size of the jump 
table; entry size (4/8) could be encoded in the name like `$jt4`/`$jt8` (naming 
just for illustration).)

I'm not a fan of `.debug_llvm_jump_table_sizes` or adding a new section for 
this, but feel free to ignore my opinion. :)

https://github.com/llvm/llvm-project/pull/101962
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits