[PATCH] D143142: [clang][lex] Enable Lexer to grow its buffer

2023-02-09 Thread Sunho Kim via Phabricator via cfe-commits
sunho added inline comments.



Comment at: clang/lib/Lex/Lexer.cpp:211
+  L->BufferOffset =
+  StrData - InputFile.getBufferStart(); // FIXME: this is wrong
+  L->BufferSize = L->BufferOffset + TokLen;

v.g.vassilev wrote:
> Is that an outdated comment? If not maybe elaborate why this is wrong.
It's indeed outdated comment. I'll remove it.



Comment at: clang/lib/Lex/Lexer.cpp:1203
 if (L && !L->isLexingRawMode())
-  L->Diag(CP-2, diag::trigraph_ignored);
+  L->Diag(CP - 2 - L->getBuffer().data(), diag::trigraph_ignored);
 return 0;

shafik wrote:
> I wonder do we really need to do these pointer gymnastics, maybe making this 
> a member function would eliminate the need for it.
Yes, we can change it to offset here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143142/new/

https://reviews.llvm.org/D143142

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


[PATCH] D141098: [clang-format][NFC] Set LineEnding to LF in config files

2023-02-07 Thread Sunho Kim via Phabricator via cfe-commits
sunho added a comment.

I think it makes more sense to use stable version of clang-format for that 
purpose but I'm not in a postion to decide as I don't work with format. Can you 
change the script to use latest clang-format for format codebase and revert 
this patch in the meantime? Currently, all patches that touch format part will 
see format verifiaction ci faliure with this patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141098/new/

https://reviews.llvm.org/D141098

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


[PATCH] D141098: [clang-format][NFC] Set LineEnding to LF in config files

2023-02-07 Thread Sunho Kim via Phabricator via cfe-commits
sunho added a comment.

Wouldn't that mean llvm contributors have to format their code using 
clang-format built from top-of-tree source code before submitting the patch? 
Technically that script is for checking if the code has been formatted 
correctly.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141098/new/

https://reviews.llvm.org/D141098

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


[PATCH] D141098: [clang-format][NFC] Set LineEnding to LF in config files

2023-02-06 Thread Sunho Kim via Phabricator via cfe-commits
sunho added a comment.

I think buildbot is "formatting" the patch using clang-format-15. The tests of 
clang-format would be done with latest code.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141098/new/

https://reviews.llvm.org/D141098

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


[PATCH] D141098: [clang-format][NFC] Set LineEnding to LF in config files

2023-02-06 Thread Sunho Kim via Phabricator via cfe-commits
sunho added a comment.

This seems to be causing builtbot lint script error: 
https://buildkite.com/llvm-project/premerge-checks/builds/134501#01862630-8fa9-487c-99b1-9addbe6257d0


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141098/new/

https://reviews.llvm.org/D141098

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


[PATCH] D143148: [clang-repl] Add basic multiline input support

2023-02-06 Thread Sunho Kim via Phabricator via cfe-commits
sunho created this revision.
Herald added a project: All.
sunho retitled this revision from "Add multiline support in clang-repl" to 
"[clang-repl] Add basic multiline support".
sunho edited the summary of this revision.
sunho updated this revision to Diff 494983.
sunho added a comment.
sunho updated this revision to Diff 494985.
sunho added a comment.
sunho updated this revision to Diff 495041.
sunho added a comment.
sunho updated this revision to Diff 495043.
sunho updated this revision to Diff 495044.
sunho updated this revision to Diff 495054.
sunho retitled this revision from "[clang-repl] Add basic multiline support" to 
"[clang-repl] Add basic multiline input support".
sunho edited the summary of this revision.
sunho published this revision for review.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Update


sunho added a comment.

Update


sunho added a comment.

Update


sunho added a comment.

Update


Add basic multi-line input support to clang-repl by using newly available 
SourceFileGrower interface of Preprocessor.

Compared to cling, this change uses fully fledged clang preprocessor (not 
MetaLexer) so it supports very complicated macro expressions.

NOTE: this is the related to 
https://discourse.llvm.org/t/rfc-flexible-lexer-buffering-for-handling-incomplete-input-in-interactive-c-c/64180


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143148

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/test/Interpreter/multiline-func-macro-brace-error.cpp
  clang/test/Interpreter/multiline-func-macro-brace.cpp
  clang/test/Interpreter/multiline-func.cpp
  clang/test/Interpreter/multiline-ifdef.cpp
  clang/tools/clang-repl/ClangRepl.cpp

Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -124,7 +124,8 @@
 continue;
   }
 
-  if (auto Err = Interp->ParseAndExecute(*Line)) {
+  if (auto Err =
+  Interp->ParseAndExecute(*Line, [&]() { return LE.readLine(); })) {
 llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
 HasError = true;
   }
Index: clang/test/Interpreter/multiline-ifdef.cpp
===
--- /dev/null
+++ clang/test/Interpreter/multiline-ifdef.cpp
@@ -0,0 +1,43 @@
+// REQUIRES: host-supports-jit
+// UNSUPPORTED: system-aix
+// RUN: cat %s | clang-repl 2>&1 | FileCheck %s
+// Check if complex multiline ifdef directive is working.
+extern "C" int printf(const char *, ...);
+
+#define ___DEFINED_SYMBOL
+
+#ifdef ___DEFINED_SYMBOL
+int test_ifdef_one() {
+  printf("Simple multiline ifdef\n");
+}
+#endif
+// CHECK: Simple multiline ifdef
+
+#ifdef ___DEFINED_SYMBOL
+#ifndef ___DEFINED_SYMBOL
+int test_ifdef_two() {
+  printf("Wrong\n");
+}
+#endif
+#ifdef ___DEFINED_SYMBOL
+int test_ifdef_two() {
+  printf("Multiline ifdef two stack\n");
+}
+#endif
+#endif
+// CHECK-NEXT: Multiline ifdef two stack
+
+#ifdef ___DEFINED_SYMBOL
+#ifdef ___DEFINED_SYMBOL
+#ifdef ___DEFINED_SYMBOL
+#ifdef ___DEFINED_SYMBOL
+int test_ifdef_four() {
+  printf("Multiline ifdef four stack\n");
+}
+#endif
+#endif
+#endif
+#endif
+// CHECK-NEXT: Multiline ifdef four stack
+
+%quit
\ No newline at end of file
Index: clang/test/Interpreter/multiline-func.cpp
===
--- /dev/null
+++ clang/test/Interpreter/multiline-func.cpp
@@ -0,0 +1,16 @@
+// REQUIRES: host-supports-jit
+// UNSUPPORTED: system-aix
+// RUN: cat %s | clang-repl | FileCheck %s
+// Check a multiline function is parsed and executed correctly.
+extern "C" int printf(const char *, ...);
+int test_multiline_function() {
+  printf("Multiline\n");
+  printf("Function\n");
+  return 0;
+}
+
+auto r1 = test_multiline_function();
+// CHECK: Multiline
+// CHECK-NEXT: Function
+
+% quit
\ No newline at end of file
Index: clang/test/Interpreter/multiline-func-macro-brace.cpp
===
--- /dev/null
+++ clang/test/Interpreter/multiline-func-macro-brace.cpp
@@ -0,0 +1,53 @@
+// REQUIRES: host-supports-jit
+// UNSUPPORTED: system-aix
+// RUN: cat %s | clang-repl | FileCheck %s
+// Check a brace counting is not broken by introduction of macro directives.
+// Brace counting is done to support multiline functions.
+extern "C" int printf(const char *, ...);
+
+#define ___DEFINED_SYMBOL
+
+int test_multiline_brace_count_simple() {
+#ifdef ___UNDEFINED_SYMBOL
+  {
+#else
+  printf("Simple multiline brace count\n");
+#endif
+return 0;
+  }
+  auto r1 = test_multiline_brace_count_simple();
+  // CHECK: Simple multiline brace count
+
+  int test_multiline_brace_count_defined() {
+#ifdef ___DEFINED_SYMBOL
+

[PATCH] D143144: [clang][lex] Add TryGrowLexerBuffer/SourceFileGrower

2023-02-06 Thread Sunho Kim via Phabricator via cfe-commits
sunho created this revision.
Herald added a project: All.
sunho retitled this revision from "asdfasdf" to "[clang][lex] Add 
TryExpandBuffer callback".
sunho edited the summary of this revision.
sunho updated this revision to Diff 494978.
sunho added a comment.
sunho updated this revision to Diff 495037.
sunho updated this revision to Diff 495039.
sunho retitled this revision from "[clang][lex] Add TryExpandBuffer callback" 
to "[clang][lex] Add TryGrowLexerBuffer/SourceFileGrower".
sunho edited the summary of this revision.
sunho edited the summary of this revision.
sunho edited the summary of this revision.
sunho edited the summary of this revision.
sunho published this revision for review.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Update


sunho added a comment.

Update


sunho added a comment.

Update


Add TryGrowLexerBuffer to Lexer and SourceFileGrower to Preprocessor that can 
be used to grow the source code buffer when Lexer reaches the eof of the buffer.

Since clang-repl receive source code incrementally line by line, we need to 
grow source code buffer. This change adds the interfaces to Lexer/Preprocessor 
in order to accommodate this need. If SourceFileGrower interface is registered 
to Preprocessor, it will call TryGrowFile method when Lexer reached eof. Inside 
this method, the user can grow the file and return true to request Lexer to 
continue the lexing from the last point.

When Lexer reaches eof it will call TryGrowLexerBuffer callback specified in 
the constructor to try growing buffer and if it got new buffer, it will 
continue the lexing from the last point. Preprocessor registers 
TryGrowLexerBuffer callback in order to implement handling of SourceFileGrower.

Note that practically all the code changes will not affect the AOT clang world 
since they are all disabled when Preprocessor doesn't have SourceFileGrower 
instance.

NOTE: This is part 2 and 3 of 
https://discourse.llvm.org/t/rfc-flexible-lexer-buffering-for-handling-incomplete-input-in-interactive-c-c/64180


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143144

Files:
  clang/include/clang/Lex/Lexer.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Lex/Lexer.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/unittests/Lex/LexerTest.cpp

Index: clang/unittests/Lex/LexerTest.cpp
===
--- clang/unittests/Lex/LexerTest.cpp
+++ clang/unittests/Lex/LexerTest.cpp
@@ -26,9 +26,12 @@
 #include "clang/Lex/PreprocessorOptions.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#include 
 #include 
+#include 
 #include 
 
 namespace {
@@ -49,12 +52,7 @@
 Target = TargetInfo::CreateTargetInfo(Diags, TargetOpts);
   }
 
-  std::unique_ptr CreatePP(StringRef Source,
- TrivialModuleLoader ) {
-std::unique_ptr Buf =
-llvm::MemoryBuffer::getMemBuffer(Source);
-SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(Buf)));
-
+  std::unique_ptr CreatePP(TrivialModuleLoader ) {
 HeaderSearch HeaderInfo(std::make_shared(), SourceMgr,
 Diags, LangOpts, Target.get());
 std::unique_ptr PP = std::make_unique(
@@ -63,6 +61,14 @@
 /*IILookup =*/nullptr,
 /*OwnsHeaderSearch =*/false);
 PP->Initialize(*Target);
+return PP;
+  }
+
+  std::unique_ptr CreatePP(StringRef Source, TrivialModuleLoader ) {
+std::unique_ptr Buf =
+llvm::MemoryBuffer::getMemBuffer(Source);
+SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(Buf)));
+std::unique_ptr PP = CreatePP(ModLoader);
 PP->EnterMainSourceFile();
 return PP;
   }
