<div>The .profraw file needs to be transformed into a .profdata file before use. See step 3 here:</div><div><br></div>    <a href="http://clang.llvm.org/docs/UsersManual.html#profiling-with-instrumentation">http://clang.llvm.org/docs/UsersManual.html#profiling-with-instrumentation</a><br>
<br>On Thursday, July 10, 2014, p2282 <<a href="mailto:ganesh.faq@gmail.com">ganesh.faq@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all,<br>
<br>
Flag "-fprofile-instr-use" generates error given below.<br>
This issue occurs even if we build llvm,clang and compiler-rt using cmake or<br>
configure.<br>
Please let me know your inputs to resolve this issue<br>
<br>
Error:error: Could not read profile: Invalid file format (bad magic)<br>
<br>
Thanks,<br>
<br>
*Steps to reproduce this issue:*<br>
$ clang -O2 -fprofile-instr-generate hello.c -o c1.out<br>
<br>
$ ls -rlt<br>
-rw-r--r-- 1 root root       70 Jul 11 10:10 hello.c<br>
-rwxr-xr-x 1 root root    15793 Jul 11 10:10 c1.out<br>
-rw-r--r-- 1 root root 12203204 Jul 11 10:10 *gmon.out*<br>
<br>
$ ./c1.out<br>
Hello world<br>
<br>
$ ls -rlt<br>
-rw-r--r-- 1 root root       70 Jul 11 10:10 hello.c<br>
-rwxr-xr-x 1 root root    15793 Jul 11 10:10 c1.out<br>
-rw-r--r-- 1 root root 12203204 Jul 11 10:10 *gmon.out*<br>
-rw-r--r-- 1 root root      104 Jul 11 10:10 *default.profraw*<br>
<br>
$ clang -O2 -fprofile-instr-use=default.profraw hello.c -o c2.out<br>
error: Could not read profile: Invalid file format (bad magic)<br>
1 error generated.<br>
<br>
*Clang version (July 10th-2014 build from stage): *<br>
$ clang -v<br>
clang -v<br>
clang version 3.5.0 (<a href="http://llvm.org/git/clang.git" target="_blank">llvm.org/git/clang.git</a><br>
5f9d646cba20f309bb69c6c358996d71912c54cd) (<a href="http://llvm.org/git/llvm.git
dc90a3ab8ffc841a442888940635306de6131d2f" target="_blank">llvm.org/git/llvm.git<br>
dc90a3ab8ffc841a442888940635306de6131d2f</a>)<br>
Target: x86_64-unknown-linux-gnu<br>
Thread model: posix<br>
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8<br>
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.2<br>
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9<br>
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.0<br>
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8<br>
Candidate multilib: .;@m64<br>
Candidate multilib: 32;@m32<br>
Selected multilib: .;@m64<br>
<br>
*OS:*  Ubuntu 14.04<br>
<br>
*LLVM configure:* ../llvm/configure --enable-profiling --enable-optimized<br>
--enable-shared --disable-debug-runtime --enable-targets=x86<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://clang-developers.42468.n3.nabble.com/Error-Invalid-file-format-bad-magic-with-fprofile-instr-use-tp4040477.html" target="_blank">http://clang-developers.42468.n3.nabble.com/Error-Invalid-file-format-bad-magic-with-fprofile-instr-use-tp4040477.html</a><br>

Sent from the Clang Developers mailing list archive at Nabble.com.<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="javascript:;" onclick="_e(event, 'cvml', 'cfe-dev@cs.uiuc.edu')">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</blockquote>