[clang] [clang-repl] Keep the first llvm::Module empty to avoid invalid memory access. (PR #89031)

2024-04-19 Thread Lang Hames via cfe-commits

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

If there's a trivial reproducer for the original issue it may be worth adding 
it as a regression test.

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


[clang] b251897 - Re-apply "[ORC] Add N_SO and N_OSO stabs entries to MachO debug..." with fixes.

2023-09-28 Thread Lang Hames via cfe-commits

Author: Lang Hames
Date: 2023-09-28T21:34:14-07:00
New Revision: b2518971d82331b09d7630ac1aecbb49e876a496

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

LOG: Re-apply "[ORC] Add N_SO and N_OSO stabs entries to MachO debug..." with 
fixes.

This re-applies db51e572893, which was reverted in 05b1a2cb3e6 due to bot
failures. The DebuggerSupportPlugin now depends on DWARF, so it has been moved
to the new OrcDebugging library (as has the enableDebuggerSupport API).

Added: 
llvm/include/llvm/ExecutionEngine/Orc/Debugging/DebuggerSupport.h
llvm/include/llvm/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.h
llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupport.cpp
llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.cpp

Modified: 
clang/lib/Interpreter/CMakeLists.txt
clang/lib/Interpreter/IncrementalExecutor.cpp
llvm/lib/ExecutionEngine/Orc/CMakeLists.txt
llvm/lib/ExecutionEngine/Orc/Debugging/CMakeLists.txt
llvm/tools/lli/CMakeLists.txt
llvm/tools/lli/lli.cpp
llvm/tools/llvm-jitlink/llvm-jitlink.cpp

Removed: 
llvm/include/llvm/ExecutionEngine/Orc/DebuggerSupport.h
llvm/include/llvm/ExecutionEngine/Orc/DebuggerSupportPlugin.h
llvm/lib/ExecutionEngine/Orc/DebuggerSupport.cpp
llvm/lib/ExecutionEngine/Orc/DebuggerSupportPlugin.cpp



diff  --git a/clang/lib/Interpreter/CMakeLists.txt 
b/clang/lib/Interpreter/CMakeLists.txt
index 79d2cba67f54c4d..84f6ca5271d2ab0 100644
--- a/clang/lib/Interpreter/CMakeLists.txt
+++ b/clang/lib/Interpreter/CMakeLists.txt
@@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS
MC
Option
OrcJit
+   OrcDebugging
OrcShared
OrcTargetProcess
Support

diff  --git a/clang/lib/Interpreter/IncrementalExecutor.cpp 
b/clang/lib/Interpreter/IncrementalExecutor.cpp
index 2692d0618b8649e..40bcef94797d43d 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.cpp
+++ b/clang/lib/Interpreter/IncrementalExecutor.cpp
@@ -17,7 +17,7 @@
 #include "clang/Interpreter/PartialTranslationUnit.h"
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
 #include "llvm/ExecutionEngine/Orc/CompileUtils.h"
-#include "llvm/ExecutionEngine/Orc/DebuggerSupport.h"
+#include "llvm/ExecutionEngine/Orc/Debugging/DebuggerSupport.h"
 #include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
 #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
 #include "llvm/ExecutionEngine/Orc/LLJIT.h"

diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/DebuggerSupport.h 
b/llvm/include/llvm/ExecutionEngine/Orc/Debugging/DebuggerSupport.h
similarity index 100%
rename from llvm/include/llvm/ExecutionEngine/Orc/DebuggerSupport.h
rename to llvm/include/llvm/ExecutionEngine/Orc/Debugging/DebuggerSupport.h

diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/DebuggerSupportPlugin.h 
b/llvm/include/llvm/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.h
similarity index 100%
rename from llvm/include/llvm/ExecutionEngine/Orc/DebuggerSupportPlugin.h
rename to 
llvm/include/llvm/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.h

diff  --git a/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt 
b/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt
index 49f202244f96c17..fdb628ac84d4356 100644
--- a/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt
+++ b/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt
@@ -13,8 +13,6 @@ add_llvm_component_library(LLVMOrcJIT
   CompileUtils.cpp
   Core.cpp
   DebugObjectManagerPlugin.cpp
-  DebuggerSupport.cpp
-  DebuggerSupportPlugin.cpp
   DebugUtils.cpp
   EPCDynamicLibrarySearchGenerator.cpp
   EPCDebugObjectRegistrar.cpp

diff  --git a/llvm/lib/ExecutionEngine/Orc/Debugging/CMakeLists.txt 
b/llvm/lib/ExecutionEngine/Orc/Debugging/CMakeLists.txt
index 216761d8209084c..2c3b2bd877f0f11 100644
--- a/llvm/lib/ExecutionEngine/Orc/Debugging/CMakeLists.txt
+++ b/llvm/lib/ExecutionEngine/Orc/Debugging/CMakeLists.txt
@@ -4,6 +4,8 @@ endif()
 
 add_llvm_component_library(LLVMOrcDebugging
   DebugInfoSupport.cpp
+  DebuggerSupport.cpp
+  DebuggerSupportPlugin.cpp
   PerfSupportPlugin.cpp
 
   ADDITIONAL_HEADER_DIRS

diff  --git a/llvm/lib/ExecutionEngine/Orc/DebuggerSupport.cpp 
b/llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupport.cpp
similarity index 94%
rename from llvm/lib/ExecutionEngine/Orc/DebuggerSupport.cpp
rename to llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupport.cpp
index 68d68f07b586203..9ba6dd90f50de51 100644
--- a/llvm/lib/ExecutionEngine/Orc/DebuggerSupport.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupport.cpp
@@ -6,9 +6,9 @@
 //
 
//===--===//
 
-#include "llvm/ExecutionEngine/Orc/DebuggerSupport.h"
+#include "llvm/ExecutionEngine/Orc/Debugging/DebuggerSupport.h"
 #include "llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h"
-#include 

[clang] 53a87b4 - [clang-repl] Disable LSan in clang-repl.

2023-09-27 Thread Lang Hames via cfe-commits

Author: Lang Hames
Date: 2023-09-27T21:39:48-07:00
New Revision: 53a87b4a6903c0c47337ca18697bb6355cc087d4

URL: 
https://github.com/llvm/llvm-project/commit/53a87b4a6903c0c47337ca18697bb6355cc087d4
DIFF: 
https://github.com/llvm/llvm-project/commit/53a87b4a6903c0c47337ca18697bb6355cc087d4.diff

LOG: [clang-repl] Disable LSan in clang-repl.

https://llvm.org/github.com/llvm/llvm-project/issues/67586.

Added: 


Modified: 
clang/tools/clang-repl/ClangRepl.cpp

Removed: 




diff  --git a/clang/tools/clang-repl/ClangRepl.cpp 
b/clang/tools/clang-repl/ClangRepl.cpp
index a29a2ebac434ab5..5663c2c5a6c9285 100644
--- a/clang/tools/clang-repl/ClangRepl.cpp
+++ b/clang/tools/clang-repl/ClangRepl.cpp
@@ -24,6 +24,14 @@
 #include "llvm/Support/TargetSelect.h"
 #include 
 
+// Disable LSan for this test.
+// FIXME: Re-enable once we can assume GCC 13.2 or higher.
+// https://llvm.org/github.com/llvm/llvm-project/issues/67586.
+#if LLVM_ADDRESS_SANITIZER_BUILD || LLVM_HWADDRESS_SANITIZER_BUILD
+#include 
+LLVM_ATTRIBUTE_USED int __lsan_is_turned_off() { return 1; }
+#endif
+
 static llvm::cl::opt CudaEnabled("cuda", llvm::cl::Hidden);
 static llvm::cl::opt CudaPath("cuda-path", llvm::cl::Hidden);
 static llvm::cl::opt OffloadArch("offload-arch", 
llvm::cl::Hidden);



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 61b0f12 - Re-apply "[ORC][LLJIT] Move enable-debugger-support utility out of..."

2023-09-27 Thread Lang Hames via cfe-commits

Author: Lang Hames
Date: 2023-09-27T13:24:02-07:00
New Revision: 61b0f12d6b9cdcb6bb3dd679e3a3c36fa94daeae

URL: 
https://github.com/llvm/llvm-project/commit/61b0f12d6b9cdcb6bb3dd679e3a3c36fa94daeae
DIFF: 
https://github.com/llvm/llvm-project/commit/61b0f12d6b9cdcb6bb3dd679e3a3c36fa94daeae.diff

LOG: Re-apply "[ORC][LLJIT] Move enable-debugger-support utility out of..."

This re-applies e1a5bb59b91, which was reverted in e5f169f91a8 due to LSan
failures on some bots (see https://github.com/llvm/llvm-project/issues/67586).
The LSan failures were not caused by this patch (just exposed by it), so LSan
was disabled for the failing test in 47625fea5e3. This should be safe to
re-land now.

Added: 
llvm/include/llvm/ExecutionEngine/Orc/DebuggerSupport.h
llvm/lib/ExecutionEngine/Orc/DebuggerSupport.cpp

Modified: 
clang/lib/Interpreter/IncrementalExecutor.cpp
clang/tools/clang-repl/ClangRepl.cpp
clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
clang/unittests/Interpreter/InterpreterTest.cpp
llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
llvm/lib/ExecutionEngine/Orc/CMakeLists.txt
llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
llvm/tools/lli/lli.cpp

Removed: 




diff  --git a/clang/lib/Interpreter/IncrementalExecutor.cpp 
b/clang/lib/Interpreter/IncrementalExecutor.cpp
index 2c4dfc9a611e021..2692d0618b8649e 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.cpp
+++ b/clang/lib/Interpreter/IncrementalExecutor.cpp
@@ -17,6 +17,7 @@
 #include "clang/Interpreter/PartialTranslationUnit.h"
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
 #include "llvm/ExecutionEngine/Orc/CompileUtils.h"
+#include "llvm/ExecutionEngine/Orc/DebuggerSupport.h"
 #include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
 #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
 #include "llvm/ExecutionEngine/Orc/LLJIT.h"
@@ -46,8 +47,13 @@ 
IncrementalExecutor::IncrementalExecutor(llvm::orc::ThreadSafeContext ,
   JTMB.addFeatures(TI.getTargetOpts().Features);
   LLJITBuilder Builder;
   Builder.setJITTargetMachineBuilder(JTMB);
-  // Enable debugging of JIT'd code (only works on JITLink for ELF and MachO).
-  Builder.setEnableDebuggerSupport(true);
+  Builder.setPrePlatformSetup(
+  [](LLJIT ) {
+// Try to enable debugging of JIT'd code (only works with JITLink for
+// ELF and MachO).
+consumeError(enableDebuggerSupport(J));
+return llvm::Error::success();
+  });
 
   if (auto JitOrErr = Builder.create())
 Jit = std::move(*JitOrErr);

diff  --git a/clang/tools/clang-repl/ClangRepl.cpp 
b/clang/tools/clang-repl/ClangRepl.cpp
index 51741fd1a27ef4a..a29a2ebac434ab5 100644
--- a/clang/tools/clang-repl/ClangRepl.cpp
+++ b/clang/tools/clang-repl/ClangRepl.cpp
@@ -152,9 +152,7 @@ int main(int argc, const char **argv) {
   llvm::InitializeAllAsmPrinters();
 
   if (OptHostSupportsJit) {
-auto J = llvm::orc::LLJITBuilder()
-   .setEnableDebuggerSupport(true)
-   .create();
+auto J = llvm::orc::LLJITBuilder().create();
 if (J)
   llvm::outs() << "true\n";
 else {

diff  --git 
a/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp 
b/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
index 4709a9479edaffc..2f1c4efb381f00b 100644
--- a/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
+++ b/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
@@ -60,9 +60,7 @@ TEST(InterpreterTest, CatchException) {
   llvm::InitializeNativeTargetAsmPrinter();
 
   {
-auto J = llvm::orc::LLJITBuilder()
- .setEnableDebuggerSupport(true)
- .create();
+auto J = llvm::orc::LLJITBuilder().create();
 if (!J) {
   // The platform does not support JITs.
   // Using llvm::consumeError will require typeinfo for ErrorInfoBase, we

diff  --git a/clang/unittests/Interpreter/InterpreterTest.cpp 
b/clang/unittests/Interpreter/InterpreterTest.cpp
index 62e5bacbdd0b6d8..5f2911e9a7adad3 100644
--- a/clang/unittests/Interpreter/InterpreterTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterTest.cpp
@@ -191,9 +191,7 @@ static std::string MangleName(NamedDecl *ND) {
 }
 
 static bool HostSupportsJit() {
-  auto J = llvm::orc::LLJITBuilder()
- .setEnableDebuggerSupport(true)
- .create();
+  auto J = llvm::orc::LLJITBuilder().create();
   if (J)
 return true;
   LLVMConsumeError(llvm::wrap(J.takeError()));

diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/DebuggerSupport.h 
b/llvm/include/llvm/ExecutionEngine/Orc/DebuggerSupport.h
new file mode 100644
index 000..1b47d7d41bb9b5a
--- /dev/null
+++ b/llvm/include/llvm/ExecutionEngine/Orc/DebuggerSupport.h
@@ -0,0 +1,28 @@
+//===-- DebugerSupport.h - Utils for enabling debugger support --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the 

[clang] 31e01e9 - [clang-repl] Update FIXME based on feedback from @zero9178.

2023-09-27 Thread Lang Hames via cfe-commits

Author: Lang Hames
Date: 2023-09-27T13:04:18-07:00
New Revision: 31e01e9388667b9b34804f37202e1fed76e98030

URL: 
https://github.com/llvm/llvm-project/commit/31e01e9388667b9b34804f37202e1fed76e98030
DIFF: 
https://github.com/llvm/llvm-project/commit/31e01e9388667b9b34804f37202e1fed76e98030.diff

LOG: [clang-repl] Update FIXME based on feedback from @zero9178.

See https://github.com/llvm/llvm-project/issues/67586.

Added: 


Modified: 
clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp

Removed: 




diff  --git 
a/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp 
b/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
index adff020d3a09887..4709a9479edaffc 100644
--- a/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
+++ b/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
@@ -30,7 +30,7 @@
 #include "gtest/gtest.h"
 
 // Disable LSan for this test.
-// FIXME: Re-enable this once we track down the leak described in
+// FIXME: Re-enable once we can assume GCC 13.2 or higher.
 // https://llvm.org/github.com/llvm/llvm-project/issues/67586.
 #if LLVM_ADDRESS_SANITIZER_BUILD || LLVM_HWADDRESS_SANITIZER_BUILD
 #include 



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b4a8999 - Revert "[test][clang-repl][Orc] Lsan report workaround"

2023-09-27 Thread Lang Hames via cfe-commits

Author: Lang Hames
Date: 2023-09-27T11:44:33-07:00
New Revision: b4a89a5edf08af9e03324274ebdce7e032ce

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

LOG: Revert "[test][clang-repl][Orc] Lsan report workaround"

This reverts commit b4b4d8bd61d8de946e130beff5049a4ab13e155d. Lsan has been
disabled in the unittest itself in 47625fea5e376082fca65d0ac644f07957605d86,
so this workaround is no longer needed.

Added: 


Modified: 
clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt

Removed: 




diff  --git a/clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt 
b/clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt
index fe38eea3155a07c..5a6597d1b6728f9 100644
--- a/clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt
+++ b/clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt
@@ -23,7 +23,4 @@ target_link_libraries(ClangReplInterpreterExceptionTests 
PUBLIC
   )
 add_dependencies(ClangReplInterpreterExceptionTests clang-resource-headers)
 
-# export_executable_symbols triggers Lsan report.
-if (NOT LLVM_USE_SANITIZER MATCHES ".*Address.*")
-  export_executable_symbols(ClangReplInterpreterExceptionTests)
-endif()
+export_executable_symbols(ClangReplInterpreterExceptionTests)



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 47625fe - [clang-repl] Disable LSan in InterpreterExceptionTest.

2023-09-27 Thread Lang Hames via cfe-commits

Author: Lang Hames
Date: 2023-09-27T11:36:14-07:00
New Revision: 47625fea5e376082fca65d0ac644f07957605d86

URL: 
https://github.com/llvm/llvm-project/commit/47625fea5e376082fca65d0ac644f07957605d86
DIFF: 
https://github.com/llvm/llvm-project/commit/47625fea5e376082fca65d0ac644f07957605d86.diff

LOG: [clang-repl] Disable LSan in InterpreterExceptionTest.

Disabling LSan for this test until we can track down the leak described in
https://github.com/llvm/llvm-project/issues/67586.

Added: 


Modified: 
clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp

Removed: 




diff  --git 
a/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp 
b/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
index 8700f506d9b17d4..adff020d3a09887 100644
--- a/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
+++ b/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
@@ -29,6 +29,14 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
+// Disable LSan for this test.
+// FIXME: Re-enable this once we track down the leak described in
+// https://llvm.org/github.com/llvm/llvm-project/issues/67586.
+#if LLVM_ADDRESS_SANITIZER_BUILD || LLVM_HWADDRESS_SANITIZER_BUILD
+#include 
+LLVM_ATTRIBUTE_USED int __lsan_is_turned_off() { return 1; }
+#endif
+
 using namespace clang;
 
 namespace {



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e5f169f - Revert "[ORC][LLJIT] Move enable-debugger-support utility out of LLJITBuilder."

2023-09-22 Thread Lang Hames via cfe-commits

Author: Lang Hames
Date: 2023-09-22T21:43:41-07:00
New Revision: e5f169f91a86af3490d9251387b3f5455941bb83

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

LOG: Revert "[ORC][LLJIT] Move enable-debugger-support utility out of 
LLJITBuilder."

This reverts commit e1a5bb59b91d60c0d87feb78f0e0614589a4c927 while I
investigate the bot failure at
https://lab.llvm.org/buildbot/#/builders/168/builds/15831

Added: 


Modified: 
clang/lib/Interpreter/IncrementalExecutor.cpp
clang/tools/clang-repl/ClangRepl.cpp
clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
clang/unittests/Interpreter/InterpreterTest.cpp
llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
llvm/lib/ExecutionEngine/Orc/CMakeLists.txt
llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
llvm/tools/lli/lli.cpp

Removed: 
llvm/include/llvm/ExecutionEngine/Orc/DebuggerSupport.h
llvm/lib/ExecutionEngine/Orc/DebuggerSupport.cpp



diff  --git a/clang/lib/Interpreter/IncrementalExecutor.cpp 
b/clang/lib/Interpreter/IncrementalExecutor.cpp
index 2692d0618b8649e..2c4dfc9a611e021 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.cpp
+++ b/clang/lib/Interpreter/IncrementalExecutor.cpp
@@ -17,7 +17,6 @@
 #include "clang/Interpreter/PartialTranslationUnit.h"
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
 #include "llvm/ExecutionEngine/Orc/CompileUtils.h"
-#include "llvm/ExecutionEngine/Orc/DebuggerSupport.h"
 #include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
 #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
 #include "llvm/ExecutionEngine/Orc/LLJIT.h"
@@ -47,13 +46,8 @@ 
IncrementalExecutor::IncrementalExecutor(llvm::orc::ThreadSafeContext ,
   JTMB.addFeatures(TI.getTargetOpts().Features);
   LLJITBuilder Builder;
   Builder.setJITTargetMachineBuilder(JTMB);
-  Builder.setPrePlatformSetup(
-  [](LLJIT ) {
-// Try to enable debugging of JIT'd code (only works with JITLink for
-// ELF and MachO).
-consumeError(enableDebuggerSupport(J));
-return llvm::Error::success();
-  });
+  // Enable debugging of JIT'd code (only works on JITLink for ELF and MachO).
+  Builder.setEnableDebuggerSupport(true);
 
   if (auto JitOrErr = Builder.create())
 Jit = std::move(*JitOrErr);

diff  --git a/clang/tools/clang-repl/ClangRepl.cpp 
b/clang/tools/clang-repl/ClangRepl.cpp
index a29a2ebac434ab5..51741fd1a27ef4a 100644
--- a/clang/tools/clang-repl/ClangRepl.cpp
+++ b/clang/tools/clang-repl/ClangRepl.cpp
@@ -152,7 +152,9 @@ int main(int argc, const char **argv) {
   llvm::InitializeAllAsmPrinters();
 
   if (OptHostSupportsJit) {
-auto J = llvm::orc::LLJITBuilder().create();
+auto J = llvm::orc::LLJITBuilder()
+   .setEnableDebuggerSupport(true)
+   .create();
 if (J)
   llvm::outs() << "true\n";
 else {

diff  --git 
a/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp 
b/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
index 70e10b1e53bd9d6..8700f506d9b17d4 100644
--- a/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
+++ b/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
@@ -52,7 +52,9 @@ TEST(InterpreterTest, CatchException) {
   llvm::InitializeNativeTargetAsmPrinter();
 
   {
-auto J = llvm::orc::LLJITBuilder().create();
+auto J = llvm::orc::LLJITBuilder()
+ .setEnableDebuggerSupport(true)
+ .create();
 if (!J) {
   // The platform does not support JITs.
   // Using llvm::consumeError will require typeinfo for ErrorInfoBase, we

diff  --git a/clang/unittests/Interpreter/InterpreterTest.cpp 
b/clang/unittests/Interpreter/InterpreterTest.cpp
index 5f2911e9a7adad3..62e5bacbdd0b6d8 100644
--- a/clang/unittests/Interpreter/InterpreterTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterTest.cpp
@@ -191,7 +191,9 @@ static std::string MangleName(NamedDecl *ND) {
 }
 
 static bool HostSupportsJit() {
-  auto J = llvm::orc::LLJITBuilder().create();
+  auto J = llvm::orc::LLJITBuilder()
+ .setEnableDebuggerSupport(true)
+ .create();
   if (J)
 return true;
   LLVMConsumeError(llvm::wrap(J.takeError()));

diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/DebuggerSupport.h 
b/llvm/include/llvm/ExecutionEngine/Orc/DebuggerSupport.h
deleted file mode 100644
index 1b47d7d41bb9b5a..000
--- a/llvm/include/llvm/ExecutionEngine/Orc/DebuggerSupport.h
+++ /dev/null
@@ -1,28 +0,0 @@
-//===-- DebugerSupport.h - Utils for enabling debugger support --*- C++ 
-*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 

[clang] e1a5bb5 - [ORC][LLJIT] Move enable-debugger-support utility out of LLJITBuilder.

2023-09-22 Thread Lang Hames via cfe-commits

Author: Lang Hames
Date: 2023-09-22T16:18:20-07:00
New Revision: e1a5bb59b91d60c0d87feb78f0e0614589a4c927

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

LOG: [ORC][LLJIT] Move enable-debugger-support utility out of LLJITBuilder.

This change means that debugger support only needs to be linked in if it's
used. The code size of debugger support is expected to increase as we improve
it (e.g. pulling in DWARF parsing), so making it an optional extra is useful
for controlling final binary sizes.

Added: 
llvm/include/llvm/ExecutionEngine/Orc/DebuggerSupport.h
llvm/lib/ExecutionEngine/Orc/DebuggerSupport.cpp

Modified: 
clang/lib/Interpreter/IncrementalExecutor.cpp
clang/tools/clang-repl/ClangRepl.cpp
clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
clang/unittests/Interpreter/InterpreterTest.cpp
llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
llvm/lib/ExecutionEngine/Orc/CMakeLists.txt
llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
llvm/tools/lli/lli.cpp

Removed: 




diff  --git a/clang/lib/Interpreter/IncrementalExecutor.cpp 
b/clang/lib/Interpreter/IncrementalExecutor.cpp
index 2c4dfc9a611e021..2692d0618b8649e 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.cpp
+++ b/clang/lib/Interpreter/IncrementalExecutor.cpp
@@ -17,6 +17,7 @@
 #include "clang/Interpreter/PartialTranslationUnit.h"
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
 #include "llvm/ExecutionEngine/Orc/CompileUtils.h"
+#include "llvm/ExecutionEngine/Orc/DebuggerSupport.h"
 #include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
 #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
 #include "llvm/ExecutionEngine/Orc/LLJIT.h"
@@ -46,8 +47,13 @@ 
IncrementalExecutor::IncrementalExecutor(llvm::orc::ThreadSafeContext ,
   JTMB.addFeatures(TI.getTargetOpts().Features);
   LLJITBuilder Builder;
   Builder.setJITTargetMachineBuilder(JTMB);
-  // Enable debugging of JIT'd code (only works on JITLink for ELF and MachO).
-  Builder.setEnableDebuggerSupport(true);
+  Builder.setPrePlatformSetup(
+  [](LLJIT ) {
+// Try to enable debugging of JIT'd code (only works with JITLink for
+// ELF and MachO).
+consumeError(enableDebuggerSupport(J));
+return llvm::Error::success();
+  });
 
   if (auto JitOrErr = Builder.create())
 Jit = std::move(*JitOrErr);

diff  --git a/clang/tools/clang-repl/ClangRepl.cpp 
b/clang/tools/clang-repl/ClangRepl.cpp
index 51741fd1a27ef4a..a29a2ebac434ab5 100644
--- a/clang/tools/clang-repl/ClangRepl.cpp
+++ b/clang/tools/clang-repl/ClangRepl.cpp
@@ -152,9 +152,7 @@ int main(int argc, const char **argv) {
   llvm::InitializeAllAsmPrinters();
 
   if (OptHostSupportsJit) {
-auto J = llvm::orc::LLJITBuilder()
-   .setEnableDebuggerSupport(true)
-   .create();
+auto J = llvm::orc::LLJITBuilder().create();
 if (J)
   llvm::outs() << "true\n";
 else {

diff  --git 
a/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp 
b/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
index 8700f506d9b17d4..70e10b1e53bd9d6 100644
--- a/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
+++ b/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
@@ -52,9 +52,7 @@ TEST(InterpreterTest, CatchException) {
   llvm::InitializeNativeTargetAsmPrinter();
 
   {
-auto J = llvm::orc::LLJITBuilder()
- .setEnableDebuggerSupport(true)
- .create();
+auto J = llvm::orc::LLJITBuilder().create();
 if (!J) {
   // The platform does not support JITs.
   // Using llvm::consumeError will require typeinfo for ErrorInfoBase, we

diff  --git a/clang/unittests/Interpreter/InterpreterTest.cpp 
b/clang/unittests/Interpreter/InterpreterTest.cpp
index 62e5bacbdd0b6d8..5f2911e9a7adad3 100644
--- a/clang/unittests/Interpreter/InterpreterTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterTest.cpp
@@ -191,9 +191,7 @@ static std::string MangleName(NamedDecl *ND) {
 }
 
 static bool HostSupportsJit() {
-  auto J = llvm::orc::LLJITBuilder()
- .setEnableDebuggerSupport(true)
- .create();
+  auto J = llvm::orc::LLJITBuilder().create();
   if (J)
 return true;
   LLVMConsumeError(llvm::wrap(J.takeError()));

diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/DebuggerSupport.h 
b/llvm/include/llvm/ExecutionEngine/Orc/DebuggerSupport.h
new file mode 100644
index 000..1b47d7d41bb9b5a
--- /dev/null
+++ b/llvm/include/llvm/ExecutionEngine/Orc/DebuggerSupport.h
@@ -0,0 +1,28 @@
+//===-- DebugerSupport.h - Utils for enabling debugger support --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See 

[clang] f2b8666 - [ORC][clang-repl] Fix clang-repl -host-supports-jit option after 122ebe3b500.

2023-08-26 Thread Lang Hames via cfe-commits

Author: Lang Hames
Date: 2023-08-26T19:46:33-07:00
New Revision: f2b866653169d479a964f99b7679738742f6a6a2

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

LOG: [ORC][clang-repl] Fix clang-repl -host-supports-jit option after 
122ebe3b500.

Same fix as 8a62d6ba7e: We need to make sure that the supports-JIT check uses
the same JIT config that will be used by the clang-repl tool.

Added: 


Modified: 
clang/tools/clang-repl/ClangRepl.cpp

Removed: 




diff  --git a/clang/tools/clang-repl/ClangRepl.cpp 
b/clang/tools/clang-repl/ClangRepl.cpp
index f46452d9e10d1a..535866b8495eff 100644
--- a/clang/tools/clang-repl/ClangRepl.cpp
+++ b/clang/tools/clang-repl/ClangRepl.cpp
@@ -87,7 +87,9 @@ int main(int argc, const char **argv) {
   llvm::InitializeAllAsmPrinters();
 
   if (OptHostSupportsJit) {
-auto J = llvm::orc::LLJITBuilder().create();
+auto J = llvm::orc::LLJITBuilder()
+   .setEnableDebuggerSupport(true)
+   .create();
 if (J)
   llvm::outs() << "true\n";
 else {



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 86258bd - [ORC][clang-repl] Fix another unit test after 122ebe3b500.

2023-08-24 Thread Lang Hames via cfe-commits

Author: Lang Hames
Date: 2023-08-24T08:20:07-07:00
New Revision: 86258bda2016323d32efbe6a298654cd77cde644

URL: 
https://github.com/llvm/llvm-project/commit/86258bda2016323d32efbe6a298654cd77cde644
DIFF: 
https://github.com/llvm/llvm-project/commit/86258bda2016323d32efbe6a298654cd77cde644.diff

LOG: [ORC][clang-repl] Fix another unit test after 122ebe3b500.

Same fix as 8a62d6ba7e: We need to make sure that the supports-JIT check uses
the same JIT config that will be used in the actual test.

Added: 


Modified: 
clang/unittests/Interpreter/InterpreterTest.cpp

Removed: 




diff  --git a/clang/unittests/Interpreter/InterpreterTest.cpp 
b/clang/unittests/Interpreter/InterpreterTest.cpp
index 338003cd9851c9..1800bff153b713 100644
--- a/clang/unittests/Interpreter/InterpreterTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterTest.cpp
@@ -191,7 +191,9 @@ static std::string MangleName(NamedDecl *ND) {
 }
 
 static bool HostSupportsJit() {
-  auto J = llvm::orc::LLJITBuilder().create();
+  auto J = llvm::orc::LLJITBuilder()
+ .setEnableDebuggerSupport(true)
+ .create();
   if (J)
 return true;
   LLVMConsumeError(llvm::wrap(J.takeError()));



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8a62d6b - [ORC][clang-repl] Fix UnitTest after 122ebe3b500.

2023-08-23 Thread Lang Hames via cfe-commits

Author: Lang Hames
Date: 2023-08-23T17:19:07-07:00
New Revision: 8a62d6ba7edc3a7d397e52884a9ce63b4e579ae1

URL: 
https://github.com/llvm/llvm-project/commit/8a62d6ba7edc3a7d397e52884a9ce63b4e579ae1
DIFF: 
https://github.com/llvm/llvm-project/commit/8a62d6ba7edc3a7d397e52884a9ce63b4e579ae1.diff

LOG: [ORC][clang-repl] Fix UnitTest after 122ebe3b500.

Commit 122ebe3b500 changed the way that we look up eh-frame registration
functions. This made LLJIT work "out of the box" in some Linux configs that
didn't work before, but caused InterpreterExceptionTest to start failing:
The test was skipped if a construction of a basic LLJIT config failed, but the
test actually depended on debugger support working too. When the basic config
started working we no longer skipped the test, then failed due to missing
debugger support. I've extended the skip-test check to include the debugger
support requirement, which should fix the issue.

Added: 


Modified: 
clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp

Removed: 




diff  --git 
a/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp 
b/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
index 70e10b1e53bd9d..8700f506d9b17d 100644
--- a/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
+++ b/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
@@ -52,7 +52,9 @@ TEST(InterpreterTest, CatchException) {
   llvm::InitializeNativeTargetAsmPrinter();
 
   {
-auto J = llvm::orc::LLJITBuilder().create();
+auto J = llvm::orc::LLJITBuilder()
+ .setEnableDebuggerSupport(true)
+ .create();
 if (!J) {
   // The platform does not support JITs.
   // Using llvm::consumeError will require typeinfo for ErrorInfoBase, we



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 231107a - Re-apply "[ORC] LLJIT updates: ExecutorNativePlatform, default ..." with fixes.

2023-04-07 Thread Lang Hames via cfe-commits

Author: Lang Hames
Date: 2023-04-08T02:40:58Z
New Revision: 231107a8b5be77d1c76975b0363976ba3211fa37

URL: 
https://github.com/llvm/llvm-project/commit/231107a8b5be77d1c76975b0363976ba3211fa37
DIFF: 
https://github.com/llvm/llvm-project/commit/231107a8b5be77d1c76975b0363976ba3211fa37.diff

LOG: Re-apply "[ORC] LLJIT updates: ExecutorNativePlatform, default ..." with 
fixes.

This reapplies 371cb1af61d, which was reverted in 0b2240eda01 due to bot
failures.

The clang-repl test failure is fixed by dropping the process symbols definition
generator that was manually attached to the main JITDylib, since LLJIT now
exposes process symbols by default. (The bug was triggered when JIT'd code used
the process atexit provided by the generator, rather than the JIT atexit which
has been moved into the platform JITDylib).

Any LLJIT clients that see crashes in static destructors should likewise remove
any process symbol generators attached to their main JITDylib.

Added: 


Modified: 
clang/lib/Interpreter/IncrementalExecutor.cpp
llvm/examples/OrcV2Examples/CMakeLists.txt

llvm/examples/OrcV2Examples/LLJITWithExecutorProcessControl/LLJITWithExecutorProcessControl.cpp

llvm/examples/OrcV2Examples/LLJITWithGDBRegistrationListener/LLJITWithGDBRegistrationListener.cpp

llvm/examples/OrcV2Examples/LLJITWithObjectLinkingLayerPlugin/LLJITWithObjectLinkingLayerPlugin.cpp
llvm/include/llvm/ExecutionEngine/Orc/COFFPlatform.h
llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp
llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
llvm/test/ExecutionEngine/OrcLazy/emulated-tls.ll
llvm/tools/lli/lli.cpp

Removed: 

llvm/examples/OrcV2Examples/OrcV2CBindingsReflectProcessSymbols/CMakeLists.txt

llvm/examples/OrcV2Examples/OrcV2CBindingsReflectProcessSymbols/OrcV2CBindingsReflectProcessSymbols.c



diff  --git a/clang/lib/Interpreter/IncrementalExecutor.cpp 
b/clang/lib/Interpreter/IncrementalExecutor.cpp
index 37d230b61f766..d744270d486a1 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.cpp
+++ b/clang/lib/Interpreter/IncrementalExecutor.cpp
@@ -43,15 +43,6 @@ 
IncrementalExecutor::IncrementalExecutor(llvm::orc::ThreadSafeContext ,
 Err = JitOrErr.takeError();
 return;
   }
-
-  const char Pref = Jit->getDataLayout().getGlobalPrefix();
-  // Discover symbols from the process as a fallback.
-  if (auto PSGOrErr = 
DynamicLibrarySearchGenerator::GetForCurrentProcess(Pref))
-Jit->getMainJITDylib().addGenerator(std::move(*PSGOrErr));
-  else {
-Err = PSGOrErr.takeError();
-return;
-  }
 }
 
 IncrementalExecutor::~IncrementalExecutor() {}

diff  --git a/llvm/examples/OrcV2Examples/CMakeLists.txt 
b/llvm/examples/OrcV2Examples/CMakeLists.txt
index af738e7bcb309..f1189e4ef96ca 100644
--- a/llvm/examples/OrcV2Examples/CMakeLists.txt
+++ b/llvm/examples/OrcV2Examples/CMakeLists.txt
@@ -14,7 +14,6 @@ add_subdirectory(OrcV2CBindingsBasicUsage)
 add_subdirectory(OrcV2CBindingsDumpObjects)
 add_subdirectory(OrcV2CBindingsIRTransforms)
 add_subdirectory(OrcV2CBindingsMCJITLikeMemoryManager)
-add_subdirectory(OrcV2CBindingsReflectProcessSymbols)
 add_subdirectory(OrcV2CBindingsRemovableCode)
 add_subdirectory(OrcV2CBindingsLazy)
 add_subdirectory(OrcV2CBindingsVeryLazy)

diff  --git 
a/llvm/examples/OrcV2Examples/LLJITWithExecutorProcessControl/LLJITWithExecutorProcessControl.cpp
 
b/llvm/examples/OrcV2Examples/LLJITWithExecutorProcessControl/LLJITWithExecutorProcessControl.cpp
index d3ca7bfc1ee30..8d2ac3261e399 100644
--- 
a/llvm/examples/OrcV2Examples/LLJITWithExecutorProcessControl/LLJITWithExecutorProcessControl.cpp
+++ 
b/llvm/examples/OrcV2Examples/LLJITWithExecutorProcessControl/LLJITWithExecutorProcessControl.cpp
@@ -22,7 +22,6 @@
 
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h"
-#include "llvm/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.h"
 #include "llvm/ExecutionEngine/Orc/EPCIndirectionUtils.h"
 #include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
 #include "llvm/ExecutionEngine/Orc/LLJIT.h"
@@ -152,9 +151,6 @@ int main(int argc, char *argv[]) {
   EPCIU->createLazyCallThroughManager(
   J->getExecutionSession(), ExecutorAddr::fromPtr());
   auto ISM = EPCIU->createIndirectStubsManager();
-  J->getMainJITDylib().addGenerator(
-  ExitOnErr(EPCDynamicLibrarySearchGenerator::GetForTargetProcess(
-  J->getExecutionSession(;
 
   // (4) Add modules.
   ExitOnErr(J->addIRModule(ExitOnErr(parseExampleModule(FooMod, "foo-mod";

diff  --git 
a/llvm/examples/OrcV2Examples/LLJITWithGDBRegistrationListener/LLJITWithGDBRegistrationListener.cpp
 
b/llvm/examples/OrcV2Examples/LLJITWithGDBRegistrationListener/LLJITWithGDBRegistrationListener.cpp
index 16e7ba3cc080b..5ee52244b3fb4 100644
--- 

[libunwind] 0751fc6 - [libunwind] On Darwin, add a callback-based lookup scheme for JIT'd unwind info.

2023-02-10 Thread Lang Hames via cfe-commits

Author: Lang Hames
Date: 2023-02-10T14:36:25-08:00
New Revision: 0751fc68b976d25dd3041217dad16622cf151cd6

URL: 
https://github.com/llvm/llvm-project/commit/0751fc68b976d25dd3041217dad16622cf151cd6
DIFF: 
https://github.com/llvm/llvm-project/commit/0751fc68b976d25dd3041217dad16622cf151cd6.diff

LOG: [libunwind] On Darwin, add a callback-based lookup scheme for JIT'd unwind 
info.

This commit adds support for a new callback-based lookup scheme for unwind
info that was inspired by the `_dyld_find_unwind_info_sections` SPI that
libunwind uses to find unwind-info in non-JIT'd frames. From
llvm-project/libunwind/src/AddressSpace.hpp:

```
struct dyld_unwind_sections {
  const struct mach_header*   mh;
  const void* dwarf_section;
  uintptr_t   dwarf_section_length;
  const void* compact_unwind_section;
  uintptr_t   compact_unwind_section_length;
};

extern bool _dyld_find_unwind_sections(void *, dyld_unwind_sections *);
```

During unwinding libunwind calls `_dyld_find_unwind_sections` to both find
unwind section addresses and identify the subarchitecture for frames (via the
MachO-header pointed to by the mh field).

This commit introduces two new libunwind SPI functions:

```
struct unw_dynamic_unwind_sections {
  unw_word_t dso_base;
  unw_word_t dwarf_section;
  size_t dwarf_section_length;
  unw_word_t compact_unwind_section;
  size_t compact_unwind_section_length;
};

typedef int (*unw_find_dynamic_unwind_sections)(
unw_word_t addr, struct unw_dynamic_unwind_sections *info);

// Returns UNW_ESUCCESS if successfully registered, UNW_EINVAL for duplicate
// registrations, and UNW_ENOMEM to indicate too many registrations.
extern int __unw_add_find_dynamic_unwind_sections(
unw_find_dynamic_unwind_sections find_dynamic_unwind_sections);

// Returns UNW_ESUCCESS if successfully deregistered, UNW_EINVAL to indicate
// no such registration.
extern int __unw_remove_find_dynamic_unwind_sections(
unw_find_dynamic_unwind_sections find_dynamic_unwind_sections);
```

These can be used to register and deregister callbacks that have a similar
signature to `_dyld_find_unwind_sections`. During unwinding if
`_dyld_find_unwind_sections` returns false (indicating that no frame info
was found by dyld) then registered callbacks are run in registration order until
either the unwind info is found or the end of the list is reached.

With this commit, and by implementing the find-unwind-info callback in the ORC
runtime in LLVM, we (1) enable support for registering JIT'd compact-unwind info
with libunwind*, (2) provide a way to identify the subarchitecture for each 
frame
(by returning a pointer to a JIT'd MachO header), and (3) delegate tracking of
unwind info to the callback, which may be able to implement more efficient
address-based lookup than libunwind.

* JITLink does not process or register compact unwind info yet, so this patch
  does not fully enable compact unwind info in ORC, it simply provides some
  necessary plumbing. JITLink support for compact unwind should land some time
  in the LLVM 17 development cycle.

Reviewed By: pete

Differential Revision: https://reviews.llvm.org/D142176

Added: 


Modified: 
libunwind/src/AddressSpace.hpp
libunwind/src/libunwind.cpp
libunwind/src/libunwind_ext.h

Removed: 




diff  --git a/libunwind/src/AddressSpace.hpp b/libunwind/src/AddressSpace.hpp
index 26d289068b38c..1abbc82254687 100644
--- a/libunwind/src/AddressSpace.hpp
+++ b/libunwind/src/AddressSpace.hpp
@@ -66,6 +66,10 @@ char *getFuncNameFromTBTable(uintptr_t pc, uint16_t ,
   // In 10.7.0 or later, libSystem.dylib implements this function.
   extern "C" bool _dyld_find_unwind_sections(void *, dyld_unwind_sections *);
 
+namespace libunwind {
+  bool findDynamicUnwindSections(void *, unw_dynamic_unwind_sections *);
+}
+
 #elif defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) && 
defined(_LIBUNWIND_IS_BAREMETAL)
 
 // When statically linked on bare-metal, the symbols for the EH table are 
looked
@@ -497,6 +501,22 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t 
targetAddr,
 info.compact_unwind_section_length = 
(size_t)dyldInfo.compact_unwind_section_length;
 return true;
   }
+
+  unw_dynamic_unwind_sections dynamicUnwindSectionInfo;
+  if (findDynamicUnwindSections((void *)targetAddr,
+)) {
+info.dso_base = dynamicUnwindSectionInfo.dso_base;
+#if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
+info.dwarf_section = (uintptr_t)dynamicUnwindSectionInfo.dwarf_section;
+info.dwarf_section_length = dynamicUnwindSectionInfo.dwarf_section_length;
+#endif
+info.compact_unwind_section =
+(uintptr_t)dynamicUnwindSectionInfo.compact_unwind_section;
+info.compact_unwind_section_length =
+dynamicUnwindSectionInfo.compact_unwind_section_length;
+return true;
+  }
+
 #elif 

[clang] 9b1cf2e - Fix running orc-rt tests with LLVM_BUILD_EXTERNAL_COMPILER_RT (again).

2022-07-05 Thread Lang Hames via cfe-commits

Author: Lang Hames
Date: 2022-07-05T15:20:08-07:00
New Revision: 9b1cf2e2b2a8ca2bc10894d569a653429b989dd0

URL: 
https://github.com/llvm/llvm-project/commit/9b1cf2e2b2a8ca2bc10894d569a653429b989dd0
DIFF: 
https://github.com/llvm/llvm-project/commit/9b1cf2e2b2a8ca2bc10894d569a653429b989dd0.diff

LOG: Fix running orc-rt tests with LLVM_BUILD_EXTERNAL_COMPILER_RT (again).

Add missing dependency on lli when building compiler-rt with
LLVM_BUILD_EXTERNAL_COMPILER_RT. Previously we would non-deterministically fail
the tests due to the missing binary.

This is essentially identical to 0e5ea403e8d, which added an earlier dependence
on llvm-jitlink.

rdar://96467892

Added: 


Modified: 
clang/runtime/CMakeLists.txt

Removed: 




diff  --git a/clang/runtime/CMakeLists.txt b/clang/runtime/CMakeLists.txt
index 02ea3811e3922..9f4633bc85b12 100644
--- a/clang/runtime/CMakeLists.txt
+++ b/clang/runtime/CMakeLists.txt
@@ -132,7 +132,7 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS 
${COMPILER_RT_SRC_ROOT}/)
   if(LLVM_INCLUDE_TESTS)
 # Add binaries that compiler-rt tests depend on.
 set(COMPILER_RT_TEST_DEPENDENCIES
-  FileCheck count not llvm-nm llvm-objdump llvm-symbolizer llvm-jitlink)
+  FileCheck count not llvm-nm llvm-objdump llvm-symbolizer llvm-jitlink 
lli)
 
 # Add top-level targets for various compiler-rt test suites.
 set(COMPILER_RT_TEST_SUITES check-fuzzer check-asan check-hwasan 
check-asan-dynamic check-dfsan



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 16dcbb5 - [ORC] Return ExecutorAddrs rather than JITEvaluatedSymbols from LLJIT::lookup.

2022-05-05 Thread Lang Hames via cfe-commits

Author: Lang Hames
Date: 2022-05-05T13:56:00-07:00
New Revision: 16dcbb53dc7968a3752661aac731172ebe0faf64

URL: 
https://github.com/llvm/llvm-project/commit/16dcbb53dc7968a3752661aac731172ebe0faf64
DIFF: 
https://github.com/llvm/llvm-project/commit/16dcbb53dc7968a3752661aac731172ebe0faf64.diff

LOG: [ORC] Return ExecutorAddrs rather than JITEvaluatedSymbols from 
LLJIT::lookup.

Clients don't care about linkage, and ExecutorAddr is much more ergonomic.

Added: 


Modified: 
clang/lib/Interpreter/IncrementalExecutor.cpp
llvm/examples/HowToUseLLJIT/HowToUseLLJIT.cpp
llvm/examples/OrcV2Examples/LLJITDumpObjects/LLJITDumpObjects.cpp
llvm/examples/OrcV2Examples/LLJITRemovableCode/LLJITRemovableCode.cpp

llvm/examples/OrcV2Examples/LLJITWithCustomObjectLinkingLayer/LLJITWithCustomObjectLinkingLayer.cpp

llvm/examples/OrcV2Examples/LLJITWithExecutorProcessControl/LLJITWithExecutorProcessControl.cpp

llvm/examples/OrcV2Examples/LLJITWithGDBRegistrationListener/LLJITWithGDBRegistrationListener.cpp

llvm/examples/OrcV2Examples/LLJITWithLazyReexports/LLJITWithLazyReexports.cpp
llvm/examples/OrcV2Examples/LLJITWithObjectCache/LLJITWithObjectCache.cpp

llvm/examples/OrcV2Examples/LLJITWithObjectLinkingLayerPlugin/LLJITWithObjectLinkingLayerPlugin.cpp

llvm/examples/OrcV2Examples/LLJITWithOptimizingIRTransform/LLJITWithOptimizingIRTransform.cpp

llvm/examples/OrcV2Examples/LLJITWithRemoteDebugging/LLJITWithRemoteDebugging.cpp

llvm/examples/OrcV2Examples/LLJITWithThinLTOSummaries/LLJITWithThinLTOSummaries.cpp
llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
llvm/lib/ExecutionEngine/Orc/OrcV2CBindings.cpp
llvm/tools/lli/lli.cpp

Removed: 




diff  --git a/clang/lib/Interpreter/IncrementalExecutor.cpp 
b/clang/lib/Interpreter/IncrementalExecutor.cpp
index 705235aafa070..75c385aa409f3 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.cpp
+++ b/clang/lib/Interpreter/IncrementalExecutor.cpp
@@ -68,7 +68,7 @@ IncrementalExecutor::getSymbolAddress(llvm::StringRef Name,
 
   if (!Sym)
 return Sym.takeError();
-  return Sym->getAddress();
+  return Sym->getValue();
 }
 
 } // end namespace clang

diff  --git a/llvm/examples/HowToUseLLJIT/HowToUseLLJIT.cpp 
b/llvm/examples/HowToUseLLJIT/HowToUseLLJIT.cpp
index 170a899136054..cdeaa745f91ef 100644
--- a/llvm/examples/HowToUseLLJIT/HowToUseLLJIT.cpp
+++ b/llvm/examples/HowToUseLLJIT/HowToUseLLJIT.cpp
@@ -91,8 +91,8 @@ int main(int argc, char *argv[]) {
   ExitOnErr(J->addIRModule(std::move(M)));
 
   // Look up the JIT'd function, cast it to a function pointer, then call it.
-  auto Add1Sym = ExitOnErr(J->lookup("add1"));
-  int (*Add1)(int) = (int (*)(int))Add1Sym.getAddress();
+  auto Add1Addr = ExitOnErr(J->lookup("add1"));
+  int (*Add1)(int) = Add1Addr.toPtr();
 
   int Result = Add1(42);
   outs() << "add1(42) = " << Result << "\n";

diff  --git a/llvm/examples/OrcV2Examples/LLJITDumpObjects/LLJITDumpObjects.cpp 
b/llvm/examples/OrcV2Examples/LLJITDumpObjects/LLJITDumpObjects.cpp
index 2c975b188fb64..c3752cc36c060 100644
--- a/llvm/examples/OrcV2Examples/LLJITDumpObjects/LLJITDumpObjects.cpp
+++ b/llvm/examples/OrcV2Examples/LLJITDumpObjects/LLJITDumpObjects.cpp
@@ -61,8 +61,8 @@ int main(int argc, char *argv[]) {
   ExitOnErr(J->addIRModule(std::move(M)));
 
   // Look up the JIT'd function, cast it to a function pointer, then call it.
-  auto Add1Sym = ExitOnErr(J->lookup("add1"));
-  int (*Add1)(int) = (int (*)(int))Add1Sym.getAddress();
+  auto Add1Addr = ExitOnErr(J->lookup("add1"));
+  int (*Add1)(int) = Add1Addr.toPtr();
 
   int Result = Add1(42);
   outs() << "add1(42) = " << Result << "\n";

diff  --git 
a/llvm/examples/OrcV2Examples/LLJITRemovableCode/LLJITRemovableCode.cpp 
b/llvm/examples/OrcV2Examples/LLJITRemovableCode/LLJITRemovableCode.cpp
index 29735d11f70d7..4739efc2eccf1 100644
--- a/llvm/examples/OrcV2Examples/LLJITRemovableCode/LLJITRemovableCode.cpp
+++ b/llvm/examples/OrcV2Examples/LLJITRemovableCode/LLJITRemovableCode.cpp
@@ -92,7 +92,7 @@ int main(int argc, char *argv[]) {
   auto PrintSymbol = [&](StringRef Name) {
 dbgs() << Name << " = ";
 if (auto Sym = J->lookup(JD, Name))
-  dbgs() << formatv("{0:x}\n", Sym->getAddress());
+  dbgs() << *Sym;
 else
   dbgs() << "error: " << toString(Sym.takeError()) << "\n";
   };

diff  --git 
a/llvm/examples/OrcV2Examples/LLJITWithCustomObjectLinkingLayer/LLJITWithCustomObjectLinkingLayer.cpp
 
b/llvm/examples/OrcV2Examples/LLJITWithCustomObjectLinkingLayer/LLJITWithCustomObjectLinkingLayer.cpp
index 907dc83f46333..16c81de54c86f 100644
--- 
a/llvm/examples/OrcV2Examples/LLJITWithCustomObjectLinkingLayer/LLJITWithCustomObjectLinkingLayer.cpp
+++ 
b/llvm/examples/OrcV2Examples/LLJITWithCustomObjectLinkingLayer/LLJITWithCustomObjectLinkingLayer.cpp
@@ -56,8 +56,8 @@ int main(int argc, char 

[clang] 71a0609 - [clang-repl] Temporarily disable the execute.cpp test on ppc64.

2021-05-13 Thread Lang Hames via cfe-commits

Author: Lang Hames
Date: 2021-05-13T14:39:12-07:00
New Revision: 71a0609a2b533dbcd6826ad774b6bee5e9818644

URL: 
https://github.com/llvm/llvm-project/commit/71a0609a2b533dbcd6826ad774b6bee5e9818644
DIFF: 
https://github.com/llvm/llvm-project/commit/71a0609a2b533dbcd6826ad774b6bee5e9818644.diff

LOG: [clang-repl] Temporarily disable the execute.cpp test on ppc64.

This test is failing on some builders (see [1]) with the following error:

error: Added modules have incompatible data layouts:
  e-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512 (module) vs
  E-m:a-i64:64-n32:64-S128-v256:256:256-v512:512:512 (jit)

The JIT layout is correct, but some IR module added to the JIT is using a
little-endian layout instead.

This commit disables the test on ppc64 until we can investigate further and
fix the bug.

[1] https://lab.llvm.org/staging/#/builders/126/builds/371

Added: 


Modified: 
clang/test/Interpreter/execute.cpp

Removed: 




diff  --git a/clang/test/Interpreter/execute.cpp 
b/clang/test/Interpreter/execute.cpp
index 81ab57e955cf6..a9beed5714d0b 100644
--- a/clang/test/Interpreter/execute.cpp
+++ b/clang/test/Interpreter/execute.cpp
@@ -1,5 +1,6 @@
 // RUN: cat %s | clang-repl | FileCheck %s
 // REQUIRES: host-supports-jit
+// UNSUPPORTED: powerpc64
 
 extern "C" int printf(const char *, ...);
 int i = 42;



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang] 4a0267e - Convert a reachable llvm_unreachable into an assert.

2020-03-22 Thread Lang Hames via cfe-commits
Hi Dave, Aaron,

and I spent a lot more time debugging than I should have because I was using
> a release + asserts build and the semantics of llvm_unreachable made
> unfortunate codegen (switching to an assert makes the issue
> immediately obvious).


Huh. I think we should be using llvm_unreachable here, but I would have
expected it to behave similarly to assert(false && ...) in +Asserts builds.
If it isn't that might be a bug?

-- Lang.

On Sun, Mar 22, 2020 at 9:19 AM David Blaikie  wrote:

> On Sun, Mar 22, 2020 at 6:34 AM Aaron Ballman 
> wrote:
>
>> On Sat, Mar 21, 2020 at 11:31 PM David Blaikie 
>> wrote:
>> >
>> > Why the change? this seems counter to LLVM's style which pretty
>> consistently uses unreachable rather than assert(false), so far as I know?
>>
>> We're not super consistent (at least within Clang), but the rules as
>> I've generally understood them are to use llvm_unreachable only for
>> truly unreachable code and to use assert(false) when the code is
>> technically reachable but is a programmer mistake to have gotten
>> there.
>
>
> I don't see those as two different things personally - llvm_unreachable is
> used when the programmer believes it to be unreachable (not that it must be
> proven to be unreachable - we have message text there so it's informative
> if the assumption turns out not to hold)
>
>
>> In this particular case, the code is very much reachable
>
>
> In what sense? If it is actually reachable - shouldn't it be tested? (& in
> which case the assert(false) will get in the way of that testing)
>
>
>> and I
>> spent a lot more time debugging than I should have because I was using
>> a release + asserts build and the semantics of llvm_unreachable made
>> unfortunate codegen (switching to an assert makes the issue
>> immediately obvious).
>>
>
> I think it might be reasonable to say that release+asserts to have
> unreachable behave the same way unreachable behaves at -O0 (which is to
> say, much like assert(false)). Clearly release+asserts effects code
> generation, so there's nothing like the "debug info invariance" goal that
> this would be tainting, etc.
>
> Certainly opinions vary here, but here are some commits that show the sort
> of general preference:
> http://llvm.org/viewvc/llvm-project?view=revision=259302
> http://llvm.org/viewvc/llvm-project?view=revision=253005
> http://llvm.org/viewvc/llvm-project?view=revision=251266
>
> And some counter examples:
> http://llvm.org/viewvc/llvm-project?view=revision=225043
> Including this thread where Chandler originally (not sure what his take on
> it is these days) expressed some ideas more along your lines:
>
> http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20110919/thread.html#46583
>
> But I'm always pretty concerned about the idea that assertions should be
> used in places where the behavior of the program has any constraints when
> the assertion is false...
>
> - Dave
>
>
>>
>> >
>> > On Tue, Mar 10, 2020 at 11:22 AM Aaron Ballman via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>> >>
>> >>
>> >> Author: Aaron Ballman
>> >> Date: 2020-03-10T14:22:21-04:00
>> >> New Revision: 4a0267e3ad8c4d47f267d7d960f127e099fb4818
>> >>
>> >> URL:
>> https://github.com/llvm/llvm-project/commit/4a0267e3ad8c4d47f267d7d960f127e099fb4818
>> >> DIFF:
>> https://github.com/llvm/llvm-project/commit/4a0267e3ad8c4d47f267d7d960f127e099fb4818.diff
>> >>
>> >> LOG: Convert a reachable llvm_unreachable into an assert.
>> >>
>> >> Added:
>> >>
>> >>
>> >> Modified:
>> >> clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
>> >>
>> >> Removed:
>> >>
>> >>
>> >>
>> >>
>> 
>> >> diff  --git a/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
>> b/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
>> >> index 01ac2bc83bb6..99e16752b51a 100644
>> >> --- a/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
>> >> +++ b/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
>> >> @@ -134,9 +134,9 @@ StringRef
>> AnalyzerOptions::getCheckerStringOption(StringRef CheckerName,
>> >>  CheckerName = CheckerName.substr(0, Pos);
>> >>} while (!CheckerName.empty() && SearchInParents);
>> >>
>> >> -  llvm_unreachable("Unknown checker option! Did you call
>> getChecker*Option "
>> >> -   "with incorrect parameters? User input must've
>> been "
>> >> -   "verified by CheckerRegistry.");
>> >> +  assert(false && "Unknown checker option! Did you call
>> getChecker*Option "
>> >> +  "with incorrect parameters? User input must've been
>> "
>> >> +  "verified by CheckerRegistry.");
>> >>
>> >>return "";
>> >>  }
>> >>
>> >>
>> >>
>> >> ___
>> >> cfe-commits mailing list
>> >> cfe-commits@lists.llvm.org
>> >> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
___
cfe-commits mailing list

[clang] 490a9a4 - [examples] Fix the clang-interpreter example for changes in 85fb997659b.

2020-02-19 Thread Lang Hames via cfe-commits

Author: Lang Hames
Date: 2020-02-19T19:01:32-08:00
New Revision: 490a9a4b77ea23f388cae67d732af6bd8aa576f9

URL: 
https://github.com/llvm/llvm-project/commit/490a9a4b77ea23f388cae67d732af6bd8aa576f9
DIFF: 
https://github.com/llvm/llvm-project/commit/490a9a4b77ea23f388cae67d732af6bd8aa576f9.diff

LOG: [examples] Fix the clang-interpreter example for changes in 85fb997659b.

Added: 


Modified: 
clang/examples/clang-interpreter/main.cpp

Removed: 




diff  --git a/clang/examples/clang-interpreter/main.cpp 
b/clang/examples/clang-interpreter/main.cpp
index c0aae4722306..6b4cdca15fb0 100644
--- a/clang/examples/clang-interpreter/main.cpp
+++ b/clang/examples/clang-interpreter/main.cpp
@@ -54,7 +54,7 @@ class SimpleJIT {
   std::unique_ptr TM;
   const DataLayout DL;
   MangleAndInterner Mangle{ES, DL};
-  JITDylib {ES.createJITDylib("")};
+  JITDylib {ES.createBareJITDylib("")};
   RTDyldObjectLinkingLayer ObjectLayer{ES, createMemMgr};
   IRCompileLayer CompileLayer{ES, ObjectLayer,
   std::make_unique(*TM)};



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b54aa05 - Update clang-interpreter example to incorporate changes in ce2207abaf9.

2020-01-21 Thread Lang Hames via cfe-commits

Author: Lang Hames
Date: 2020-01-21T22:00:50-08:00
New Revision: b54aa053d3aeeab0cdaecb6286419138b7da5ef4

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

LOG: Update clang-interpreter example to incorporate changes in ce2207abaf9.

Added: 


Modified: 
clang/examples/clang-interpreter/main.cpp

Removed: 




diff  --git a/clang/examples/clang-interpreter/main.cpp 
b/clang/examples/clang-interpreter/main.cpp
index db6b0cce4fd1..c0aae4722306 100644
--- a/clang/examples/clang-interpreter/main.cpp
+++ b/clang/examples/clang-interpreter/main.cpp
@@ -56,7 +56,8 @@ class SimpleJIT {
   MangleAndInterner Mangle{ES, DL};
   JITDylib {ES.createJITDylib("")};
   RTDyldObjectLinkingLayer ObjectLayer{ES, createMemMgr};
-  IRCompileLayer CompileLayer{ES, ObjectLayer, SimpleCompiler(*TM)};
+  IRCompileLayer CompileLayer{ES, ObjectLayer,
+  std::make_unique(*TM)};
 
   static std::unique_ptr createMemMgr() {
 return std::make_unique();



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 41eeded - Fix the clang interpreter example which was broken by 4fc68b9b7f3e0.

2019-12-05 Thread Lang Hames via cfe-commits

Author: Lang Hames
Date: 2019-12-05T02:42:35-08:00
New Revision: 41eeded804310df0719ecbc92a0e14b438213dbf

URL: 
https://github.com/llvm/llvm-project/commit/41eeded804310df0719ecbc92a0e14b438213dbf
DIFF: 
https://github.com/llvm/llvm-project/commit/41eeded804310df0719ecbc92a0e14b438213dbf.diff

LOG: Fix the clang interpreter example which was broken by 4fc68b9b7f3e0.

Added: 


Modified: 
clang/examples/clang-interpreter/main.cpp

Removed: 




diff  --git a/clang/examples/clang-interpreter/main.cpp 
b/clang/examples/clang-interpreter/main.cpp
index 6ac142bffdff..db6b0cce4fd1 100644
--- a/clang/examples/clang-interpreter/main.cpp
+++ b/clang/examples/clang-interpreter/main.cpp
@@ -54,6 +54,7 @@ class SimpleJIT {
   std::unique_ptr TM;
   const DataLayout DL;
   MangleAndInterner Mangle{ES, DL};
+  JITDylib {ES.createJITDylib("")};
   RTDyldObjectLinkingLayer ObjectLayer{ES, createMemMgr};
   IRCompileLayer CompileLayer{ES, ObjectLayer, SimpleCompiler(*TM)};
 
@@ -66,7 +67,7 @@ class SimpleJIT {
   std::unique_ptr ProcessSymbolsGenerator)
   : TM(std::move(TM)), DL(std::move(DL)) {
 llvm::sys::DynamicLibrary::LoadLibraryPermanently(nullptr);
-ES.getMainJITDylib().addGenerator(std::move(ProcessSymbolsGenerator));
+MainJD.addGenerator(std::move(ProcessSymbolsGenerator));
   }
 
 public:
@@ -95,11 +96,11 @@ class SimpleJIT {
   const TargetMachine () const { return *TM; }
 
   Error addModule(ThreadSafeModule M) {
-return CompileLayer.add(ES.getMainJITDylib(), std::move(M));
+return CompileLayer.add(MainJD, std::move(M));
   }
 
   Expected findSymbol(const StringRef ) {
-return ES.lookup({()}, Mangle(Name));
+return ES.lookup({}, Mangle(Name));
   }
 
   Expected getSymbolAddress(const StringRef ) {



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r366511 - Update the SimpleJIT class in the clang-interpreter example to use ORCv2.

2019-07-18 Thread Lang Hames via cfe-commits
Author: lhames
Date: Thu Jul 18 15:47:18 2019
New Revision: 366511

URL: http://llvm.org/viewvc/llvm-project?rev=366511=rev
Log:
Update the SimpleJIT class in the clang-interpreter example to use ORCv2.

This will remove the ORCv1 deprecation warnings.

Modified:
cfe/trunk/examples/clang-interpreter/main.cpp

Modified: cfe/trunk/examples/clang-interpreter/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/clang-interpreter/main.cpp?rev=366511=366510=366511=diff
==
--- cfe/trunk/examples/clang-interpreter/main.cpp (original)
+++ cfe/trunk/examples/clang-interpreter/main.cpp Thu Jul 18 15:47:18 2019
@@ -18,6 +18,7 @@
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
 #include "llvm/ExecutionEngine/Orc/CompileUtils.h"
+#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
 #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
 #include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
 #include "llvm/ExecutionEngine/SectionMemoryManager.h"
@@ -50,65 +51,69 @@ namespace orc {
 class SimpleJIT {
 private:
   ExecutionSession ES;
-  std::shared_ptr Resolver;
   std::unique_ptr TM;
   const DataLayout DL;
-  LegacyRTDyldObjectLinkingLayer ObjectLayer;
-  LegacyIRCompileLayer CompileLayer;
+  MangleAndInterner Mangle{ES, DL};
+  RTDyldObjectLinkingLayer ObjectLayer{ES, createMemMgr};
+  IRCompileLayer CompileLayer{ES, ObjectLayer, SimpleCompiler(*TM)};
 
-public:
-  SimpleJIT()
-  : Resolver(createLegacyLookupResolver(
-ES,
-[this](const std::string ) -> JITSymbol {
-  if (auto Sym = CompileLayer.findSymbol(Name, false))
-return Sym;
-  else if (auto Err = Sym.takeError())
-return std::move(Err);
-  if (auto SymAddr =
-  RTDyldMemoryManager::getSymbolAddressInProcess(Name))
-return JITSymbol(SymAddr, JITSymbolFlags::Exported);
-  return nullptr;
-},
-[](Error Err) { cantFail(std::move(Err), "lookupFlags failed"); 
})),
-TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()),
-ObjectLayer(ES,
-[this](VModuleKey) {
-  return LegacyRTDyldObjectLinkingLayer::Resources{
-  std::make_shared(), Resolver};
-}),
-CompileLayer(ObjectLayer, SimpleCompiler(*TM)) {
+  static std::unique_ptr createMemMgr() {
+return llvm::make_unique();
+  }
+
+  SimpleJIT(std::unique_ptr TM, DataLayout DL,
+DynamicLibrarySearchGenerator ProcessSymbolsGenerator)
+  : TM(std::move(TM)), DL(std::move(DL)) {
 llvm::sys::DynamicLibrary::LoadLibraryPermanently(nullptr);
+ES.getMainJITDylib().setGenerator(std::move(ProcessSymbolsGenerator));
   }
 
-  const TargetMachine () const { return *TM; }
+public:
+  static Expected> Create() {
+auto JTMB = JITTargetMachineBuilder::detectHost();
+if (!JTMB)
+  return JTMB.takeError();
+
+auto TM = JTMB->createTargetMachine();
+if (!TM)
+  return TM.takeError();
+
+auto DL = (*TM)->createDataLayout();
+
+auto ProcessSymbolsGenerator =
+DynamicLibrarySearchGenerator::GetForCurrentProcess(
+DL.getGlobalPrefix());
+
+if (!ProcessSymbolsGenerator)
+  return ProcessSymbolsGenerator.takeError();
 
-  VModuleKey addModule(std::unique_ptr M) {
-// Add the module to the JIT with a new VModuleKey.
-auto K = ES.allocateVModule();
-cantFail(CompileLayer.addModule(K, std::move(M)));
-return K;
+return std::unique_ptr(new SimpleJIT(
+std::move(*TM), std::move(DL), std::move(*ProcessSymbolsGenerator)));
   }
 
-  JITSymbol findSymbol(const StringRef ) {
-std::string MangledName;
-raw_string_ostream MangledNameStream(MangledName);
-Mangler::getNameWithPrefix(MangledNameStream, Name, DL);
-return CompileLayer.findSymbol(MangledNameStream.str(), true);
+  const TargetMachine () const { return *TM; }
+
+  Error addModule(ThreadSafeModule M) {
+return CompileLayer.add(ES.getMainJITDylib(), std::move(M));
   }
 
-  JITTargetAddress getSymbolAddress(const StringRef ) {
-return cantFail(findSymbol(Name).getAddress());
+  Expected findSymbol(const StringRef ) {
+return ES.lookup({()}, Mangle(Name));
   }
 
-  void removeModule(VModuleKey K) {
-cantFail(CompileLayer.removeModule(K));
+  Expected getSymbolAddress(const StringRef ) {
+auto Sym = findSymbol(Name);
+if (!Sym)
+  return Sym.takeError();
+return Sym->getAddress();
   }
 };
 
 } // end namespace orc
 } // end namespace llvm
 
+llvm::ExitOnError ExitOnErr;
+
 int main(int argc, const char **argv) {
   // This just needs to be some symbol in the binary; C++ doesn't
   // allow taking the address of ::main however.
@@ -130,6 +135,8 @@ int main(int argc, const char **argv) {
 

r366141 - [clang-fuzzer] Remove 'setUseOrcMCJITReplacement(false)' call.

2019-07-15 Thread Lang Hames via cfe-commits
Author: lhames
Date: Mon Jul 15 15:27:57 2019
New Revision: 366141

URL: http://llvm.org/viewvc/llvm-project?rev=366141=rev
Log:
[clang-fuzzer] Remove 'setUseOrcMCJITReplacement(false)' call.

The default value for this option (UseMCJITReplacement) is already false, and
OrcMCJITReplacement is going to have deprecation warnings attached in LLVM 9.0.
Removing this call removes a spurious warning.

Modified:
cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp

Modified: cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp?rev=366141=366140=366141=diff
==
--- cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp (original)
+++ cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp Mon Jul 15 
15:27:57 2019
@@ -159,7 +159,6 @@ static void CreateAndRunJITFunc(const st
   builder.setMAttrs(getFeatureList());
   builder.setErrorStr();
   builder.setEngineKind(EngineKind::JIT);
-  builder.setUseOrcMCJITReplacement(false);
   builder.setMCJITMemoryManager(make_unique());
   builder.setOptLevel(OLvl);
   builder.setTargetOptions(InitTargetOptionsFromCodeGenFlags());


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r315532 - Update cc1as_main for MCCodeEmitter ownership change in r315531.

2017-10-11 Thread Lang Hames via cfe-commits
Author: lhames
Date: Wed Oct 11 16:35:27 2017
New Revision: 315532

URL: http://llvm.org/viewvc/llvm-project?rev=315532=rev
Log:
Update cc1as_main for MCCodeEmitter ownership change in r315531.

Modified:
cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=315532=315531=315532=diff
==
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Wed Oct 11 16:35:27 2017
@@ -419,7 +419,7 @@ static bool ExecuteAssembler(AssemblerIn
   Opts.CPU, Options);
 Triple T(Opts.Triple);
 Str.reset(TheTarget->createMCObjectStreamer(
-T, Ctx, std::unique_ptr(MAB), *Out, CE, *STI,
+T, Ctx, std::unique_ptr(MAB), *Out, 
std::unique_ptr(CE), *STI,
 Opts.RelaxAll, Opts.IncrementalLinkerCompatible,
 /*DWARFMustBeAtTheEnd*/ true));
 Str.get()->InitSections(Opts.NoExecStack);


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r315411 - Update cc1as_main for MCAsmBackend ownership change in r315410.

2017-10-10 Thread Lang Hames via cfe-commits
Author: lhames
Date: Tue Oct 10 18:58:08 2017
New Revision: 315411

URL: http://llvm.org/viewvc/llvm-project?rev=315411=rev
Log:
Update cc1as_main for MCAsmBackend ownership change in r315410.

Modified:
cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=315411=315410=315411=diff
==
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Tue Oct 10 18:58:08 2017
@@ -419,8 +419,8 @@ static bool ExecuteAssembler(AssemblerIn
   Opts.CPU, Options);
 Triple T(Opts.Triple);
 Str.reset(TheTarget->createMCObjectStreamer(
-T, Ctx, *MAB, *Out, CE, *STI, Opts.RelaxAll,
-Opts.IncrementalLinkerCompatible,
+T, Ctx, std::unique_ptr(MAB), *Out, CE, *STI,
+Opts.RelaxAll, Opts.IncrementalLinkerCompatible,
 /*DWARFMustBeAtTheEnd*/ true));
 Str.get()->InitSections(Opts.NoExecStack);
   }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r305860 - Special-case handling of destructors in override lists when dumping ASTs.

2017-07-13 Thread Lang Hames via cfe-commits
FWIW: Replacing the call to getName with getNameAsString seems to fix the
destructor issue as well (i.e. I can remove the special case for
destructors) so I've committed this r307959.

If the getName failure for destructors is unexpected it may be worth
digging into as a separate issue.

Cheers,
Lang.

On Thu, Jul 13, 2017 at 2:00 PM, Lang Hames <lha...@gmail.com> wrote:

> Sure.
>
> Richard - is this likely to be related to your query? Calling getName() on
> at least one destructor in Sema/ms_class_layout triggers the assertion in
> NamedDecl::getName():
>
> (lldb)
> frame #4: 0x0001039600e2 
> clang`clang::NamedDecl::getName(this=0x000112897490)
> const at Decl.h:238
>235/// This requires that the declaration have a name and that it
> be a simple
>236/// identifier.
>237StringRef getName() const {
> -> 238  assert(Name.isIdentifier() && "Name is not a simple
> identifier");
>239  return getIdentifier() ? getIdentifier()->getName() : "";
>240}
>241
> (lldb) expr this->dump()
> CXXDestructorDecl 0x112897490  llvm-svn-tot/llvm/tools/clang/test/Sema/ms_class_layout.cpp:102:3,
> col:17> col:11 used ~IA 'void (void) __attribute__((thiscall))' virtual
> `-CompoundStmt 0x1128977f8 <col:16, col:17>
>
> - Lang.
>
> On Wed, Jul 12, 2017 at 10:36 PM, Akira Hatanaka <ahatan...@apple.com>
> wrote:
>
>> Hi Lang,
>>
>> clang crashes when I compile the following code with "-Xclang -ast-dump”:
>>
>> class Base {
>> public:
>>   virtual void operator()() {}
>> };
>>
>> class Derived : public Base {
>> public:
>>   void operator()() override {}
>> };
>>
>> If I change “OS << D->getName()” to “OS << D->getNameAsString()”, the
>> crash disappears.
>>
>> Can you take a look please?
>>
>> On Jun 20, 2017, at 2:30 PM, Lang Hames via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>> Author: lhames
>> Date: Tue Jun 20 16:30:43 2017
>> New Revision: 305860
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=305860=rev
>> Log:
>> Special-case handling of destructors in override lists when dumping ASTs.
>>
>> Fixes a bug in r305850: CXXDestructors don't have names, so we need to
>> handle
>> printing of them separately.
>>
>>
>> Modified:
>>cfe/trunk/lib/AST/ASTDumper.cpp
>>
>> Modified: cfe/trunk/lib/AST/ASTDumper.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDum
>> per.cpp?rev=305860=305859=305860=diff
>> 
>> ==
>> --- cfe/trunk/lib/AST/ASTDumper.cpp (original)
>> +++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jun 20 16:30:43 2017
>> @@ -1189,9 +1189,12 @@ void ASTDumper::VisitFunctionDecl(const
>>   auto dumpOverride =
>> [=](const CXXMethodDecl *D) {
>>   SplitQualType T_split = D->getType().split();
>> -  OS << D << " " << D->getParent()->getName() << "::"
>> - << D->getName() << " '"
>> - << QualType::getAsString(T_split) << "'";
>> +  OS << D << " " << D->getParent()->getName() << "::";
>> +  if (isa(D))
>> +OS << "~" << D->getParent()->getName();
>> +  else
>> +OS << D->getName();
>>
>> +  OS << " '" << QualType::getAsString(T_split) << "'";
>> };
>>
>>   dumpChild([=] {
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r307959 - Use getNameAsString instead of getName to get method names when dumping

2017-07-13 Thread Lang Hames via cfe-commits
Author: lhames
Date: Thu Jul 13 14:08:29 2017
New Revision: 307959

URL: http://llvm.org/viewvc/llvm-project?rev=307959=rev
Log:
Use getNameAsString instead of getName to get method names when dumping
overrides:  getName can fail if the decl's name isn't a simple identifier.

This is a more general replacement for the fix in r305860.


Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=307959=307958=307959=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Thu Jul 13 14:08:29 2017
@@ -1189,12 +1189,8 @@ void ASTDumper::VisitFunctionDecl(const
   auto dumpOverride =
 [=](const CXXMethodDecl *D) {
   SplitQualType T_split = D->getType().split();
-  OS << D << " " << D->getParent()->getName() << "::";
-  if (isa(D))
-OS << "~" << D->getParent()->getName();
-  else
-OS << D->getName();
-  OS << " '" << QualType::getAsString(T_split) << "'";
+  OS << D << " " << D->getParent()->getName() << "::"
+ << D->getNameAsString() << " '" << QualType::getAsString(T_split) 
<< "'";
 };
 
   dumpChild([=] {


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r305860 - Special-case handling of destructors in override lists when dumping ASTs.

2017-07-13 Thread Lang Hames via cfe-commits
Sure.

Richard - is this likely to be related to your query? Calling getName() on
at least one destructor in Sema/ms_class_layout triggers the assertion in
NamedDecl::getName():

(lldb)
frame #4: 0x0001039600e2
clang`clang::NamedDecl::getName(this=0x000112897490) const at Decl.h:238
   235/// This requires that the declaration have a name and that it be
a simple
   236/// identifier.
   237StringRef getName() const {
-> 238  assert(Name.isIdentifier() && "Name is not a simple
identifier");
   239  return getIdentifier() ? getIdentifier()->getName() : "";
   240}
   241
(lldb) expr this->dump()
CXXDestructorDecl 0x112897490
 col:11 used ~IA 'void (void) __attribute__((thiscall))' virtual
`-CompoundStmt 0x1128977f8 <col:16, col:17>

- Lang.

On Wed, Jul 12, 2017 at 10:36 PM, Akira Hatanaka <ahatan...@apple.com>
wrote:

> Hi Lang,
>
> clang crashes when I compile the following code with "-Xclang -ast-dump”:
>
> class Base {
> public:
>   virtual void operator()() {}
> };
>
> class Derived : public Base {
> public:
>   void operator()() override {}
> };
>
> If I change “OS << D->getName()” to “OS << D->getNameAsString()”, the
> crash disappears.
>
> Can you take a look please?
>
> On Jun 20, 2017, at 2:30 PM, Lang Hames via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: lhames
> Date: Tue Jun 20 16:30:43 2017
> New Revision: 305860
>
> URL: http://llvm.org/viewvc/llvm-project?rev=305860=rev
> Log:
> Special-case handling of destructors in override lists when dumping ASTs.
>
> Fixes a bug in r305850: CXXDestructors don't have names, so we need to
> handle
> printing of them separately.
>
>
> Modified:
>cfe/trunk/lib/AST/ASTDumper.cpp
>
> Modified: cfe/trunk/lib/AST/ASTDumper.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDum
> per.cpp?rev=305860=305859=305860=diff
> 
> ==
> --- cfe/trunk/lib/AST/ASTDumper.cpp (original)
> +++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jun 20 16:30:43 2017
> @@ -1189,9 +1189,12 @@ void ASTDumper::VisitFunctionDecl(const
>   auto dumpOverride =
> [=](const CXXMethodDecl *D) {
>   SplitQualType T_split = D->getType().split();
> -  OS << D << " " << D->getParent()->getName() << "::"
> - << D->getName() << " '"
> - << QualType::getAsString(T_split) << "'";
> +  OS << D << " " << D->getParent()->getName() << "::";
> +  if (isa(D))
> +OS << "~" << D->getParent()->getName();
> +  else
> +OS << D->getName();
>
> +  OS << " '" << QualType::getAsString(T_split) << "'";
> };
>
>   dumpChild([=] {
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r307444 - Add testcase for r305850.

2017-07-07 Thread Lang Hames via cfe-commits
Author: lhames
Date: Fri Jul  7 14:51:11 2017
New Revision: 307444

URL: http://llvm.org/viewvc/llvm-project?rev=307444=rev
Log:
Add testcase for r305850.

Accidentally left this out of the original commit.

Added:
cfe/trunk/test/Import/import-overrides/
cfe/trunk/test/Import/import-overrides/Inputs/
cfe/trunk/test/Import/import-overrides/Inputs/Hierarchy.cpp
cfe/trunk/test/Import/import-overrides/test.cpp

Added: cfe/trunk/test/Import/import-overrides/Inputs/Hierarchy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/import-overrides/Inputs/Hierarchy.cpp?rev=307444=auto
==
--- cfe/trunk/test/Import/import-overrides/Inputs/Hierarchy.cpp (added)
+++ cfe/trunk/test/Import/import-overrides/Inputs/Hierarchy.cpp Fri Jul  7 
14:51:11 2017
@@ -0,0 +1,9 @@
+class Base {
+public:
+  virtual void foo() {}
+};
+
+class Derived : public Base {
+public:
+  void foo() override {}
+};

Added: cfe/trunk/test/Import/import-overrides/test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/import-overrides/test.cpp?rev=307444=auto
==
--- cfe/trunk/test/Import/import-overrides/test.cpp (added)
+++ cfe/trunk/test/Import/import-overrides/test.cpp Fri Jul  7 14:51:11 2017
@@ -0,0 +1,7 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/Hierarchy.cpp 
-expression %s | FileCheck %s
+
+// CHECK: Overrides:{{.*}}Base::foo
+
+void foo() {
+  Derived d;
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r305850 - Preserve CXX method overrides in ASTImporter

2017-06-20 Thread Lang Hames via cfe-commits
Should be fixed in r305860.

- Lang.

On Tue, Jun 20, 2017 at 2:19 PM, Lang Hames <lha...@gmail.com> wrote:

> Oops - this broke Sema/ms_class_layout.cpp. Looking in to it now...
>
> - Lang.
>
> On Tue, Jun 20, 2017 at 2:06 PM, Lang Hames via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: lhames
>> Date: Tue Jun 20 16:06:00 2017
>> New Revision: 305850
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=305850=rev
>> Log:
>> Preserve CXX method overrides in ASTImporter
>>
>> Summary:
>> The ASTImporter should import CXX method overrides from the source context
>> when it imports a method decl.
>>
>> Reviewers: spyffe, rsmith, doug.gregor
>>
>> Reviewed By: spyffe
>>
>> Differential Revision: https://reviews.llvm.org/D34371
>>
>> Modified:
>> cfe/trunk/lib/AST/ASTDumper.cpp
>> cfe/trunk/lib/AST/ASTImporter.cpp
>> cfe/trunk/tools/clang-import-test/clang-import-test.cpp
>>
>> Modified: cfe/trunk/lib/AST/ASTDumper.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDum
>> per.cpp?rev=305850=305849=305850=diff
>> 
>> ==
>> --- cfe/trunk/lib/AST/ASTDumper.cpp (original)
>> +++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jun 20 16:06:00 2017
>> @@ -1184,6 +1184,28 @@ void ASTDumper::VisitFunctionDecl(const
>>   I != E; ++I)
>>dumpCXXCtorInitializer(*I);
>>
>> +  if (const CXXMethodDecl *MD = dyn_cast(D))
>> +if (MD->size_overridden_methods() != 0) {
>> +  auto dumpOverride =
>> +[=](const CXXMethodDecl *D) {
>> +  SplitQualType T_split = D->getType().split();
>> +  OS << D << " " << D->getParent()->getName() << "::"
>> + << D->getName() << " '"
>> + << QualType::getAsString(T_split) << "'";
>> +};
>> +
>> +  dumpChild([=] {
>> +auto FirstOverrideItr = MD->begin_overridden_methods();
>> +OS << "Overrides: [ ";
>> +dumpOverride(*FirstOverrideItr);
>> +for (const auto *Override :
>> +   llvm::make_range(FirstOverrideItr + 1,
>> +MD->end_overridden_methods()))
>> +  dumpOverride(Override);
>> +OS << " ]";
>> +  });
>> +}
>> +
>>if (D->doesThisDeclarationHaveABody())
>>  dumpStmt(D->getBody());
>>  }
>>
>> Modified: cfe/trunk/lib/AST/ASTImporter.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImp
>> orter.cpp?rev=305850=305849=305850=diff
>> 
>> ==
>> --- cfe/trunk/lib/AST/ASTImporter.cpp (original)
>> +++ cfe/trunk/lib/AST/ASTImporter.cpp Tue Jun 20 16:06:00 2017
>> @@ -319,6 +319,9 @@ namespace clang {
>>  bool ImportArrayChecked(const InContainerTy , OIter
>> Obegin) {
>>return ImportArrayChecked(InContainer.begin(), InContainer.end(),
>> Obegin);
>>  }
>> +
>> +// Importing overrides.
>> +void ImportOverrides(CXXMethodDecl *ToMethod, CXXMethodDecl
>> *FromMethod);
>>};
>>  }
>>
>> @@ -2025,6 +2028,9 @@ Decl *ASTNodeImporter::VisitFunctionDecl
>>// Add this function to the lexical context.
>>LexicalDC->addDeclInternal(ToFunction);
>>
>> +  if (auto *FromCXXMethod = dyn_cast(D))
>> +ImportOverrides(cast(ToFunction), FromCXXMethod);
>> +
>>return ToFunction;
>>  }
>>
>> @@ -5499,6 +5505,14 @@ Expr *ASTNodeImporter::VisitSubstNonType
>>  Replacement);
>>  }
>>
>> +void ASTNodeImporter::ImportOverrides(CXXMethodDecl *ToMethod,
>> +  CXXMethodDecl *FromMethod) {
>> +  for (auto *FromOverriddenMethod : FromMethod->overridden_methods())
>> +ToMethod->addOverriddenMethod(
>> +  cast(Importer.Import(const_cast<CXXMethodDecl*>(
>> +FromOverriddenMethod;
>> +}
>> +
>>  ASTImporter::ASTImporter(ASTContext , FileManager
>> ,
>>   ASTContext , FileManager
>> ,
>>   bool MinimalImport)
>>
>> Modified: cfe/trunk/tools/clang-import-test/clang-import-test.cpp
>> URL: http://llvm.org/viewvc/llvm-project

r305860 - Special-case handling of destructors in override lists when dumping ASTs.

2017-06-20 Thread Lang Hames via cfe-commits
Author: lhames
Date: Tue Jun 20 16:30:43 2017
New Revision: 305860

URL: http://llvm.org/viewvc/llvm-project?rev=305860=rev
Log:
Special-case handling of destructors in override lists when dumping ASTs.

Fixes a bug in r305850: CXXDestructors don't have names, so we need to handle
printing of them separately.


Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=305860=305859=305860=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jun 20 16:30:43 2017
@@ -1189,9 +1189,12 @@ void ASTDumper::VisitFunctionDecl(const
   auto dumpOverride =
 [=](const CXXMethodDecl *D) {
   SplitQualType T_split = D->getType().split();
-  OS << D << " " << D->getParent()->getName() << "::"
- << D->getName() << " '"
- << QualType::getAsString(T_split) << "'";
+  OS << D << " " << D->getParent()->getName() << "::";
+  if (isa(D))
+OS << "~" << D->getParent()->getName();
+  else
+OS << D->getName();
+  OS << " '" << QualType::getAsString(T_split) << "'";
 };
 
   dumpChild([=] {


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r305850 - Preserve CXX method overrides in ASTImporter

2017-06-20 Thread Lang Hames via cfe-commits
Oops - this broke Sema/ms_class_layout.cpp. Looking in to it now...

- Lang.

On Tue, Jun 20, 2017 at 2:06 PM, Lang Hames via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: lhames
> Date: Tue Jun 20 16:06:00 2017
> New Revision: 305850
>
> URL: http://llvm.org/viewvc/llvm-project?rev=305850=rev
> Log:
> Preserve CXX method overrides in ASTImporter
>
> Summary:
> The ASTImporter should import CXX method overrides from the source context
> when it imports a method decl.
>
> Reviewers: spyffe, rsmith, doug.gregor
>
> Reviewed By: spyffe
>
> Differential Revision: https://reviews.llvm.org/D34371
>
> Modified:
> cfe/trunk/lib/AST/ASTDumper.cpp
> cfe/trunk/lib/AST/ASTImporter.cpp
> cfe/trunk/tools/clang-import-test/clang-import-test.cpp
>
> Modified: cfe/trunk/lib/AST/ASTDumper.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> ASTDumper.cpp?rev=305850=305849=305850=diff
> 
> ==
> --- cfe/trunk/lib/AST/ASTDumper.cpp (original)
> +++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jun 20 16:06:00 2017
> @@ -1184,6 +1184,28 @@ void ASTDumper::VisitFunctionDecl(const
>   I != E; ++I)
>dumpCXXCtorInitializer(*I);
>
> +  if (const CXXMethodDecl *MD = dyn_cast(D))
> +if (MD->size_overridden_methods() != 0) {
> +  auto dumpOverride =
> +[=](const CXXMethodDecl *D) {
> +  SplitQualType T_split = D->getType().split();
> +  OS << D << " " << D->getParent()->getName() << "::"
> + << D->getName() << " '"
> + << QualType::getAsString(T_split) << "'";
> +};
> +
> +  dumpChild([=] {
> +auto FirstOverrideItr = MD->begin_overridden_methods();
> +OS << "Overrides: [ ";
> +dumpOverride(*FirstOverrideItr);
> +for (const auto *Override :
> +   llvm::make_range(FirstOverrideItr + 1,
> +MD->end_overridden_methods()))
> +  dumpOverride(Override);
> +OS << " ]";
> +  });
> +}
> +
>if (D->doesThisDeclarationHaveABody())
>  dumpStmt(D->getBody());
>  }
>
> Modified: cfe/trunk/lib/AST/ASTImporter.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> ASTImporter.cpp?rev=305850=305849=305850=diff
> 
> ==
> --- cfe/trunk/lib/AST/ASTImporter.cpp (original)
> +++ cfe/trunk/lib/AST/ASTImporter.cpp Tue Jun 20 16:06:00 2017
> @@ -319,6 +319,9 @@ namespace clang {
>  bool ImportArrayChecked(const InContainerTy , OIter
> Obegin) {
>return ImportArrayChecked(InContainer.begin(), InContainer.end(),
> Obegin);
>  }
> +
> +// Importing overrides.
> +void ImportOverrides(CXXMethodDecl *ToMethod, CXXMethodDecl
> *FromMethod);
>};
>  }
>
> @@ -2025,6 +2028,9 @@ Decl *ASTNodeImporter::VisitFunctionDecl
>// Add this function to the lexical context.
>LexicalDC->addDeclInternal(ToFunction);
>
> +  if (auto *FromCXXMethod = dyn_cast(D))
> +ImportOverrides(cast(ToFunction), FromCXXMethod);
> +
>return ToFunction;
>  }
>
> @@ -5499,6 +5505,14 @@ Expr *ASTNodeImporter::VisitSubstNonType
>  Replacement);
>  }
>
> +void ASTNodeImporter::ImportOverrides(CXXMethodDecl *ToMethod,
> +  CXXMethodDecl *FromMethod) {
> +  for (auto *FromOverriddenMethod : FromMethod->overridden_methods())
> +ToMethod->addOverriddenMethod(
> +  cast(Importer.Import(const_cast<CXXMethodDecl*>(
> +FromOverriddenMethod;
> +}
> +
>  ASTImporter::ASTImporter(ASTContext , FileManager
> ,
>   ASTContext , FileManager
> ,
>   bool MinimalImport)
>
> Modified: cfe/trunk/tools/clang-import-test/clang-import-test.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-
> import-test/clang-import-test.cpp?rev=305850=305849=305850=diff
> 
> ==
> --- cfe/trunk/tools/clang-import-test/clang-import-test.cpp (original)
> +++ cfe/trunk/tools/clang-import-test/clang-import-test.cpp Tue Jun 20
> 16:06:00 2017
> @@ -17,7 +17,9 @@
>  #include "clang/Basic/TargetInfo.h"
>  #include "clang/Basic/TargetOptions.h"
>  #include "clang/CodeGen/ModuleBuilder.h"
> +#include "clang/Frontend/AST

r305850 - Preserve CXX method overrides in ASTImporter

2017-06-20 Thread Lang Hames via cfe-commits
Author: lhames
Date: Tue Jun 20 16:06:00 2017
New Revision: 305850

URL: http://llvm.org/viewvc/llvm-project?rev=305850=rev
Log:
Preserve CXX method overrides in ASTImporter

Summary:
The ASTImporter should import CXX method overrides from the source context
when it imports a method decl.

Reviewers: spyffe, rsmith, doug.gregor

Reviewed By: spyffe

Differential Revision: https://reviews.llvm.org/D34371

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/tools/clang-import-test/clang-import-test.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=305850=305849=305850=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jun 20 16:06:00 2017
@@ -1184,6 +1184,28 @@ void ASTDumper::VisitFunctionDecl(const
  I != E; ++I)
   dumpCXXCtorInitializer(*I);
 
+  if (const CXXMethodDecl *MD = dyn_cast(D))
+if (MD->size_overridden_methods() != 0) {
+  auto dumpOverride =
+[=](const CXXMethodDecl *D) {
+  SplitQualType T_split = D->getType().split();
+  OS << D << " " << D->getParent()->getName() << "::"
+ << D->getName() << " '"
+ << QualType::getAsString(T_split) << "'";
+};
+
+  dumpChild([=] {
+auto FirstOverrideItr = MD->begin_overridden_methods();
+OS << "Overrides: [ ";
+dumpOverride(*FirstOverrideItr);
+for (const auto *Override :
+   llvm::make_range(FirstOverrideItr + 1,
+MD->end_overridden_methods()))
+  dumpOverride(Override);
+OS << " ]";
+  });
+}
+
   if (D->doesThisDeclarationHaveABody())
 dumpStmt(D->getBody());
 }

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=305850=305849=305850=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Tue Jun 20 16:06:00 2017
@@ -319,6 +319,9 @@ namespace clang {
 bool ImportArrayChecked(const InContainerTy , OIter Obegin) {
   return ImportArrayChecked(InContainer.begin(), InContainer.end(), 
Obegin);
 }
+
+// Importing overrides.
+void ImportOverrides(CXXMethodDecl *ToMethod, CXXMethodDecl *FromMethod);
   };
 }
 
@@ -2025,6 +2028,9 @@ Decl *ASTNodeImporter::VisitFunctionDecl
   // Add this function to the lexical context.
   LexicalDC->addDeclInternal(ToFunction);
 
+  if (auto *FromCXXMethod = dyn_cast(D))
+ImportOverrides(cast(ToFunction), FromCXXMethod);
+
   return ToFunction;
 }
 
@@ -5499,6 +5505,14 @@ Expr *ASTNodeImporter::VisitSubstNonType
 Replacement);
 }
 
+void ASTNodeImporter::ImportOverrides(CXXMethodDecl *ToMethod,
+  CXXMethodDecl *FromMethod) {
+  for (auto *FromOverriddenMethod : FromMethod->overridden_methods())
+ToMethod->addOverriddenMethod(
+  cast(Importer.Import(const_cast(
+FromOverriddenMethod;
+}
+
 ASTImporter::ASTImporter(ASTContext , FileManager ,
  ASTContext , FileManager ,
  bool MinimalImport)

Modified: cfe/trunk/tools/clang-import-test/clang-import-test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-import-test/clang-import-test.cpp?rev=305850=305849=305850=diff
==
--- cfe/trunk/tools/clang-import-test/clang-import-test.cpp (original)
+++ cfe/trunk/tools/clang-import-test/clang-import-test.cpp Tue Jun 20 16:06:00 
2017
@@ -17,7 +17,9 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TargetOptions.h"
 #include "clang/CodeGen/ModuleBuilder.h"
+#include "clang/Frontend/ASTConsumers.h"
 #include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/MultiplexConsumer.h"
 #include "clang/Frontend/TextDiagnosticBuffer.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Lex/Preprocessor.h"
@@ -51,6 +53,10 @@ static llvm::cl::list
   llvm::cl::desc("Argument to pass to the CompilerInvocation"),
   llvm::cl::CommaSeparated);
 
+static llvm::cl::opt
+DumpAST("dump-ast", llvm::cl::init(false),
+llvm::cl::desc("Dump combined AST"));
+
 namespace init_convenience {
 class TestDiagnosticConsumer : public DiagnosticConsumer {
 private:
@@ -233,7 +239,7 @@ std::unique_ptr BuildI
 }
 
 llvm::Error ParseSource(const std::string , CompilerInstance ,
-CodeGenerator ) {
+ASTConsumer ) {
   SourceManager  = CI.getSourceManager();
   const FileEntry *FE = CI.getFileManager().getFile(Path);
   if (!FE) {
@@ -241,13 +247,14 @@ llvm::Error ParseSource(const std::strin
   

r305619 - Call setMustBuildLookupTable on TagDecls in ExternalASTMerger

2017-06-16 Thread Lang Hames via cfe-commits
Author: lhames
Date: Fri Jun 16 19:12:38 2017
New Revision: 305619

URL: http://llvm.org/viewvc/llvm-project?rev=305619=rev
Log:
Call setMustBuildLookupTable on TagDecls in ExternalASTMerger

Summary:
setMustBuildLookupTable should be called on imported TagDecls otherwise we may 
fail
to import their member decls (if they have any).

Not calling the setMustBuildLookupTable method results in a failure in the 
attached test
case when lookup for the 'x' member fails on struct S, which hasn't had its 
decls imported
elsewhere. (By contrast the member-in-struct testcase hasn't run into this issue
because the import of its decls is triggered when the struct instance is 
defined, and the
member access follows this).

Reviewers: spyffe, rsmith

Reviewed By: spyffe, rsmith

Differential Revision: https://reviews.llvm.org/D34253

Added:
cfe/trunk/test/Import/indirect-struct-member-access/
cfe/trunk/test/Import/indirect-struct-member-access/Inputs/
cfe/trunk/test/Import/indirect-struct-member-access/Inputs/S.c
cfe/trunk/test/Import/indirect-struct-member-access/test.c
Modified:
cfe/trunk/lib/AST/ExternalASTMerger.cpp

Modified: cfe/trunk/lib/AST/ExternalASTMerger.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExternalASTMerger.cpp?rev=305619=305618=305619=diff
==
--- cfe/trunk/lib/AST/ExternalASTMerger.cpp (original)
+++ cfe/trunk/lib/AST/ExternalASTMerger.cpp Fri Jun 16 19:12:38 2017
@@ -41,6 +41,7 @@ public:
   Decl *Imported(Decl *From, Decl *To) override {
 if (auto ToTag = dyn_cast(To)) {
   ToTag->setHasExternalLexicalStorage();
+  ToTag->setMustBuildLookupTable();
 } else if (auto ToNamespace = dyn_cast(To)) {
   ToNamespace->setHasExternalVisibleStorage();
 }

Added: cfe/trunk/test/Import/indirect-struct-member-access/Inputs/S.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/indirect-struct-member-access/Inputs/S.c?rev=305619=auto
==
--- cfe/trunk/test/Import/indirect-struct-member-access/Inputs/S.c (added)
+++ cfe/trunk/test/Import/indirect-struct-member-access/Inputs/S.c Fri Jun 16 
19:12:38 2017
@@ -0,0 +1,3 @@
+struct S {
+  int a;
+};

Added: cfe/trunk/test/Import/indirect-struct-member-access/test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/indirect-struct-member-access/test.c?rev=305619=auto
==
--- cfe/trunk/test/Import/indirect-struct-member-access/test.c (added)
+++ cfe/trunk/test/Import/indirect-struct-member-access/test.c Fri Jun 16 
19:12:38 2017
@@ -0,0 +1,4 @@
+// RUN: clang-import-test -import %S/Inputs/S.c -expression %s
+void expr(struct S *MyS) {
+  MyS->a = 3;
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r300140 - [libcxx] Fix __compressed_pair so it doesn't copy the argument multiple times, and add constexpr.

2017-04-24 Thread Lang Hames via cfe-commits
Hi Eric,

Renaming __compressed_pair_elem's member from __first_ to __value_ has
broken a lot of LLDB's data formatters. Would it be possible to rename it
back for consistency? If it's just a rename it would be preferable to the
alternative, which would be to add some clumsy fallback logic in LLDB:

if (auto *Entry = find_element("__first_"))
  // ...
else if (auto *Entry = find_element("__value_"))
  // ...
else
  // ...

Cheers,
Lang.


On Wed, Apr 12, 2017 at 4:45 PM, Eric Fiselier via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ericwf
> Date: Wed Apr 12 18:45:53 2017
> New Revision: 300140
>
> URL: http://llvm.org/viewvc/llvm-project?rev=300140=rev
> Log:
> [libcxx] Fix __compressed_pair so it doesn't copy the argument multiple
> times, and add constexpr.
>
> Summary:
> __compressed_pair takes and passes it's constructor arguments by value.
> This causes arguments to be moved 3 times instead of once. This patch
> addresses that issue and fixes `constexpr` on the constructors.
>
> I would rather have this fix than D27564, and I'm fairly confident it's
> not ABI breaking but I'm not 100% sure.
>
> I prefer this solution because it removes a lot of code and makes the
> implementation *much* smaller.
>
> Reviewers: mclow.lists, K-ballo
>
> Reviewed By: K-ballo
>
> Subscribers: K-ballo, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D27565
>
> Modified:
> libcxx/trunk/include/__hash_table
> libcxx/trunk/include/memory
> libcxx/trunk/include/string
> libcxx/trunk/test/std/utilities/memory/unique.ptr/
> unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp
>
> Modified: libcxx/trunk/include/__hash_table
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/_
> _hash_table?rev=300140=300139=300140=diff
> 
> ==
> --- libcxx/trunk/include/__hash_table (original)
> +++ libcxx/trunk/include/__hash_table Wed Apr 12 18:45:53 2017
> @@ -1402,7 +1402,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
> const key_equal&
> __eql,
> const
> allocator_type& __a)
>  : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a),
> 0)),
> -  __p1_(__node_allocator(__a)),
> +  __p1_(__second_tag(), __node_allocator(__a)),
>__p2_(0, __hf),
>__p3_(1.0f, __eql)
>  {
> @@ -1411,7 +1411,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
>  template 
>  __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const
> allocator_type& __a)
>  : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a),
> 0)),
> -  __p1_(__node_allocator(__a)),
> +  __p1_(__second_tag(), __node_allocator(__a)),
>__p2_(0),
>__p3_(1.0f)
>  {
> @@ -1423,7 +1423,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
>__bucket_list_deleter(allocator_traits<__pointer_allocator>::
>select_on_container_copy_construction(
>__u.__bucket_list_.get_deleter().__alloc()), 0)),
> -  __p1_(allocator_traits<__node_allocator>::
> +  __p1_(__second_tag(), allocator_traits<__node_allocator>::
>select_on_container_copy_construction(__u.__node_alloc())),
>__p2_(0, __u.hash_function()),
>__p3_(__u.__p3_)
> @@ -1434,7 +1434,7 @@ template   __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const
> __hash_table& __u,
> const
> allocator_type& __a)
>  : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a),
> 0)),
> -  __p1_(__node_allocator(__a)),
> +  __p1_(__second_tag(), __node_allocator(__a)),
>__p2_(0, __u.hash_function()),
>__p3_(__u.__p3_)
>  {
> @@ -1468,7 +1468,7 @@ template   __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&&
> __u,
> const
> allocator_type& __a)
>  : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a),
> 0)),
> -  __p1_(__node_allocator(__a)),
> +  __p1_(__second_tag(), __node_allocator(__a)),
>__p2_(0, _VSTD::move(__u.hash_function())),
>__p3_(_VSTD::move(__u.__p3_))
>  {
>
> Modified: libcxx/trunk/include/memory
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/
> memory?rev=300140=300139=300140=diff
> 
> ==
> --- libcxx/trunk/include/memory (original)
> +++ libcxx/trunk/include/memory Wed Apr 12 18:45:53 2017
> @@ -653,7 +653,7 @@ void* align(size_t alignment, size_t siz
>  #include 
>  #include 
>  #include 
> -
> +#include 
>  #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
>  #  include 
>  #endif
> @@ -2070,307 +2070,174 @@ public:
>  };
>  #endif
>
> -template  remove_cv<_T1>::type,
> - 

Re: [libcxx] r276092 - Unbreak is_constructible tests for Clang <= 3.7.

2016-07-20 Thread Lang Hames via cfe-commits
Hi Eric,

I'm seeing failures on the builders that look like they're related to this
- http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/359/

Could you look in to what's going on here?

- Lang.


On Tue, Jul 19, 2016 at 11:36 PM, Eric Fiselier via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ericwf
> Date: Wed Jul 20 01:36:11 2016
> New Revision: 276092
>
> URL: http://llvm.org/viewvc/llvm-project?rev=276092=rev
> Log:
> Unbreak is_constructible tests for Clang <= 3.7.
>
> There is a bug in Clang's __is_constructible builtin that causes it
> to return true for function types; ex [T = void()].
>
>
>
> Modified:
>
> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
>
> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp
>
> Modified:
> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp?rev=276092=276091=276092=diff
>
> ==
> ---
> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
> (original)
> +++
> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
> Wed Jul 20 01:36:11 2016
> @@ -151,9 +151,21 @@ int main()
>  test_is_constructible();
>  test_is_not_constructible();
>
> +test_is_not_constructible();
> +test_is_not_constructible();
> +
> +// TODO: Remove this workaround once Clang <= 3.7 are no longer used
> regularly.
> +// In those compiler versions the __is_constructible builtin gives the
> wrong
> +// results for abominable function types.
> +#if defined(__clang__) && __clang_major__ == 3 && __clang_minor__ < 8
> +#define WORKAROUND_CLANG_BUG
> +#endif
> +#if !defined(WORKAROUND_CLANG_BUG)
> +test_is_not_constructible();
>  test_is_not_constructible ();
>  test_is_not_constructible ();
>  test_is_not_constructible ();
>  test_is_not_constructible ();
>  #endif
> +#endif
>  }
>
> Modified:
> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp?rev=276092=276091=276092=diff
>
> ==
> ---
> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp
> (original)
> +++
> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp
> Wed Jul 20 01:36:11 2016
> @@ -107,7 +107,19 @@ int main()
>  #if TEST_STD_VER >= 11
>  test_is_not_default_constructible();
>  test_is_not_default_constructible();
> +
> +// TODO: Remove this workaround once Clang <= 3.7 are no longer used
> regularly.
> +// In those compiler versions the __is_constructible builtin gives the
> wrong
> +// results for abominable function types.
> +#if defined(__clang__) && __clang_major__ == 3 && __clang_minor__ < 8
> +#define WORKAROUND_CLANG_BUG
> +#endif
> +#if !defined(WORKAROUND_CLANG_BUG)
>  test_is_not_default_constructible();
> -test_is_not_default_constructible();
> +test_is_not_default_constructible ();
> +test_is_not_default_constructible ();
> +test_is_not_default_constructible ();
> +test_is_not_default_constructible ();
> +#endif
>  #endif
>  }
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits