<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Clang crashes when running user defined LLVM pass with -xclang flag"
   href="http://llvm.org/bugs/show_bug.cgi?id=20353">20353</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang crashes when running user defined LLVM pass with -xclang flag
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>windxing2007@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This bug appears when using clang to compile a hello world program as below.
#include <stdio.h>
void main()
{
printf("hello world\n");
}

The pass loaded to clang is a simple pass which have the following two lines of
code:
  1----Type * ShortTy = IntegerType::get(M.getContext(), 16);
  2----PointerType * Ptr16Ty = PointerType::getUnqual(ShortTy);
If line 2 is removed, then clang won't crash. I'm not sure whether it crashes
because line 2 has error. If it is an error of line 2, please let me know.

The pass is loaded using the command as  below:
clang -Xclang -load -Xclang
/home/jun/llvm-3.x/build/Debug+Asserts/lib/LLVMInst.so  test.c -o test

The backtrace is as below:
0  clang           0x0000000002e19847 llvm::sys::PrintStackTrace(_IO_FILE*) +
38
1  clang           0x0000000002e19ace
2  clang           0x0000000002e19512
3  libpthread.so.0 0x00007ff04cc13cb0
4  clang           0x0000000002dae406 llvm::PointerType::get(llvm::Type*,
unsigned int) + 118
5  LLVMInst.so     0x00007ff04d03a6c2
6  LLVMInst.so     0x00007ff04d038dca
7  clang           0x0000000002d908c4
llvm::FPPassManager::runOnFunction(llvm::Function&) + 390
8  clang           0x0000000002d90605
llvm::legacy::FunctionPassManagerImpl::run(llvm::Function&) + 89
9  clang           0x0000000002d901cc
llvm::legacy::FunctionPassManager::run(llvm::Function&) + 180
10 clang           0x0000000000f1875b
11 clang           0x0000000000f18917
clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions
const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::Module*,
clang::BackendAction, llvm::raw_ostream*) + 136
12 clang           0x0000000000f1428e
13 clang           0x00000000011240d8 clang::ParseAST(clang::Sema&, bool, bool)
+ 776
14 clang           0x0000000000cbe96f clang::ASTFrontendAction::ExecuteAction()
+ 321
15 clang           0x0000000000f13724 clang::CodeGenAction::ExecuteAction() +
1414
16 clang           0x0000000000cbe4ae clang::FrontendAction::Execute() + 200
17 clang           0x0000000000c8fd44
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 720
18 clang           0x0000000000c5e63a
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1018
19 clang           0x0000000000c4f572 cc1_main(char const**, char const**, char
const*, void*) + 717
20 clang           0x0000000000c59d0a main + 786
21 libc.so.6       0x00007ff04be4f76d __libc_start_main + 237
22 clang           0x0000000000c4ec69
Stack dump:
0.    Program arguments: /usr/local/bin/clang -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
test.c -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version
2.22 -resource-dir /usr/local/bin/../lib/clang/3.5 -internal-isystem
/usr/local/include -internal-isystem /usr/local/bin/../lib/clang/3.5/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fdebug-compilation-dir /home/jun/straight-DTA/test -ferror-limit 19
-fmessage-length 171 -mstackrealign -fobjc-runtime=gcc
-fdiagnostics-show-option -vectorize-slp -load
/home/jun/llvm-3.x/build/Debug+Asserts/lib/LLVMInst.so -o /tmp/test-f83ffb.o -x
c test.c 
1.    <eof> parser at end of file
2.    Per-function optimization
3.    Running pass 'instrument every basic block' on function '@main'
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.5 (trunk 196464) (llvm/trunk 196460)
Target: x86_64-unknown-linux-gnu
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to
<a href="http://llvm.org/bugs/">http://llvm.org/bugs/</a> and include the crash backtrace, preprocessed source, and
associated run script.
clang: note: diagnostic msg:</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>