clangupc / clang-upc

Clang UPC Front-End
https://clangupc.github.io/
Other
16 stars 5 forks source link

ICE on negative semantic test - shared-array-init-unsupported #22

Closed nenadv closed 10 years ago

nenadv commented 10 years ago

After upgrade to 3.4 this test crashes the compiler.

+0.     Program arguments: /eng/upc/dev/nenad/clang-upc/bld/bin/clang-3.4 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -disable-free -disable-llvm-verifier -main-file-name shared-array-init-unsupported.upc -mrelocation-model static -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -momit-leaf-frame-pointer -g -coverage-file /eng/upc/dev/nenad/clang-upc/clang-upc-tests/upc-semantics/shared-array-init-unsupported.o -resource-dir /eng/upc/dev/nenad/clang-upc/bld/bin/../lib/clang/3.4 -internal-isystem /usr/local/include -internal-isystem /eng/upc/dev/nenad/clang-upc/bld/bin/../lib/clang/3.4/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wall -Wextra -Wwrite-strings -Werror -pedantic-errors -fconst-strings -fdebug-compilation-dir /eng/upc/dev/nenad/clang-upc/clang-upc-tests/upc-semantics -ferror-limit 19 -fmessage-length 0 -mstackrealign -fobjc-runtime=gcc -fupc-threads 8 -fdiagnostics-show-option -vectorize-loops -vectorize-slp -o shared-array-init-unsupported.o -x upc shared-array-init-unsupported.upc 
+1.     <eof> parser at end of file
+2.     shared-array-init-unsupported.upc:5:12: LLVM IR generation of declaration 'A'
+3.     shared-array-init-unsupported.upc:5:12: Generating code for declaration 'A'
+clang-3.4: error: unable to execute command: Segmentation fault (core dumped)
+clang-3.4: error: clang frontend command failed due to signal (use -v to see invocation)
+clang version 3.4  (UPC 20140113)
+Target: x86_64-unknown-linux-gnu
+Thread model: posix
+clang-3.4: note: diagnostic msg: PLEASE submit a bug report to  and include the crash backtrace, preprocessed source, and associated run script.
+0  clangupc        0x0000000001c51111 llvm::sys::PrintStackTrace(_IO_FILE*) + 38
+1  clangupc        0x0000000001c51398
+2  clangupc        0x0000000001c50ddc
+3  libpthread.so.0 0x0000003509e0f000
+4  libc.so.6       0x0000003509360551
+5  clangupc        0x0000000000c2e59b
+6  clangupc        0x0000000001e963ce clang::driver::Driver::GetTemporaryPath(llvm::StringRef, char const*) const + 86
+7  clangupc        0x0000000001e94474 clang::driver::Driver::GetNamedOutputPath(clang::driver::Compilation&, clang::driver::JobAction const&, char const*, char const*, bool, bool) const + 1314
+8  clangupc        0x0000000001e93a47 clang::driver::Driver::BuildJobsForAction(clang::driver::Compilation&, clang::driver::Action const*, clang::driver::ToolChain const*, char const*, bool, bool, char const*, clang::driver::InputInfo&) const + 1315
+9  clangupc        0x0000000001e92d06 clang::driver::Driver::BuildJobs(clang::driver::Compilation&) const + 866
+10 clangupc        0x0000000001e8df6d clang::driver::Driver::generateCompilationDiagnostics(clang::driver::Compilation&, clang::driver::Command const*) + 1659
+11 clangupc        0x0000000000c2e36a main + 4142
+12 libc.so.6       0x0000003509221a05 __libc_start_main + 245
+13 clangupc        0x0000000000c2bf49
+Stack dump:
+0.     Program arguments: /eng/upc/dev/nenad/clang-upc/bld/bin/clangupc -O2 -Wall -Wextra -Wwrite-strings -Werror -g -c -pedantic-errors -fupc-threads-8 shared-array-init-unsupported.upc 
+1.     Building compilation jobs
+2.     Building compilation jobs
+3.     Computing output path
make: *** [shared-array-init-unsupported.s-out] Error 1
nenadv commented 10 years ago

It is caused by the following code in lib/CodeGen/CGExprAgg.cpp:

1135     if (Dest.isShared()) {                                                      
1136       // This shouldn't be reachable.  It's just here                           
1137       // to catch any changes.                                                  
1138       llvm_unreachable("Can't initialize a shared array here.");                
1139       return;                                                                   
1140     } 

llvm_unreachable() is an exception and will abort the compilation. Maybe that was not the case in 3.3 (llvm_unreachable just returned a warning) and we were able to simple return without the abort (which is collaborated by the presence of the above string in the expected result for our clang-upc test suite). If I remove the call to llvm_unreachable call everything works.

nenadv commented 10 years ago

I am thinking of changing the code:

diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp
index 988ac6b..2ab6263 100644
--- a/lib/CodeGen/CGExprAgg.cpp
+++ b/lib/CodeGen/CGExprAgg.cpp
@@ -1133,9 +1133,8 @@ void AggExprEmitter::VisitInitListExpr(InitListExpr *E) {
       return Visit(E->getInit(0));

     if (Dest.isShared()) {
-      // This shouldn't be reachable.  It's just here
-      // to catch any changes.
-      llvm_unreachable("Can't initialize a shared array here.");
+      // We do not handle shared array initialization.
+      // Error was already reported.
       return;
     }

With this patch we just report an error. This will require for the test suite to change the expected output as the above llvm_unreachable() string is not available any more.