@@ -660,4 +666,59 @@
   }
   EXPECT_TRUE(ToksView.empty());
 }
+
+TEST_F(LexerTest, BasicSourceFileGrower) {
+  std::deque SourceLines = {
+"int main() {",
+"  return 0;",
+"}"
+  };
+
+  TrivialModuleLoader ModLoader;
+  PP = CreatePP(ModLoader);
+  auto  = PP->getSourceManager();
+
+  struct FileGrower : public SourceFileGrower {
+FileGrower(SourceManager& SM, std::deque SourceLines) : SM(SM), SourceLines(SourceLines) {
+  FE = SM.getFileManager().getVirtualFile("main.cpp", 1024, 0);
+  CurFileID = SM.createFileID(FE, SourceLocation(), SrcMgr::C_User);
+  SM.overrideFileContents(FE, llvm::MemoryBufferRef("", ""));
+}
+~FileGrower() = default;
+
+bool TryGrowFile(FileID FileID) override {
+  if (FileID != CurFileID)
+return false;
+  if (SourceLines.empty())
+return false;
+  CurStr += SourceLines.front();
+  CurStr.push_back('\n');
+  SourceLines.pop_front();
+  CurBuf = llvm::MemoryBuffer::getMemBuffer(CurStr);
+  SM.overrideFileContents(FE, CurBuf->getMemBufferRef());
+  return true;
+}
+SourceManager& SM;
+std::deque SourceLines;
+

[PATCH] D141380: [clang-repl] XFAIL riscv targets in simple-exception test case

2023-01-13 Thread Sunho Kim via Phabricator via cfe-commits
sunho added a subscriber: Hahnfeld.
sunho added a comment.

Maybe @Hahnfeld knows something as he added riscv support to clang-repl 
recently.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141380/new/

https://reviews.llvm.org/D141380

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


[PATCH] D141380: [clang-repl] XFAIL riscv targets in simple-exception test case

2023-01-13 Thread Sunho Kim via Phabricator via cfe-commits
sunho added a comment.

Do you have an exception support in your libc and it's dynamically linked? I 
believe if clang-repl was able to execute the program, it must have 
successfully linked to cxxthrow symbols and so exception handling works 
correctly.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141380/new/

https://reviews.llvm.org/D141380

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


[PATCH] D130788: [clang-repl] Disable building when LLVM_STATIC_LINK_CXX_STDLIB is ON.

2022-08-19 Thread Sunho Kim via Phabricator via cfe-commits
sunho added a comment.

In D130788#3732325 , @sbc100 wrote:

> In D130788#3731232 , @sunho wrote:
>
>> In D130788#3730533 , @sbc100 wrote:
>>
>>> I'm not totally sure but I think the change is responsible for the 
>>> emscripten integration bot failing `InterpreterTest.CatchException`: 
>>> https://logs.chromium.org/logs/emscripten-releases/buildbucket/cr-buildbucket/8807160007692150337/+/u/LLVM_regression/stdout
>>>
>>>   [==] Running 1 test from 1 test suite.
>>>   [--] Global test environment set-up.
>>>   [--] 1 test from InterpreterTest
>>>   [ RUN  ] InterpreterTest.CatchException
>>>   JIT session error: Symbols not found: [ __gxx_personality_v0, 
>>> _ZSt9terminatev, _ZTVN10__cxxabiv117__class_type_infoE, 
>>> __cxa_allocate_exception, __cxa_begin_catch, __cxa_end_catch, 
>>> __cxa_free_exception, __cxa_throw ]
>>>   Failure value returned from cantFail wrapped call
>>>   Failed to materialize symbols: { (main, { _ZN16custom_exceptionC2EPKc, 
>>> __clang_call_terminate, _ZTI16custom_exception, _ZTS16custom_exception, 
>>> throw_exception }) }
>>>   UNREACHABLE executed at 
>>> /b/s/w/ir/cache/builder/emscripten-releases/llvm-project/llvm/include/llvm/Support/Error.h:786!
>>>   Stack dump without symbol names (ensure you have llvm-symbolizer in your 
>>> PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
>>>   
>>> /b/s/w/ir/cache/builder/emscripten-releases/build/llvm-out/tools/clang/unittests/Interpreter/ExceptionTests/./ClangReplInterpreterExceptionTests(+0x2464413)[0x55cb14660413]
>>>   
>>> /b/s/w/ir/cache/builder/emscripten-releases/build/llvm-out/tools/clang/unittests/Interpreter/ExceptionTests/./ClangReplInterpreterExceptionTests(+0x246236c)[0x55cb1465e36c]
>>>   
>>> /b/s/w/ir/cache/builder/emscripten-releases/build/llvm-out/tools/clang/unittests/Interpreter/ExceptionTests/./ClangReplInterpreterExceptionTests(+0x24648df)[0x55cb146608df]
>>>   /lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x7fad2fab1980]
>>>   /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7fad2eb0de87]
>>>   /lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7fad2eb0f7f1]
>>>   
>>> /b/s/w/ir/cache/builder/emscripten-releases/build/llvm-out/tools/clang/unittests/Interpreter/ExceptionTests/./ClangReplInterpreterExceptionTests(+0x23f798f)[0x55cb145f398f]
>>>   
>>> /b/s/w/ir/cache/builder/emscripten-releases/build/llvm-out/tools/clang/unittests/Interpreter/ExceptionTests/./ClangReplInterpreterExceptionTests(+0x1e9de35)[0x55cb14099e35]
>>>   
>>> /b/s/w/ir/cache/builder/emscripten-releases/build/llvm-out/tools/clang/unittests/Interpreter/ExceptionTests/./ClangReplInterpreterExceptionTests(+0x1e9d597)[0x55cb14099597]
>>>   
>>> /b/s/w/ir/cache/builder/emscripten-releases/build/llvm-out/tools/clang/unittests/Interpreter/ExceptionTests/./ClangReplInterpreterExceptionTests(+0x246d6be)[0x55cb146696be]
>>>   
>>> /b/s/w/ir/cache/builder/emscripten-releases/build/llvm-out/tools/clang/unittests/Interpreter/ExceptionTests/./ClangReplInterpreterExceptionTests(+0x246e659)[0x55cb1466a659]
>>>   
>>> /b/s/w/ir/cache/builder/emscripten-releases/build/llvm-out/tools/clang/unittests/Interpreter/ExceptionTests/./ClangReplInterpreterExceptionTests(+0x246ee40)[0x55cb1466ae40]
>>>   
>>> /b/s/w/ir/cache/builder/emscripten-releases/build/llvm-out/tools/clang/unittests/Interpreter/ExceptionTests/./ClangReplInterpreterExceptionTests(+0x247b2c3)[0x55cb146772c3]
>>>   
>>> /b/s/w/ir/cache/builder/emscripten-releases/build/llvm-out/tools/clang/unittests/Interpreter/ExceptionTests/./ClangReplInterpreterExceptionTests(+0x247ab42)[0x55cb14676b42]
>>>   
>>> /b/s/w/ir/cache/builder/emscripten-releases/build/llvm-out/tools/clang/unittests/Interpreter/ExceptionTests/./ClangReplInterpreterExceptionTests(+0x246559c)[0x55cb1466159c]
>>>   /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x7fad2eaf0c87]
>>>   
>>> /b/s/w/ir/cache/builder/emscripten-releases/build/llvm-out/tools/clang/unittests/Interpreter/ExceptionTests/./ClangReplInterpreterExceptionTests(+0x1e9ceda)[0x55cb14098eda]
>>>
>>> This started happening consistently after this change 
>>> https://chromium.googlesource.com/emscripten-releases/+/584b2f531314d1e70cd5ebadcce7e015a6215c9a.
>>>   The only CL in that list that looks related seems to be this one.
>>
>> Could you share the detailed build configuration of those bots?
>
> All the step should be visible here: 
> https://ci.chromium.org/ui/p/emscripten-releases/builders/ci/linux-test-suites/b8805531315340503553/steps
>
> The most relevant one I guess would be:
>
> https://logs.chromium.org/logs/emscripten-releases/buildbucket/cr-buildbucket/8805531315340503553/+/u/Build_LLVM/stdout
>
> Here you can see LLVM being configured with:
>
>   
> subprocess.check_call(`/b/s/w/ir/cache/builder/emscripten-releases/cmake-3.21.3-linux-x86_64/bin/cmake
>  -G Ninja 

[PATCH] D130788: [clang-repl] Disable building when LLVM_STATIC_LINK_CXX_STDLIB is ON.

2022-08-18 Thread Sunho Kim via Phabricator via cfe-commits
sunho added a comment.

In D130788#3730533 , @sbc100 wrote:

> I'm not totally sure but I think the change is responsible for the emscripten 
> integration bot failing `InterpreterTest.CatchException`: 
> https://logs.chromium.org/logs/emscripten-releases/buildbucket/cr-buildbucket/8807160007692150337/+/u/LLVM_regression/stdout
>
>   [==] Running 1 test from 1 test suite.
>   [--] Global test environment set-up.
>   [--] 1 test from InterpreterTest
>   [ RUN  ] InterpreterTest.CatchException
>   JIT session error: Symbols not found: [ __gxx_personality_v0, 
> _ZSt9terminatev, _ZTVN10__cxxabiv117__class_type_infoE, 
> __cxa_allocate_exception, __cxa_begin_catch, __cxa_end_catch, 
> __cxa_free_exception, __cxa_throw ]
>   Failure value returned from cantFail wrapped call
>   Failed to materialize symbols: { (main, { _ZN16custom_exceptionC2EPKc, 
> __clang_call_terminate, _ZTI16custom_exception, _ZTS16custom_exception, 
> throw_exception }) }
>   UNREACHABLE executed at 
> /b/s/w/ir/cache/builder/emscripten-releases/llvm-project/llvm/include/llvm/Support/Error.h:786!
>   Stack dump without symbol names (ensure you have llvm-symbolizer in your 
> PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
>   
> /b/s/w/ir/cache/builder/emscripten-releases/build/llvm-out/tools/clang/unittests/Interpreter/ExceptionTests/./ClangReplInterpreterExceptionTests(+0x2464413)[0x55cb14660413]
>   
> /b/s/w/ir/cache/builder/emscripten-releases/build/llvm-out/tools/clang/unittests/Interpreter/ExceptionTests/./ClangReplInterpreterExceptionTests(+0x246236c)[0x55cb1465e36c]
>   
> /b/s/w/ir/cache/builder/emscripten-releases/build/llvm-out/tools/clang/unittests/Interpreter/ExceptionTests/./ClangReplInterpreterExceptionTests(+0x24648df)[0x55cb146608df]
>   /lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x7fad2fab1980]
>   /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7fad2eb0de87]
>   /lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7fad2eb0f7f1]
>   
> /b/s/w/ir/cache/builder/emscripten-releases/build/llvm-out/tools/clang/unittests/Interpreter/ExceptionTests/./ClangReplInterpreterExceptionTests(+0x23f798f)[0x55cb145f398f]
>   
> /b/s/w/ir/cache/builder/emscripten-releases/build/llvm-out/tools/clang/unittests/Interpreter/ExceptionTests/./ClangReplInterpreterExceptionTests(+0x1e9de35)[0x55cb14099e35]
>   
> /b/s/w/ir/cache/builder/emscripten-releases/build/llvm-out/tools/clang/unittests/Interpreter/ExceptionTests/./ClangReplInterpreterExceptionTests(+0x1e9d597)[0x55cb14099597]
>   
> /b/s/w/ir/cache/builder/emscripten-releases/build/llvm-out/tools/clang/unittests/Interpreter/ExceptionTests/./ClangReplInterpreterExceptionTests(+0x246d6be)[0x55cb146696be]
>   
> /b/s/w/ir/cache/builder/emscripten-releases/build/llvm-out/tools/clang/unittests/Interpreter/ExceptionTests/./ClangReplInterpreterExceptionTests(+0x246e659)[0x55cb1466a659]
>   
> /b/s/w/ir/cache/builder/emscripten-releases/build/llvm-out/tools/clang/unittests/Interpreter/ExceptionTests/./ClangReplInterpreterExceptionTests(+0x246ee40)[0x55cb1466ae40]
>   
> /b/s/w/ir/cache/builder/emscripten-releases/build/llvm-out/tools/clang/unittests/Interpreter/ExceptionTests/./ClangReplInterpreterExceptionTests(+0x247b2c3)[0x55cb146772c3]
>   
> /b/s/w/ir/cache/builder/emscripten-releases/build/llvm-out/tools/clang/unittests/Interpreter/ExceptionTests/./ClangReplInterpreterExceptionTests(+0x247ab42)[0x55cb14676b42]
>   
> /b/s/w/ir/cache/builder/emscripten-releases/build/llvm-out/tools/clang/unittests/Interpreter/ExceptionTests/./ClangReplInterpreterExceptionTests(+0x246559c)[0x55cb1466159c]
>   /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x7fad2eaf0c87]
>   
> /b/s/w/ir/cache/builder/emscripten-releases/build/llvm-out/tools/clang/unittests/Interpreter/ExceptionTests/./ClangReplInterpreterExceptionTests(+0x1e9ceda)[0x55cb14098eda]
>
> This started happening consistently after this change 
> https://chromium.googlesource.com/emscripten-releases/+/584b2f531314d1e70cd5ebadcce7e015a6215c9a.
>   The only CL in that list that looks related seems to be this one.

Could you share the detailed build configuration of those bots?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130788/new/

https://reviews.llvm.org/D130788

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


[PATCH] D130788: [clang-repl] Disable building when LLVM_STATIC_LINK_CXX_STDLIB is ON.

2022-07-31 Thread Sunho Kim via Phabricator via cfe-commits
sunho added a comment.

In D130788#3689820 , @dyung wrote:

> In D130788#3689795 , @sunho wrote:
>
>> The test isn't supposed to be ran on windows -- we don't support exception 
>> on windows at all yet. I guess XFAIL: windows-msvc, windows-gnu is not 
>> working out.
>
> If you don't want the test run on Windows, I think what you want is probably 
> `system-windows` rather than `windows-msvc` and `windows-gnu`. The former 
> will mark as XFAIL when it is run on Windows, while the latter will mark as 
> XFAIL when the target triple includes those strings.

Should have been fixed in 
https://github.com/llvm/llvm-project/commit/773d51ce3bedd091539aa86a5e5fc15a9174ff7b.
 Can you check it out?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130788/new/

https://reviews.llvm.org/D130788

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


[PATCH] D130788: [clang-repl] Disable building when LLVM_STATIC_LINK_CXX_STDLIB is ON.

2022-07-31 Thread Sunho Kim via Phabricator via cfe-commits
sunho added a comment.

In D130788#3689693 , @dyung wrote:

> The test simple-exception.cpp is failing on the PS5 Windows bot after this 
> change. Can you take a look?
>
> I forced a build using the commit prior to yours which passed: 
> https://lab.llvm.org/buildbot/#/builders/216/builds/7636
> And then I forced a build using your commit, and the test failed: 
> https://lab.llvm.org/buildbot/#/builders/216/builds/7637
>
>    TEST 'Clang :: Interpreter/simple-exception.cpp' 
> FAILED 
>   Script:
>   --
>   : 'RUN: at line 4';   cat 
> Z:\test\llvm-project\clang\test\Interpreter\simple-exception.cpp | 
> z:\test\build\bin\clang-repl.exe | z:\test\build\bin\filecheck.exe 
> Z:\test\llvm-project\clang\test\Interpreter\simple-exception.cpp
>   --
>   Exit Code: 1
>   Command Output (stdout):
>   --
>   $ ":" "RUN: at line 4"
>   $ "cat" "Z:\test\llvm-project\clang\test\Interpreter\simple-exception.cpp"
>   $ "z:\test\build\bin\clang-repl.exe"
>   # command stderr:
>   JIT session error: Symbols not found: [ ??_7type_info@@6B@ ]
>   error: Failed to materialize symbols: { (main, { _CT??_R0PEAX@88, 
> ?f@@YAHXZ, ?r1@@3HA, _CTA2PEAD, ??_C@_0BB@DPCIAKEG@Simple?5exception?$AA@, 
> ??_C@_03OFAPEBGM@?$CFs?6?$AA@, $.incr_module_8.__inits.0, 
> ?checkException@@YAHXZ, _TIC2PEAD, ??_R0PEAD@8, ??_R0PEAX@8, 
> __orc_init_func.incr_module_8, ??_C@_0N@CKKDCGKM@Running?5f?$CI?$CJ?6?$AA@, 
> _CT??_R0PEAD@88 }) }
>   error: Failed to materialize symbols: { (main, { 
> __orc_init_func.incr_module_8 }) }
>   $ "z:\test\build\bin\filecheck.exe" 
> "Z:\test\llvm-project\clang\test\Interpreter\simple-exception.cpp"
>   # command stderr:
>   Z:\test\llvm-project\clang\test\Interpreter\simple-exception.cpp:10:11: 
> error: CHECK: expected string not found in input
>   // CHECK: Running f()
> ^
>   :1:1: note: scanning from here
>   clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> 
> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> 
> clang-repl> 
>   ^
>   :1:11: note: possible intended match here
>   clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> 
> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> 
> clang-repl> 
> ^
>   Input file: 
>   Check file: Z:\test\llvm-project\clang\test\Interpreter\simple-exception.cpp
>   -dump-input=help explains the following input dump.
>   Input was:
>   <<
>   1: clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> 
> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> 
> clang-repl> clang-repl>  
>   check:10'0 
> X
>  error: no match found
>   check:10'1   ?  
>   
>possible intended match
>   >>
>   error: command failed with exit status: 1
>   --
>   

The test isn't supposed to be ran on windows -- we don't support exception on 
windows at all yet. I guess XFAIL: windows-msvc, windows-gnu is not working out.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130788/new/

https://reviews.llvm.org/D130788

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


[PATCH] D130788: [clang-repl] Disable building when LLVM_STATIC_LINK_CXX_STDLIB is ON.

2022-07-30 Thread Sunho Kim via Phabricator via cfe-commits
sunho added a comment.

https://lab.llvm.org/buildbot/#/builders/98/builds/22588 fuschia build bot is 
happy with this change and I don't see new build breakages so far!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130788/new/

https://reviews.llvm.org/D130788

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


[PATCH] D130788: [clang-repl] Disable building when LLVM_STATIC_LINK_CXX_STDLIB is ON.

2022-07-30 Thread Sunho Kim via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa8f2e24e48fd: [clang-repl] Disable building when 
LLVM_STATIC_LINK_CXX_STDLIB is ON. (authored by sunho).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130788/new/

https://reviews.llvm.org/D130788

Files:
  clang/CMakeLists.txt
  clang/test/CMakeLists.txt
  clang/test/Interpreter/code-undo.cpp
  clang/test/Interpreter/execute-weak.cpp
  clang/test/Interpreter/execute.cpp
  clang/test/Interpreter/global-dtor-win.cpp
  clang/test/Interpreter/global-dtor.cpp
  clang/test/Interpreter/lit.local.cfg
  clang/test/Interpreter/plugins.cpp
  clang/test/Interpreter/simple-exception.cpp
  clang/test/lit.cfg.py
  clang/tools/CMakeLists.txt
  clang/tools/clang-repl/ClangRepl.cpp
  clang/unittests/CMakeLists.txt
  clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp

Index: clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
===
--- clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
+++ clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
@@ -113,17 +113,6 @@
   Triple.getArch() == llvm::Triple::aarch64_32))
 return;
 
-  // Check if platform does not support exceptions.
-  {
-// Force the creation of an incremental executor to call getSymbolAddress.
-llvm::cantFail(Interp->ParseAndExecute(""));
-auto Sym = Interp->getSymbolAddress("__cxa_throw");
-if (!Sym) {
-  LLVMConsumeError(llvm::wrap(Sym.takeError()));
-  return;
-}
-  }
-
   llvm::cantFail(Interp->ParseAndExecute(ExceptionCode));
   testing::internal::CaptureStdout();
   auto ThrowException =
Index: clang/unittests/CMakeLists.txt
===
--- clang/unittests/CMakeLists.txt
+++ clang/unittests/CMakeLists.txt
@@ -35,7 +35,9 @@
 add_subdirectory(Rewrite)
 add_subdirectory(Sema)
 add_subdirectory(CodeGen)
-add_subdirectory(Interpreter)
+if(HAVE_CLANG_REPL_SUPPORT)
+  add_subdirectory(Interpreter)
+endif()
 # FIXME: libclang unit tests are disabled on Windows due
 # to failures, mostly in libclang.VirtualFileOverlay_*.
 if(NOT WIN32 AND CLANG_TOOL_LIBCLANG_BUILD) 
Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -28,8 +28,6 @@
   llvm::cl::CommaSeparated);
 static llvm::cl::opt OptHostSupportsJit("host-supports-jit",
   llvm::cl::Hidden);
-static llvm::cl::opt OptHostSupportsException("host-supports-exception",
-llvm::cl::Hidden);
 static llvm::cl::list OptInputs(llvm::cl::Positional,
  llvm::cl::desc("[code to run]"));
 
@@ -67,42 +65,6 @@
   return Errs ? EXIT_FAILURE : EXIT_SUCCESS;
 }
 
-// Check if the host environment supports c++ exception handling
-// by querying the existence of symbol __cxa_throw.
-static bool checkExceptionSupport() {
-  auto J = llvm::orc::LLJITBuilder().create();
-  if (!J) {
-llvm::consumeError(J.takeError());
-return false;
-  }
-
-  std::vector Dummy;
-  auto CI = clang::IncrementalCompilerBuilder::create(Dummy);
-  if (!CI) {
-llvm::consumeError(CI.takeError());
-return false;
-  }
-
-  auto Interp = clang::Interpreter::create(std::move(*CI));
-  if (!Interp) {
-llvm::consumeError(Interp.takeError());
-return false;
-  }
-
-  if (auto Err = (*Interp)->ParseAndExecute("")) {
-llvm::consumeError(std::move(Err));
-return false;
-  }
-
-  auto Sym = (*Interp)->getSymbolAddress("__cxa_throw");
-  if (!Sym) {
-llvm::consumeError(Sym.takeError());
-return false;
-  }
-
-  return true;
-}
-
 llvm::ExitOnError ExitOnErr;
 int main(int argc, const char **argv) {
   ExitOnErr.setBanner("clang-repl: ");
@@ -127,14 +89,6 @@
 return 0;
   }
 
-  if (OptHostSupportsException) {
-if (checkExceptionSupport())
-  llvm::outs() << "true\n";
-else
-  llvm::outs() << "false\n";
-return 0;
-  }
-
   // FIXME: Investigate if we could use runToolOnCodeWithArgs from tooling. It
   // can replace the boilerplate code for creation of the compiler instance.
   auto CI = ExitOnErr(clang::IncrementalCompilerBuilder::create(ClangArgv));
Index: clang/tools/CMakeLists.txt
===
--- clang/tools/CMakeLists.txt
+++ clang/tools/CMakeLists.txt
@@ -14,7 +14,9 @@
 add_clang_subdirectory(clang-offload-bundler)
 add_clang_subdirectory(clang-offload-wrapper)
 add_clang_subdirectory(clang-scan-deps)
-add_clang_subdirectory(clang-repl)
+if(HAVE_CLANG_REPL_SUPPORT)
+  

[PATCH] D130786: [clang-repl] Disable execution unittests on unsupported platforms.

2022-07-29 Thread Sunho Kim via Phabricator via cfe-commits
sunho added a comment.

@alanphipps I just confirmed that the buildbot failures were fixed by the new 
fix https://reviews.llvm.org/rG65c9265f4158. Could you check out if this fixes 
the failure on your end too?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130786/new/

https://reviews.llvm.org/D130786

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


[PATCH] D130786: [clang-repl] Disable execution unittests on unsupported platforms.

2022-07-29 Thread Sunho Kim via Phabricator via cfe-commits
sunho added a comment.

In D130786#3688387 , @alanphipps 
wrote:

> I'm still seeing a failure on my downstream Arm compiler on Linux in the unit 
> tests -- I thought I saw the same failure on the buildbots:
>
>   FAIL: llvm_regressions :: 
> Clang-Unit/Interpreter/ClangReplInterpreterTests/1/8
>   3   
> 
>   4   Script(shard):
>   5   --
>   6   
> GTEST_OUTPUT=json:/scratch/build_jenkins/workspace/Downstream_Changes/llvm_cgt/arm-llvm/RelWithAsserts/llvm/tools/clang/unittests/Interpreter/./ClangReplInterpreterTests-Clang-Unit-39149-1-8.json
>  GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=8 GTEST_SHARD_INDEX=1 
> /scratch/build_jenkins/workspace/Downstream_Changes/llvm_cgt/arm-llvm/RelWithAsserts/llvm/tools/clang/unittests/Interpreter/./ClangReplInterpreterTests
>   7   --
>   8
>   9   Note: This is test shard 2 of 8.
>   10  [==] Running 1 test from 1 test suite.
>   11  [--] Global test environment set-up.
>   12  [--] 1 test from IncrementalProcessing
>   13  [ RUN  ] IncrementalProcessing.FindMangledNameSymbol
>   14   #0 0x00676fc3 
> llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
> (/scratch/build_jenkins/workspace/Downstream_Changes/llvm_cgt/arm-llvm/RelWithAsserts/llvm/tools/clang/unittests/Interpreter/./ClangReplInterpreterTests+0x676fc3)
>   15   #1 0x00674e1c llvm::sys::RunSignalHandlers() 
> (/scratch/build_jenkins/workspace/Downstream_Changes/llvm_cgt/arm-llvm/RelWithAsserts/llvm/tools/clang/unittests/Interpreter/./ClangReplInterpreterTests+0x674e1c)
>   16   #2 0x006775c6 SignalHandler(int) 
> (/scratch/build_jenkins/workspace/Downstream_Changes/llvm_cgt/arm-llvm/RelWithAsserts/llvm/tools/clang/unittests/Interpreter/./ClangReplInterpreterTests+0x6775c6)
>   17   #3 0x7fa295c6f330 __restore_rt 
> (/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
>   18   #4 0x00b54a97 clang::IncrementalExecutor::cleanUp() 
> (/scratch/build_jenkins/workspace/Downstream_Changes/llvm_cgt/arm-llvm/RelWithAsserts/llvm/tools/clang/unittests/Interpreter/./ClangReplInterpreterTests+0xb54a97)
>   19   #5 0x00b521e4 clang::Interpreter::~Interpreter() 
> (/scratch/build_jenkins/workspace/Downstream_Changes/llvm_cgt/arm-llvm/RelWithAsserts/llvm/tools/clang/unittests/Interpreter/./ClangReplInterpreterTests+0xb521e4)
>   20   #6 0x00489a13 (anonymous 
> namespace)::IncrementalProcessing_FindMangledNameSymbol_Test::TestBody() 
> (/scratch/build_jenkins/workspace/Downstream_Changes/llvm_cgt/arm-llvm/RelWithAsserts/llvm/tools/clang/unittests/Interpreter/./ClangReplInterpreterTests+0x489a13)
>   21   #7 0x0068889c testing::Test::Run() 
> (/scratch/build_jenkins/workspace/Downstream_Changes/llvm_cgt/arm-llvm/RelWithAsserts/llvm/tools/clang/unittests/Interpreter/./ClangReplInterpreterTests+0x68889c)
>   22   #8 0x006895c9 testing::TestInfo::Run() 
> (/scratch/build_jenkins/workspace/Downstream_Changes/llvm_cgt/arm-llvm/RelWithAsserts/llvm/tools/clang/unittests/Interpreter/./ClangReplInterpreterTests+0x6895c9)
>   23   #9 0x00689c77 testing::TestSuite::Run() 
> (/scratch/build_jenkins/workspace/Downstream_Changes/llvm_cgt/arm-llvm/RelWithAsserts/llvm/tools/clang/unittests/Interpreter/./ClangReplInterpreterTests+0x689c77)
>   24  #10 0x00699647 
> testing::internal::UnitTestImpl::RunAllTests() 
> (/scratch/build_jenkins/workspace/Downstream_Changes/llvm_cgt/arm-llvm/RelWithAsserts/llvm/tools/clang/unittests/Interpreter/./ClangReplInterpreterTests+0x699647)
>   25  #11 0x00698ec3 testing::UnitTest::Run() 
> (/scratch/build_jenkins/workspace/Downstream_Changes/llvm_cgt/arm-llvm/RelWithAsserts/llvm/tools/clang/unittests/Interpreter/./ClangReplInterpreterTests+0x698ec3)
>   26  #12 0x00680fec main 
> (/scratch/build_jenkins/workspace/Downstream_Changes/llvm_cgt/arm-llvm/RelWithAsserts/llvm/tools/clang/unittests/Interpreter/./ClangReplInterpreterTests+0x680fec)
>   27  #13 0x7fa294d64f45 __libc_start_main 
> /build/eglibc-xkFqqE/eglibc-2.19/csu/libc-start.c:321:0
>   28  #14 0x0047fff5 _start 
> (/scratch/build_jenkins/workspace/Downstream_Changes/llvm_cgt/arm-llvm/RelWithAsserts/llvm/tools/clang/unittests/Interpreter/./ClangReplInterpreterTests+0x47fff5)

I'm aware it's not fixed yet. I have another fix on my local machine that I'm 
building right now -- I'll commit it once I confirmed it builds on my machine.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130786/new/

https://reviews.llvm.org/D130786

___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D130786: [clang-repl] Disable execution unittests on unsupported platforms.

2022-07-29 Thread Sunho Kim via Phabricator via cfe-commits
sunho added a comment.

In D130786#3688019 , @probinson wrote:

> If you're going to post a patch for review, you really should wait for 
> someone to review it before you land it.

I rushed as bots were breaking on the upstream. Sorry about that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130786/new/

https://reviews.llvm.org/D130786

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


[PATCH] D129242: [clang-repl] Add host exception support check utility flag.

2022-07-29 Thread Sunho Kim via Phabricator via cfe-commits
sunho added a comment.

https://reviews.llvm.org/D130788 this is the patch fyi.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129242/new/

https://reviews.llvm.org/D129242

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


[PATCH] D129242: [clang-repl] Add host exception support check utility flag.

2022-07-29 Thread Sunho Kim via Phabricator via cfe-commits
sunho added a comment.

@uabelho The thing is we have to statically link libstdc++ in JIT stack, but 
this is not possible at the moment in many platforms. It's actually possible 
with a new generation linker called JITLink, but it has limited platform 
support. For now, I just sumbitted a patch disabling clang-repl build when 
LLVM_STATIC_LINK_CXX_STDLIB is turned on. This should resolve the build failure 
on your side. If you want to use clang-repl on your environment, it's actually 
possible to statically link libstdc++ on JIT side as JITLink is available on 
x86 linux. Please let me if you want me to dig into it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129242/new/

https://reviews.llvm.org/D129242

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


[PATCH] D130786: [clang-repl] Disable execution unittests on unsupported platforms.

2022-07-29 Thread Sunho Kim via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4191d661c746: [clang-repl] Disable execution unittests on 
unsupported platforms. (authored by sunho).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130786/new/

https://reviews.llvm.org/D130786

Files:
  clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
  clang/unittests/Interpreter/InterpreterTest.cpp


Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -28,6 +28,12 @@
 
 using namespace clang;
 
+#if defined(_AIX) || defined(__hexagon__) ||   
\
+(defined(_WIN32) &&
\
+ (defined(__aarch64__) || defined(_M_ARM64) || defined(__arm__)))
+#define CLANG_INTERPRETER_NO_SUPPORT_EXEC
+#endif
+
 namespace {
 using Args = std::vector;
 static std::unique_ptr
@@ -191,7 +197,7 @@
   ~LLVMInitRAII() { llvm::llvm_shutdown(); }
 } LLVMInit;
 
-#ifdef _AIX
+#ifdef CLANG_INTERPRETER_NO_SUPPORT_EXEC
 TEST(IncrementalProcessing, DISABLED_FindMangledNameSymbol) {
 #else
 TEST(IncrementalProcessing, FindMangledNameSymbol) {
@@ -253,7 +259,7 @@
   return R.getFoundDecl();
 }
 
-#ifdef _AIX
+#ifdef CLANG_INTERPRETER_NO_SUPPORT_EXEC
 TEST(IncrementalProcessing, DISABLED_InstantiateTemplate) {
 #else
 TEST(IncrementalProcessing, InstantiateTemplate) {
Index: clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
===
--- clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
+++ clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
@@ -46,6 +46,7 @@
 }
 
 TEST(InterpreterTest, CatchException) {
+  llvm::llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
   llvm::InitializeNativeTarget();
   llvm::InitializeNativeTargetAsmPrinter();
 
@@ -130,8 +131,6 @@
   EXPECT_ANY_THROW(ThrowException());
   std::string CapturedStdOut = testing::internal::GetCapturedStdout();
   EXPECT_EQ(CapturedStdOut, "Caught: 'To be caught in JIT'\n");
-
-  llvm::llvm_shutdown();
 }
 
 } // end anonymous namespace


Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -28,6 +28,12 @@
 
 using namespace clang;
 
+#if defined(_AIX) || defined(__hexagon__) ||   \
+(defined(_WIN32) &&\
+ (defined(__aarch64__) || defined(_M_ARM64) || defined(__arm__)))
+#define CLANG_INTERPRETER_NO_SUPPORT_EXEC
+#endif
+
 namespace {
 using Args = std::vector;
 static std::unique_ptr
@@ -191,7 +197,7 @@
   ~LLVMInitRAII() { llvm::llvm_shutdown(); }
 } LLVMInit;
 
-#ifdef _AIX
+#ifdef CLANG_INTERPRETER_NO_SUPPORT_EXEC
 TEST(IncrementalProcessing, DISABLED_FindMangledNameSymbol) {
 #else
 TEST(IncrementalProcessing, FindMangledNameSymbol) {
@@ -253,7 +259,7 @@
   return R.getFoundDecl();
 }
 
-#ifdef _AIX
+#ifdef CLANG_INTERPRETER_NO_SUPPORT_EXEC
 TEST(IncrementalProcessing, DISABLED_InstantiateTemplate) {
 #else
 TEST(IncrementalProcessing, InstantiateTemplate) {
Index: clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
===
--- clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
+++ clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
@@ -46,6 +46,7 @@
 }
 
 TEST(InterpreterTest, CatchException) {
+  llvm::llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
   llvm::InitializeNativeTarget();
   llvm::InitializeNativeTargetAsmPrinter();
 
@@ -130,8 +131,6 @@
   EXPECT_ANY_THROW(ThrowException());
   std::string CapturedStdOut = testing::internal::GetCapturedStdout();
   EXPECT_EQ(CapturedStdOut, "Caught: 'To be caught in JIT'\n");
-
-  llvm::llvm_shutdown();
 }
 
 } // end anonymous namespace
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129242: [clang-repl] Add host exception support check utility flag.

2022-07-29 Thread Sunho Kim via Phabricator via cfe-commits
sunho added a comment.

In D129242#3686713 , @uabelho wrote:

> In D129242#3686610 , @sunho wrote:
>
>> @uabelho Hi, that's a typeinfo symbol of libc++ abi. It's quite weird that 
>> __cxa_throw is availble while _ZTIPKc is not. Do you have some special 
>> setting regarding libc++ in your environment?
>
> We compile with clang 8 on a RHEL7 machine, but since we then got too old 
> libs we do
>
>   
> --gcc-toolchain=/proj/bbi_twh/wh_bbi/x86_64-Linux2/bbigcc/1.9.3.0/crosscompiler
>
> since we have newer libs there. This is seen in the cmake command:
>
>   cmake command: CC='/proj/flexasic/app/llvm/8.0/bin/clang -march=corei7 
> --gcc-toolchain=/proj/bbi_twh/wh_bbi/x86_64-Linux2/bbigcc/1.9.3.0/crosscompiler'
>  CXX='/proj/flexasic/app/llvm/8.0/bin/clang++ -march=corei7 
> --gcc-toolchain=/proj/bbi_twh/wh_bbi/x86_64-Linux2/bbigcc/1.9.3.0/crosscompiler'
>  LDFLAGS='-Wl,-R/proj/bbi_twh/wh_bbi/x86_64-Linux3/z3/4.8.8-1/lib64' 
> PATH=/proj/flexasic/app/ninja/1.8.2/SLED11-64/bin:$PATH  
> /app/vbuild/RHEL7-x86_64/cmake/3.16.4/bin/cmake 
> /repo/uabelho/main-github/llvm --debug-trycompile -G Ninja 
> -DCMAKE_MAKE_PROGRAM=/proj/flexasic/app/ninja/1.8.2/SLED11-64/bin/ninja 
> -DCMAKE_BUILD_TYPE=Release 
> -DCMAKE_C_FLAGS='-Wno-error=unused-command-line-argument' 
> -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_INSTALL_PREFIX=/compiler-clang 
> -DLLVM_APPEND_VC_REV=OFF -DLLVM_CCACHE_DIR=/repo/uabelho/.ccache/ 
> -DLLVM_CCACHE_BUILD=ON 
> -DLLVM_CCACHE_PROGRAM=/app/vbuild/RHEL7-x86_64/ccache/3.2.2/bin/ccache 
> -DLLVM_CCACHE_NOHASHDIR=ON -DLLVM_CCACHE_BASEDIR=/repo 
> -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_WERROR=ON 
> -DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra;lld' 
> -DLLVM_ENABLE_Z3_SOLVER=ON 
> -DLLVM_Z3_INSTALL_DIR=/proj/bbi_twh/wh_bbi/x86_64-Linux3/z3/4.8.8-1 
> -DLLVM_ENABLE_LIBPFM=OFF -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_ENABLE_TERMINFO=OFF 
> -DLLVM_ENABLE_LIBEDIT=OFF -DLLVM_STATIC_LINK_CXX_STDLIB=ON 
> -DCLANG_ENABLE_ARCMT=OFF -DCLANG_TOOLING_BUILD_AST_INTROSPECTION=OFF
>
> Could it be something like that there is a mismatch somewhere so the support 
> checks will use some libs but then the actual libs used when 
> compiling/running is something else?

Thanks for the detailed information. I'm thining it's because of 
LLVM_STATIC_LINK_CXX_STDLIB=ON. The default method used by ORC for finding 
external symbol on linux is look up the symbols defined by the current process 
and dynamic libraries loaded so far using dlsym. Since libstdc++ was statically 
linked, some of the libstdc++ symbols might not be visible in symbol table. 
It's still weird that it has successfully found `__cxa_throw` though. (the log 
you showed says it has found `__cxa_throw`)

I'll try to reproduce the issue by tweaking LLVM_STATIC_LINK_CXX_STDLIB on my 
local machine and report back.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129242/new/

https://reviews.llvm.org/D129242

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


[PATCH] D129242: [clang-repl] Add host exception support check utility flag.

2022-07-29 Thread Sunho Kim via Phabricator via cfe-commits
sunho added a comment.

@uabelho Hi, that's a typeinfo symbol of libc++ abi. It's quite weird that 
__cxa_throw is availble while _ZTIPKc is not. Do you have some special setting 
regarding libc++ in your environment?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129242/new/

https://reviews.llvm.org/D129242

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


[PATCH] D129242: [clang-repl] Add host exception support check utility flag.

2022-07-28 Thread Sunho Kim via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3cc3be8fa471: [clang-repl] Add host exception support check 
utility flag. (authored by sunho).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129242/new/

https://reviews.llvm.org/D129242

Files:
  clang/test/Interpreter/simple-exception.cpp
  clang/test/lit.cfg.py
  clang/tools/clang-repl/ClangRepl.cpp

Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -28,6 +28,8 @@
   llvm::cl::CommaSeparated);
 static llvm::cl::opt OptHostSupportsJit("host-supports-jit",
   llvm::cl::Hidden);
+static llvm::cl::opt OptHostSupportsException("host-supports-exception",
+llvm::cl::Hidden);
 static llvm::cl::list OptInputs(llvm::cl::Positional,
  llvm::cl::desc("[code to run]"));
 
@@ -65,6 +67,42 @@
   return Errs ? EXIT_FAILURE : EXIT_SUCCESS;
 }
 
+// Check if the host environment supports c++ exception handling
+// by querying the existence of symbol __cxa_throw.
+static bool checkExceptionSupport() {
+  auto J = llvm::orc::LLJITBuilder().create();
+  if (!J) {
+llvm::consumeError(J.takeError());
+return false;
+  }
+
+  std::vector Dummy;
+  auto CI = clang::IncrementalCompilerBuilder::create(Dummy);
+  if (!CI) {
+llvm::consumeError(CI.takeError());
+return false;
+  }
+
+  auto Interp = clang::Interpreter::create(std::move(*CI));
+  if (!Interp) {
+llvm::consumeError(Interp.takeError());
+return false;
+  }
+
+  if (auto Err = (*Interp)->ParseAndExecute("")) {
+llvm::consumeError(std::move(Err));
+return false;
+  }
+
+  auto Sym = (*Interp)->getSymbolAddress("__cxa_throw");
+  if (!Sym) {
+llvm::consumeError(Sym.takeError());
+return false;
+  }
+
+  return true;
+}
+
 llvm::ExitOnError ExitOnErr;
 int main(int argc, const char **argv) {
   ExitOnErr.setBanner("clang-repl: ");
@@ -87,6 +125,14 @@
 return 0;
   }
 
+  if (OptHostSupportsException) {
+if (checkExceptionSupport())
+  llvm::outs() << "true\n";
+else
+  llvm::outs() << "false\n";
+return 0;
+  }
+
   // FIXME: Investigate if we could use runToolOnCodeWithArgs from tooling. It
   // can replace the boilerplate code for creation of the compiler instance.
   auto CI = ExitOnErr(clang::IncrementalCompilerBuilder::create(ClangArgv));
Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -70,7 +70,7 @@
 if config.clang_examples:
 config.available_features.add('examples')
 
-def have_host_jit_support():
+def have_host_jit_feature_support(feature_name):
 clang_repl_exe = lit.util.which('clang-repl', config.clang_tools_dir)
 
 if not clang_repl_exe:
@@ -79,7 +79,7 @@
 
 try:
 clang_repl_cmd = subprocess.Popen(
-[clang_repl_exe, '--host-supports-jit'], stdout=subprocess.PIPE)
+[clang_repl_exe, '--host-supports-' + feature_name], stdout=subprocess.PIPE)
 except OSError:
 print('could not exec clang-repl')
 return False
@@ -89,9 +89,12 @@
 
 return 'true' in clang_repl_out
 
-if have_host_jit_support():
+if have_host_jit_feature_support('jit'):
 config.available_features.add('host-supports-jit')
 
+if have_host_jit_feature_support('exception'):
+config.available_features.add('host-supports-exception')
+
 if config.clang_staticanalyzer:
 config.available_features.add('staticanalyzer')
 tools.append('clang-check')
Index: clang/test/Interpreter/simple-exception.cpp
===
--- /dev/null
+++ clang/test/Interpreter/simple-exception.cpp
@@ -0,0 +1,14 @@
+// clang-format off
+// REQUIRES: host-supports-jit, host-supports-exception 
+// UNSUPPORTED: system-aix
+// XFAIL: arm, arm64-apple, windows-msvc, windows-gnu
+// RUN: cat %s | clang-repl | FileCheck %s
+extern "C" int printf(const char *, ...);
+
+int f() { throw "Simple exception"; return 0; }
+int checkException() { try { printf("Running f()\n"); f(); } catch (const char *e) { printf("%s\n", e); } return 0; }
+auto r1 = checkException();
+// CHECK: Running f()
+// CHECK-NEXT: Simple exception
+
+%quit
\ No newline at end of file
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129175: [ORC] Fix weak hidden symbols failure on PPC with runtimedyld

2022-07-28 Thread Sunho Kim via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG72ea1a721e00: [ORC] Fix weak hidden symbols failure on PPC 
with runtimedyld (authored by sunho).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129175/new/

https://reviews.llvm.org/D129175

Files:
  clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
  llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
  llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp


Index: llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
===
--- llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
+++ llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
@@ -108,6 +108,7 @@
   // filter these later.
   auto InternalSymbols = std::make_shared>();
   {
+SymbolFlagsMap ExtraSymbolsToClaim;
 for (auto  : (*Obj)->symbols()) {
 
   // Skip file symbols.
@@ -128,6 +129,33 @@
 return;
   }
 
+  // Try to claim responsibility of weak symbols
+  // if AutoClaimObjectSymbols flag is set.
+  if (AutoClaimObjectSymbols &&
+  (*SymFlagsOrErr & object::BasicSymbolRef::SF_Weak)) {
+auto SymName = Sym.getName();
+if (!SymName) {
+  ES.reportError(SymName.takeError());
+  R->failMaterialization();
+  return;
+}
+
+// Already included in responsibility set, skip it
+SymbolStringPtr SymbolName = ES.intern(*SymName);
+if (R->getSymbols().count(SymbolName))
+  continue;
+
+auto SymFlags = JITSymbolFlags::fromObjectSymbol(Sym);
+if (!SymFlags) {
+  ES.reportError(SymFlags.takeError());
+  R->failMaterialization();
+  return;
+}
+
+ExtraSymbolsToClaim[SymbolName] = *SymFlags;
+continue;
+  }
+
   // Don't include symbols that aren't global.
   if (!(*SymFlagsOrErr & object::BasicSymbolRef::SF_Global)) {
 if (auto SymName = Sym.getName())
@@ -139,6 +167,13 @@
 }
   }
 }
+
+if (!ExtraSymbolsToClaim.empty()) {
+  if (auto Err = R->defineMaterializing(ExtraSymbolsToClaim)) {
+ES.reportError(std::move(Err));
+R->failMaterialization();
+  }
+}
   }
 
   auto MemMgr = GetMemoryManager();
Index: llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
===
--- llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
+++ llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
@@ -746,6 +746,11 @@
 Layer->setAutoClaimResponsibilityForObjectSymbols(true);
   }
 
+  if (S.JTMB->getTargetTriple().isOSBinFormatELF() &&
+  (S.JTMB->getTargetTriple().getArch() == Triple::ArchType::ppc64 ||
+   S.JTMB->getTargetTriple().getArch() == Triple::ArchType::ppc64le))
+Layer->setAutoClaimResponsibilityForObjectSymbols(true);
+
   // FIXME: Explicit conversion to std::unique_ptr added to 
silence
   //errors from some GCC / libstdc++ bots. Remove this conversion (i.e.
   //just return ObjLinkingLayer) once those bots are upgraded.
Index: clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
===
--- clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
+++ clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
@@ -98,11 +98,6 @@
   // FIXME: Re-enable the excluded target triples.
   const clang::CompilerInstance *CI = Interp->getCompilerInstance();
   const llvm::Triple  = CI->getASTContext().getTargetInfo().getTriple();
-  // FIXME: PPC fails due to `Symbols not found: [DW.ref.__gxx_personality_v0]`
-  // The current understanding is that the JIT should emit this symbol if it 
was
-  // not (eg. the way passing clang -fPIC does it).
-  if (Triple.isPPC())
-return;
 
   // FIXME: ARM fails due to `Not implemented relocation type!`
   if (Triple.isARM())


Index: llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
===
--- llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
+++ llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
@@ -108,6 +108,7 @@
   // filter these later.
   auto InternalSymbols = std::make_shared>();
   {
+SymbolFlagsMap ExtraSymbolsToClaim;
 for (auto  : (*Obj)->symbols()) {
 
   // Skip file symbols.
@@ -128,6 +129,33 @@
 return;
   }
 
+  // Try to claim responsibility of weak symbols
+  // if AutoClaimObjectSymbols flag is set.
+  if (AutoClaimObjectSymbols &&
+  (*SymFlagsOrErr & object::BasicSymbolRef::SF_Weak)) {
+auto SymName = Sym.getName();
+if (!SymName) {
+  ES.reportError(SymName.takeError());
+  R->failMaterialization();
+

[PATCH] D129049: [clang] Fix gcc-6 compilation error. (NFC)

2022-07-03 Thread Sunho Kim via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG134363208b92: [clang] Fix gcc-6 compilation error. (NFC) 
(authored by sunho).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129049/new/

https://reviews.llvm.org/D129049

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp


Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -496,7 +496,7 @@
 
 template 
 const RecordType *ByteCodeExprGen::getRecordTy(QualType Ty) {
-  if (auto *PT = dyn_cast(Ty))
+  if (const PointerType *PT = dyn_cast(Ty))
 return PT->getPointeeType()->getAs();
   else
 return Ty->getAs();


Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -496,7 +496,7 @@
 
 template 
 const RecordType *ByteCodeExprGen::getRecordTy(QualType Ty) {
-  if (auto *PT = dyn_cast(Ty))
+  if (const PointerType *PT = dyn_cast(Ty))
 return PT->getPointeeType()->getAs();
   else
 return Ty->getAs();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128589: [clang-repl] Support destructors of global objects.

2022-06-30 Thread Sunho Kim via Phabricator via cfe-commits
sunho added inline comments.



Comment at: clang/test/Interpreter/execute.cpp:22-23
 
+struct D { float f = 1.0; D *m = nullptr; D(){} ~D() { printf("D[f=%f, 
m=0x%llx]\n", f, reinterpret_cast(m)); }} d;
+// CHECK: D[f=1.00, m=0x0]
+

Hahnfeld wrote:
> I think it would be better to add new test cases instead of extending this 
> ever-growing file. And it might also be a good idea to split off some of the 
> previous additions into separate test cases that exercise specific parts of 
> the interpreter infrastructure (D126781 and D123674).
Got it. I will address your comment when relanding the patch after fixing ppc 
failure.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128589/new/

https://reviews.llvm.org/D128589

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


[PATCH] D128589: [clang-repl] Support destructors of global objects.

2022-06-26 Thread Sunho Kim via Phabricator via cfe-commits
sunho added a comment.

This seems to be breaking builds in ppc bots. Invastigating right now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128589/new/

https://reviews.llvm.org/D128589

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


[PATCH] D128589: [clang-repl] Support destructors of global objects.

2022-06-26 Thread Sunho Kim via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9de8b05bfe0d: [clang-repl] Support destructors of global 
objects. (authored by sunho).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128589/new/

https://reviews.llvm.org/D128589

Files:
  clang/lib/Interpreter/IncrementalExecutor.cpp
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/test/Interpreter/execute.cpp
  clang/tools/clang-repl/ClangRepl.cpp
  clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp

Index: clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
===
--- clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
+++ clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
@@ -48,6 +48,7 @@
 TEST(InterpreterTest, CatchException) {
   llvm::InitializeNativeTarget();
   llvm::InitializeNativeTargetAsmPrinter();
+  llvm::llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
 
   {
 auto J = llvm::orc::LLJITBuilder().create();
@@ -131,8 +132,6 @@
   EXPECT_ANY_THROW(ThrowException());
   std::string CapturedStdOut = testing::internal::GetCapturedStdout();
   EXPECT_EQ(CapturedStdOut, "Caught: 'To be caught in JIT'\n");
-
-  llvm::llvm_shutdown();
 }
 
 } // end anonymous namespace
Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -70,6 +70,8 @@
   ExitOnErr.setBanner("clang-repl: ");
   llvm::cl::ParseCommandLineOptions(argc, argv);
 
+  llvm::llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
+
   std::vector ClangArgv(ClangArgs.size());
   std::transform(ClangArgs.begin(), ClangArgs.end(), ClangArgv.begin(),
  [](const std::string ) -> const char * { return s.data(); });
@@ -121,7 +123,5 @@
   // later errors use the default handling behavior instead.
   llvm::remove_fatal_error_handler();
 
-  llvm::llvm_shutdown();
-
   return checkDiagErrors(Interp->getCompilerInstance());
 }
Index: clang/test/Interpreter/execute.cpp
===
--- clang/test/Interpreter/execute.cpp
+++ clang/test/Interpreter/execute.cpp
@@ -1,3 +1,4 @@
+// clang-format off
 // RUN: clang-repl "int x = 10;" "int y=7; err;" "int y = 10;"
 // RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
 // RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck --check-prefix=CHECK-DRIVER %s
@@ -18,4 +19,7 @@
 inline int foo() { return 42; }
 int r3 = foo();
 
+struct D { float f = 1.0; D *m = nullptr; D(){} ~D() { printf("D[f=%f, m=0x%llx]\n", f, reinterpret_cast(m)); }} d;
+// CHECK: D[f=1.00, m=0x0]
+
 quit
Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -183,7 +183,14 @@
*TSCtx->getContext(), Err);
 }
 
-Interpreter::~Interpreter() {}
+Interpreter::~Interpreter() {
+  if (IncrExecutor) {
+if (llvm::Error Err = IncrExecutor->cleanUp())
+  llvm::report_fatal_error(
+  llvm::Twine("Failed to clean up IncrementalExecutor: ") +
+  toString(std::move(Err)));
+  }
+}
 
 llvm::Expected>
 Interpreter::create(std::unique_ptr CI) {
Index: clang/lib/Interpreter/IncrementalExecutor.h
===
--- clang/lib/Interpreter/IncrementalExecutor.h
+++ clang/lib/Interpreter/IncrementalExecutor.h
@@ -43,6 +43,7 @@
 
   llvm::Error addModule(std::unique_ptr M);
   llvm::Error runCtors() const;
+  llvm::Error cleanUp();
   llvm::Expected
   getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const;
   llvm::orc::LLJIT *getExecutionEngine() const { return Jit.get(); }
Index: clang/lib/Interpreter/IncrementalExecutor.cpp
===
--- clang/lib/Interpreter/IncrementalExecutor.cpp
+++ clang/lib/Interpreter/IncrementalExecutor.cpp
@@ -52,6 +52,12 @@
 
 IncrementalExecutor::~IncrementalExecutor() {}
 
+// Clean up the JIT instance.
+llvm::Error IncrementalExecutor::cleanUp() {
+  // This calls the global dtors of registered modules.
+  return Jit->deinitialize(Jit->getMainJITDylib());
+}
+
 llvm::Error IncrementalExecutor::addModule(std::unique_ptr M) {
   return Jit->addIRModule(llvm::orc::ThreadSafeModule(std::move(M), TSCtx));
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128589: [clang-repl] Support destructors of global objects.

2022-06-26 Thread Sunho Kim via Phabricator via cfe-commits
sunho updated this revision to Diff 440047.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128589/new/

https://reviews.llvm.org/D128589

Files:
  clang/lib/Interpreter/IncrementalExecutor.cpp
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/test/Interpreter/execute.cpp
  clang/tools/clang-repl/ClangRepl.cpp
  clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp

Index: clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
===
--- clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
+++ clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
@@ -48,6 +48,7 @@
 TEST(InterpreterTest, CatchException) {
   llvm::InitializeNativeTarget();
   llvm::InitializeNativeTargetAsmPrinter();
+  llvm::llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
 
   {
 auto J = llvm::orc::LLJITBuilder().create();
@@ -131,8 +132,6 @@
   EXPECT_ANY_THROW(ThrowException());
   std::string CapturedStdOut = testing::internal::GetCapturedStdout();
   EXPECT_EQ(CapturedStdOut, "Caught: 'To be caught in JIT'\n");
-
-  llvm::llvm_shutdown();
 }
 
 } // end anonymous namespace
Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -70,6 +70,8 @@
   ExitOnErr.setBanner("clang-repl: ");
   llvm::cl::ParseCommandLineOptions(argc, argv);
 
+  llvm::llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
+
   std::vector ClangArgv(ClangArgs.size());
   std::transform(ClangArgs.begin(), ClangArgs.end(), ClangArgv.begin(),
  [](const std::string ) -> const char * { return s.data(); });
@@ -121,7 +123,5 @@
   // later errors use the default handling behavior instead.
   llvm::remove_fatal_error_handler();
 
-  llvm::llvm_shutdown();
-
   return checkDiagErrors(Interp->getCompilerInstance());
 }
Index: clang/test/Interpreter/execute.cpp
===
--- clang/test/Interpreter/execute.cpp
+++ clang/test/Interpreter/execute.cpp
@@ -1,3 +1,4 @@
+// clang-format off
 // RUN: clang-repl "int x = 10;" "int y=7; err;" "int y = 10;"
 // RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
 // RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck --check-prefix=CHECK-DRIVER %s
@@ -18,4 +19,7 @@
 inline int foo() { return 42; }
 int r3 = foo();
 
+struct D { float f = 1.0; D *m = nullptr; D(){} ~D() { printf("D[f=%f, m=0x%llx]\n", f, reinterpret_cast(m)); }} d;
+// CHECK: D[f=1.00, m=0x0]
+
 quit
Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -183,7 +183,14 @@
*TSCtx->getContext(), Err);
 }
 
-Interpreter::~Interpreter() {}
+Interpreter::~Interpreter() {
+  if (IncrExecutor) {
+if (llvm::Error Err = IncrExecutor->cleanUp())
+  llvm::report_fatal_error(
+  llvm::Twine("Failed to clean up IncrementalExecutor: ") +
+  toString(std::move(Err)));
+  }
+}
 
 llvm::Expected>
 Interpreter::create(std::unique_ptr CI) {
Index: clang/lib/Interpreter/IncrementalExecutor.h
===
--- clang/lib/Interpreter/IncrementalExecutor.h
+++ clang/lib/Interpreter/IncrementalExecutor.h
@@ -43,6 +43,7 @@
 
   llvm::Error addModule(std::unique_ptr M);
   llvm::Error runCtors() const;
+  llvm::Error cleanUp();
   llvm::Expected
   getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const;
   llvm::orc::LLJIT *getExecutionEngine() const { return Jit.get(); }
Index: clang/lib/Interpreter/IncrementalExecutor.cpp
===
--- clang/lib/Interpreter/IncrementalExecutor.cpp
+++ clang/lib/Interpreter/IncrementalExecutor.cpp
@@ -52,6 +52,12 @@
 
 IncrementalExecutor::~IncrementalExecutor() {}
 
+// Clean up the JIT instance.
+llvm::Error IncrementalExecutor::cleanUp() {
+  // This calls the global dtors of registered modules.
+  return Jit->deinitialize(Jit->getMainJITDylib());
+}
+
 llvm::Error IncrementalExecutor::addModule(std::unique_ptr M) {
   return Jit->addIRModule(llvm::orc::ThreadSafeModule(std::move(M), TSCtx));
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127207: [flang][driver] Fix support for `-x`

2022-06-17 Thread Sunho Kim via Phabricator via cfe-commits
sunho added a comment.

Hi! I'm not exactly sure what's going on. But, seems like build is failing 
here? https://lab.llvm.org/buildbot/#/builders/177/builds/5571


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127207/new/

https://reviews.llvm.org/D127207

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


[PATCH] D127991: [clang-repl] Remove memory leak of ASTContext/TargetMachine.

2022-06-17 Thread Sunho Kim via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7bc00ce5cd41: [clang-repl] Remove memory leak of 
ASTContext/TargetMachine. (authored by sunho).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127991/new/

https://reviews.llvm.org/D127991

Files:
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/Interpreter.cpp


Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -116,6 +116,9 @@
   // times, reusing the same AST.
   Clang->getCodeGenOpts().ClearASTBeforeBackend = false;
 
+  Clang->getFrontendOpts().DisableFree = false;
+  Clang->getCodeGenOpts().DisableFree = false;
+
   return std::move(Clang);
 }
 
Index: clang/lib/Interpreter/IncrementalParser.cpp
===
--- clang/lib/Interpreter/IncrementalParser.cpp
+++ clang/lib/Interpreter/IncrementalParser.cpp
@@ -134,7 +134,10 @@
   P->Initialize();
 }
 
-IncrementalParser::~IncrementalParser() { Act->FinalizeAction(); }
+IncrementalParser::~IncrementalParser() {
+  P.reset();
+  Act->FinalizeAction();
+}
 
 llvm::Expected
 IncrementalParser::ParseOrWrapTopLevelDecl() {


Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -116,6 +116,9 @@
   // times, reusing the same AST.
   Clang->getCodeGenOpts().ClearASTBeforeBackend = false;
 
+  Clang->getFrontendOpts().DisableFree = false;
+  Clang->getCodeGenOpts().DisableFree = false;
+
   return std::move(Clang);
 }
 
Index: clang/lib/Interpreter/IncrementalParser.cpp
===
--- clang/lib/Interpreter/IncrementalParser.cpp
+++ clang/lib/Interpreter/IncrementalParser.cpp
@@ -134,7 +134,10 @@
   P->Initialize();
 }
 
-IncrementalParser::~IncrementalParser() { Act->FinalizeAction(); }
+IncrementalParser::~IncrementalParser() {
+  P.reset();
+  Act->FinalizeAction();
+}
 
 llvm::Expected
 IncrementalParser::ParseOrWrapTopLevelDecl() {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits