<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 building with "__naked" function attribute"
href="http://llvm.org/bugs/show_bug.cgi?id=21178">21178</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang crashes when building with "__naked" function attribute
</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>viniciustinti@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>Created <span class=""><a href="attachment.cgi?id=13151" name="attach_13151" title="Reduced test case">attachment 13151</a> <a href="attachment.cgi?id=13151&action=edit" title="Reduced test case">[details]</a></span>
Reduced test case
Clang is not able to build the following code:
/*
* clang-3.6 -cc1 -triple armv7-none-linux-gnueabi -S -O0 reduce.c
*/
#define __naked __attribute__((naked))
struct firmware_ops {
int (*prepare_idle)(void);
};
extern const struct firmware_ops *firmware_ops;
static void register_firmware_ops(const struct firmware_ops *ops)
{
firmware_ops = ops;
}
static void __naked tf_generic_smc(unsigned int type)
{
asm volatile(
".arch_extension sec\n\t"
:
: "r" (type)
: "memory");
}
static int tf_prepare_idle(void)
{
tf_generic_smc(0);
return 0;
}
static const struct firmware_ops trusted_foundations_ops = {
.prepare_idle = tf_prepare_idle,
};
void of_register_trusted_foundations(void)
{
register_firmware_ops(&trusted_foundations_ops);
}
/* end */
When compiling it gives the following crash. Using Clang's debug version it
fails at the assertion below
/* crash */
0 clang-3.6 0x0000000000f3db95 llvm::sys::PrintStackTrace(_IO_FILE*) +
37
1 clang-3.6 0x0000000000f3df7b
2 libpthread.so.0 0x00002b267c8f9340
3 clang-3.6 0x0000000001379ee1
clang::CodeGen::CodeGenFunction::GetAddrOfBlockDecl(clang::VarDecl const*,
bool) + 33
4 clang-3.6 0x00000000013b6076
clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(clang::DeclRefExpr const*) +
2534
5 clang-3.6 0x00000000013ae0f9
clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*) + 441
6 clang-3.6 0x00000000013b3a63
clang::CodeGen::CodeGenFunction::EmitCheckedLValue(clang::Expr const*,
clang::CodeGen::CodeGenFunction::TypeCheckKind) + 99
7 clang-3.6 0x00000000013e0142
8 clang-3.6 0x00000000013e18b9
9 clang-3.6 0x00000000013da45c
10 clang-3.6 0x00000000013d257c
clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) + 76
11 clang-3.6 0x00000000012f750f
clang::CodeGen::CodeGenFunction::EmitAsmInput(clang::TargetInfo::ConstraintInfo
const&, clang::Expr const*, std::string&) + 303
12 clang-3.6 0x00000000012f2d1d
clang::CodeGen::CodeGenFunction::EmitAsmStmt(clang::AsmStmt const&) + 7869
13 clang-3.6 0x00000000012eded3
clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) + 451
14 clang-3.6 0x00000000012f5d5b
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot) + 91
15 clang-3.6 0x0000000001302554
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&) + 1332
16 clang-3.6 0x000000000130f2a9
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*) + 1241
17 clang-3.6 0x000000000130c710
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) + 336
18 clang-3.6 0x000000000130802e clang::CodeGen::CodeGenModule::Release()
+ 46
19 clang-3.6 0x00000000012c2293
20 clang-3.6 0x000000000175bc93 clang::ParseAST(clang::Sema&, bool, bool)
+ 467
21 clang-3.6 0x00000000012c13ec clang::CodeGenAction::ExecuteAction() +
76
22 clang-3.6 0x00000000010a5969 clang::FrontendAction::Execute() + 57
23 clang-3.6 0x0000000001079483
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 803
24 clang-3.6 0x00000000011135c5
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 3141
25 clang-3.6 0x000000000067aa7e cc1_main(llvm::ArrayRef<char const*>,
char const*, void*) + 590
26 clang-3.6 0x0000000000679e20 main + 11536
27 libc.so.6 0x00002b267d561ec5 __libc_start_main + 245
28 clang-3.6 0x000000000067700b
/* assertion */
clang-3.6: /src/clang/lib/CodeGen/CGExpr.cpp:1956: clang::CodeGen::LValue
clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(const clang::DeclRefExpr *):
Assertion `isa<BlockDecl>(CurCodeDecl) && E->refersToEnclosingLocal()' failed.</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>