<div dir="ltr"><div>clang doesn't seem to respect __attribute__((used)) in C functions. Even if I declare a function like the following:
<span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span> </span>__attribute__((used)) void function(), then also it doesn't declare the function in its IR file if I don't use the function. Is there any other way to force the declaration of "unused" function declarations with clang.</span></div><div><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></div><div>I have hacked in clang 6.0.0 in tools/clang/lib/CodeGen/CodeGenModule.cpp file. I changed in EmitGlobal function to detect if the function has "used" attribute and then if it has then use "GetOrCreateLLVMFunction" this to create the function declaration. However, this hack fails in some other cases. Therefore I am looking for a proper way to do this.</div><div><br></div><div><div><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Regards,<div>Soham Sinha</div><div>PhD Student, Department of Computer Science</div><div>Boston University</div></div></div></div></div></div></div></div></div></div>