[Lldb-commits] [libc] [lld] [clang] [libcxx] [lldb] [mlir] [clang-tools-extra] [libcxxabi] [flang] [llvm] [openmp] [compiler-rt] [llvm] Support IFuncs on Darwin platforms (PR #73686)

2023-12-13 Thread Ahmed Bougacha via lldb-commits

https://github.com/ahmedbougacha commented:

Only a couple minor comments, LG otherwise, thanks!  The Subtarget weirdness is 
unfortunate but I can't say I have a better alternative

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


[Lldb-commits] [libcxx] [clang] [libcxxabi] [lld] [flang] [openmp] [mlir] [llvm] [libc] [compiler-rt] [clang-tools-extra] [lldb] [llvm] Support IFuncs on Darwin platforms (PR #73686)

2023-12-13 Thread Ahmed Bougacha via lldb-commits

https://github.com/ahmedbougacha edited 
https://github.com/llvm/llvm-project/pull/73686
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [clang] [openmp] [lld] [compiler-rt] [libc] [flang] [libcxxabi] [llvm] [libcxx] [clang-tools-extra] [mlir] [llvm] Support IFuncs on Darwin platforms (PR #73686)

2023-12-13 Thread Ahmed Bougacha via lldb-commits


@@ -599,6 +599,26 @@ class AsmPrinter : public MachineFunctionPass {
   /// instructions in verbose mode.
   virtual void emitImplicitDef(const MachineInstr *MI) const;
 
+  /// getSubtargetInfo() cannot be used where this is needed because we don't
+  /// have a MachineFunction when we're lowering a GlobalIFunc, and
+  /// getSubtargetInfo requires one. Override the implementation in targets
+  /// that support the Mach-O IFunc lowering.
+  virtual const MCSubtargetInfo *getIFuncMCSubtargetInfo() const {
+return nullptr;
+  }
+
+  virtual void emitMachOIFuncStubBody(Module &M, const GlobalIFunc &GI,
+  MCSymbol *LazyPointer) {

ahmedbougacha wrote:

Maybe pass the symbol string directly, since the implementations make their own 
symbol references anyway?  That way you also don't have to do the awkward 
de-mangle/re-mangle dance with the +1

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


[Lldb-commits] [llvm] [libcxxabi] [compiler-rt] [mlir] [openmp] [lldb] [flang] [clang-tools-extra] [libc] [lld] [libcxx] [clang] [llvm] Support IFuncs on Darwin platforms (PR #73686)

2023-12-13 Thread Ahmed Bougacha via lldb-commits


@@ -2147,24 +2148,80 @@ void AsmPrinter::emitGlobalIFunc(Module &M, const 
GlobalIFunc &GI) {
   assert(!TM.getTargetTriple().isOSBinFormatXCOFF() &&
  "IFunc is not supported on AIX.");
 
-  MCSymbol *Name = getSymbol(&GI);
+  auto EmitLinkage = [&](MCSymbol *Sym) {
+if (GI.hasExternalLinkage() || !MAI->getWeakRefDirective())
+  OutStreamer->emitSymbolAttribute(Sym, MCSA_Global);
+else if (GI.hasWeakLinkage() || GI.hasLinkOnceLinkage())
+  OutStreamer->emitSymbolAttribute(Sym, MCSA_WeakReference);
+else
+  assert(GI.hasLocalLinkage() && "Invalid ifunc linkage");
+  };
 
-  if (GI.hasExternalLinkage() || !MAI->getWeakRefDirective())
-OutStreamer->emitSymbolAttribute(Name, MCSA_Global);
-  else if (GI.hasWeakLinkage() || GI.hasLinkOnceLinkage())
-OutStreamer->emitSymbolAttribute(Name, MCSA_WeakReference);
-  else
-assert(GI.hasLocalLinkage() && "Invalid ifunc linkage");
+  if (TM.getTargetTriple().isOSBinFormatELF()) {
+MCSymbol *Name = getSymbol(&GI);
+EmitLinkage(Name);
+OutStreamer->emitSymbolAttribute(Name, MCSA_ELF_TypeIndFunction);
+emitVisibility(Name, GI.getVisibility());
+
+// Emit the directives as assignments aka .set:
+const MCExpr *Expr = lowerConstant(GI.getResolver());
+OutStreamer->emitAssignment(Name, Expr);
+MCSymbol *LocalAlias = getSymbolPreferLocal(GI);
+if (LocalAlias != Name)
+  OutStreamer->emitAssignment(LocalAlias, Expr);
+  } else if (TM.getTargetTriple().isOSBinFormatMachO() &&

ahmedbougacha wrote:

early return with if->fatal_error, for indentation?

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


[Lldb-commits] [lld] [clang] [libcxx] [llvm] [libc] [mlir] [libcxxabi] [openmp] [lldb] [clang-tools-extra] [compiler-rt] [flang] [llvm] Support IFuncs on Darwin platforms (PR #73686)

2023-12-14 Thread Ahmed Bougacha via lldb-commits


@@ -2169,8 +2169,11 @@ void AsmPrinter::emitGlobalIFunc(Module &M, const 
GlobalIFunc &GI) {
 MCSymbol *LocalAlias = getSymbolPreferLocal(GI);
 if (LocalAlias != Name)
   OutStreamer->emitAssignment(LocalAlias, Expr);
-  } else if (TM.getTargetTriple().isOSBinFormatMachO() &&
- getIFuncMCSubtargetInfo()) {
+
+return;
+  }
+
+  if (TM.getTargetTriple().isOSBinFormatMachO() && getIFuncMCSubtargetInfo()) {

ahmedbougacha wrote:

oh I meant literally:
```
  if (!TM.getTargetTriple().isOSBinFormatMachO() || !getIFuncMCSubtargetInfo())
  llvm::report_fatal_error("IFuncs are not supported on this platform");
```

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


[Lldb-commits] [clang-tools-extra] [libc] [openmp] [lld] [compiler-rt] [libcxxabi] [clang] [libcxx] [lldb] [mlir] [flang] [llvm] [llvm] Support IFuncs on Darwin platforms (PR #73686)

2023-12-14 Thread Ahmed Bougacha via lldb-commits

https://github.com/ahmedbougacha approved this pull request.

Neat, ty!

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


[Lldb-commits] [lldb] 6c4f250 - Revert "[lldb] [gdb-remote client] Refactor handling qSupported"

2021-04-12 Thread Ahmed Bougacha via lldb-commits

Author: Ahmed Bougacha
Date: 2021-04-12T18:06:09-07:00
New Revision: 6c4f2508e4278ac789230cb05f2bb56a8a7297dc

URL: 
https://github.com/llvm/llvm-project/commit/6c4f2508e4278ac789230cb05f2bb56a8a7297dc
DIFF: 
https://github.com/llvm/llvm-project/commit/6c4f2508e4278ac789230cb05f2bb56a8a7297dc.diff

LOG: Revert "[lldb] [gdb-remote client] Refactor handling qSupported"

This reverts commit 3842de49f6551f597b4c7c78caa8ba7003755cec.

It fails to build, with errors such as:
  GDBRemoteCommunicationClient.cpp:1005:20:
  error: no viable overloaded '='
  avail_name = compression;

Added: 


Modified: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index 2db985c632db1..c032fc20b5f3c 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -345,9 +345,6 @@ void GDBRemoteCommunicationClient::GetRemoteQSupported() {
   m_supports_qXfer_features_read = eLazyBoolNo;
   m_supports_qXfer_memory_map_read = eLazyBoolNo;
   m_supports_multiprocess = eLazyBoolNo;
-  m_supports_qEcho = eLazyBoolNo;
-  m_supports_QPassSignals = eLazyBoolNo;
-
   m_max_packet_size = UINT64_MAX; // It's supposed to always be there, but if
   // not, we assume no limit
 
@@ -365,51 +362,97 @@ void GDBRemoteCommunicationClient::GetRemoteQSupported() {
   if (SendPacketAndWaitForResponse(packet.GetString(), response,
/*send_async=*/false) ==
   PacketResult::Success) {
+const char *response_cstr = response.GetStringRef().data();
+
 // Hang on to the qSupported packet, so that platforms can do custom
 // configuration of the transport before attaching/launching the process.
-m_qSupported_response = response.GetStringRef().str();
-
-llvm::SmallVector server_features;
-response.GetStringRef().split(server_features, ';');
-
-for (auto x : server_features) {
-  if (x == "qXfer:auxv:read+")
-m_supports_qXfer_auxv_read = eLazyBoolYes;
-  else if (x == "qXfer:libraries-svr4:read+")
-m_supports_qXfer_libraries_svr4_read = eLazyBoolYes;
-  else if (x == "augmented-libraries-svr4-read") {
-m_supports_qXfer_libraries_svr4_read = eLazyBoolYes; // implied
-m_supports_augmented_libraries_svr4_read = eLazyBoolYes;
-  } else if (x == "qXfer:libraries:read+")
-m_supports_qXfer_libraries_read = eLazyBoolYes;
-  else if (x == "qXfer:features:read+")
-m_supports_qXfer_features_read = eLazyBoolYes;
-  else if (x == "qXfer:memory-map:read+")
-m_supports_qXfer_memory_map_read = eLazyBoolYes;
-  else if (x == "qEcho")
-m_supports_qEcho = eLazyBoolYes;
-  else if (x == "QPassSignals+")
-m_supports_QPassSignals = eLazyBoolYes;
-  else if (x == "multiprocess+")
-m_supports_multiprocess = eLazyBoolYes;
-  // Look for a list of compressions in the features list e.g.
-  // 
qXfer:features:read+;PacketSize=2;qEcho+;SupportedCompressions=zlib-
-  // deflate,lzma
-  else if (x.consume_front("SupportedCompressions=")) {
-llvm::SmallVector compressions;
-x.split(compressions, ',');
-if (!compressions.empty())
-  MaybeEnableCompression(compressions);
-  } else if (x.consume_front("PacketSize=")) {
-StringExtractorGDBRemote packet_response(x);
-m_max_packet_size =
-packet_response.GetHexMaxU64(/*little_endian=*/false, UINT64_MAX);
-if (m_max_packet_size == 0) {
-  m_max_packet_size = UINT64_MAX; // Must have been a garbled response
-  Log *log(
-  ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
-  LLDB_LOGF(log, "Garbled PacketSize spec in qSupported response");
+m_qSupported_response = response_cstr;
+
+if (::strstr(response_cstr, "qXfer:auxv:read+"))
+  m_supports_qXfer_auxv_read = eLazyBoolYes;
+if (::strstr(response_cstr, "qXfer:libraries-svr4:read+"))
+  m_supports_qXfer_libraries_svr4_read = eLazyBoolYes;
+if (::strstr(response_cstr, "augmented-libraries-svr4-read")) {
+  m_supports_qXfer_libraries_svr4_read = eLazyBoolYes; // implied
+  m_supports_augmented_libraries_svr4_read = eLazyBoolYes;
+}
+if (::strstr(response_cstr, "qXfer:libraries:read+"))
+  m_supports_qXfer_libraries_read = eLazyBoolYes;
+if (::strstr(response_cstr, "qXfer:features:read+"))
+  m_supports_qXfer_features_read = eLazyBoolYes;
+if (::strstr(response_cstr, "qXfer:memory-map:read+"))
+  m_supports_qXfer_memory_map_r