<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 --- - assertion in __builtin_return_address with level > 0 on MIPS"
   href="http://llvm.org/bugs/show_bug.cgi?id=19970">19970</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>assertion in __builtin_return_address with level > 0 on MIPS
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </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>Backend: MIPS
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>msebor@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>3.4 as well as a recent top of trunk abend on the following test case,
indicating that __builtin_return_address is not implemented on MIPS (N32, N64,
and O32) for arguments greater than 0.

While searching for an existing bug report, we came across the following:
<a href="https://dmz-portal.mips.com/bugz/show_bug.cgi?id=1137">https://dmz-portal.mips.com/bugz/show_bug.cgi?id=1137</a>

$ echo "void* a (void) { return __builtin_return_address(1); }" |
llvm-head-gcc-4.8.2-x86_64-linux/Debug+Asserts/bin/clang -S
--target=mips64-montavista-linux-gnu -xc -
clang:
/scratch/msebor/llvm/llvm-head/lib/Target/Mips/MipsISelLowering.cpp:1799:
llvm::SDValue llvm::MipsTargetLowering::lowerRETURNADDR(llvm::SDValue,
llvm::SelectionDAG&) const: Assertion
`(cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue() == 0) && "Return
address can be determined only for current frame."' failed.
0  clang           0x00000000039e3061 llvm::sys::PrintStackTrace(_IO_FILE*) +
38
1  clang           0x00000000039e32de
2  clang           0x00000000039e2c8d
3  libpthread.so.0 0x0000003cb8a0eb10
4  libc.so.6       0x0000003cb7e30265 gsignal + 53
5  libc.so.6       0x0000003cb7e31d10 abort + 272
6  libc.so.6       0x0000003cb7e296e6 __assert_fail + 246
7  clang           0x0000000002a364ed
llvm::MipsTargetLowering::lowerRETURNADDR(llvm::SDValue, llvm::SelectionDAG&)
const + 193
8  clang           0x0000000002a2ef8e
llvm::MipsTargetLowering::LowerOperation(llvm::SDValue, llvm::SelectionDAG&)
const + 840
9  clang           0x0000000002a59cff
llvm::MipsSETargetLowering::LowerOperation(llvm::SDValue, llvm::SelectionDAG&)
const + 1087
10 clang           0x00000000030c4981
11 clang           0x00000000030bbd6f
12 clang           0x00000000030dcca2 llvm::SelectionDAG::Legalize() + 58
13 clang           0x000000000308dc38
llvm::SelectionDAGISel::CodeGenAndEmitDAG() + 2684
14 clang           0x000000000308ce95
llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::Instruction
const>, llvm::ilist_iterator<llvm::Instruction const>, bool&) + 259
15 clang           0x000000000308fa3e
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 3016
16 clang           0x000000000308c107
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 1065
17 clang           0x0000000002a29b93
llvm::MipsDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 35
18 clang           0x0000000002a53865
llvm::MipsSEDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 65
19 clang           0x00000000032a4d9b
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 95
20 clang           0x000000000395b50e
llvm::FPPassManager::runOnFunction(llvm::Function&) + 290
21 clang           0x000000000395b67e
llvm::FPPassManager::runOnModule(llvm::Module&) + 84
22 clang           0x000000000395b9d2
23 clang           0x000000000395c07c
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 244
24 clang           0x000000000395c29b
llvm::legacy::PassManager::run(llvm::Module&) + 39
25 clang           0x000000000126a0d1
26 clang           0x000000000126a1a3
clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions
const&, clang::TargetOptions const&, clang::LangOptions const&,
llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::raw_ostream*) + 127
27 clang           0x0000000001262abb
28 clang           0x00000000014c5c1f clang::ParseAST(clang::Sema&, bool, bool)
+ 780
29 clang           0x0000000000fc6348 clang::ASTFrontendAction::ExecuteAction()
+ 322
30 clang           0x0000000001264a3c clang::CodeGenAction::ExecuteAction() +
1224
31 clang           0x0000000000fc5e7d clang::FrontendAction::Execute() + 139
32 clang           0x0000000000f93d28
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 720
33 clang           0x0000000000f5bfa4
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1090
34 clang           0x0000000000f4a293 cc1_main(char const**, char const**, char
const*, void*) + 641
35 clang           0x0000000000f56d05 main + 760
36 libc.so.6       0x0000003cb7e1d994 __libc_start_main + 244
37 clang           0x0000000000f489a9
Stack dump:
0.    Program arguments:
/scratch/msebor/llvm/llvm-head-gcc-4.8.2-x86_64-linux/Debug+Asserts/bin/clang
-cc1 -triple mips64-montavista-linux-gnu -S -disable-free -main-file-name -
-mrelocation-model static -mdisable-fp-elim -fmath-errno -no-integrated-as
-mconstructor-aliases -target-cpu mips64r2 -target-abi n64 -mfloat-abi hard
-target-linker-version 2.23.2 -coverage-file /scratch/msebor/tmp/-.s
-resource-dir
/scratch/msebor/llvm/llvm-head-gcc-4.8.2-x86_64-linux/Debug+Asserts/bin/../lib/clang/3.5.0
-internal-isystem /usr/local/include -internal-isystem
/scratch/msebor/llvm/llvm-head-gcc-4.8.2-x86_64-linux/Debug+Asserts/bin/../lib/clang/3.5.0/include
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fno-dwarf-directory-asm -fdebug-compilation-dir /scratch/msebor/tmp
-ferror-limit 19 -fmessage-length 80 -mstackrealign -fobjc-runtime=gcc
-fdiagnostics-show-option -fcolor-diagnostics -o -.s -x c - 
1.    <eof> parser at end of file
2.    Code generation
3.    Running pass 'Function Pass Manager' on module '-'.
4.    Running pass 'MIPS DAG->DAG Pattern Instruction Selection' on function
'@a'
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.5.0 (<a href="http://llvm.org/git/clang.git">http://llvm.org/git/clang.git</a>
c8e71f6da9b5e48b489779569b9a4e72e462f24a) (<a href="http://llvm.org/git/llvm.git">http://llvm.org/git/llvm.git</a>
8962f1959d2bcfcffb6be4cc0f4170121b960595)
Target: mips64-montavista-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: Error generating preprocessed source(s) - ignoring
input from stdin.
clang: note: diagnostic msg: Error generating preprocessed source(s) - no
preprocessable inputs.</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>