<div dir="ltr"><div>Hi, </div><div><br></div><div>The LangRef warns that "blockaddress(@function, %block)" has a limited and target-dependent applicability:  <a href="https://llvm.org/docs/LangRef.html#addresses-of-basic-blocks">https://llvm.org/docs/LangRef.html#addresses-of-basic-blocks</a></div><div><br></div><div>But I wanted very much to save addresses of blocks in a global variable and so I did: </div><div><br></div><div>% cat cond.c </div><div>void foo(long *a) { if (a) *a = 0; }</div><div><br></div><div><div>% clang -O1  -c  cond.c   -fsanitize-coverage=inline-8bit-counters,pc-table -S -o - -emit-llvm </div></div><div><br></div><div><div>@__sancov_gen_.1 = private constant [3 x i8*] [i8* bitcast (void (i64*)* @foo to i8*), i8* blockaddress(@foo, %entry.if.end_crit_edge), i8* blockaddress(@foo, %if.then)], section "__sancov_pcs", align 8</div></div><div><br></div><div>Is this expected to work? </div><div>If not, is it reasonable to try to make it work? </div><div><br></div><div>This works almost as I want it to, but not quite entirely:</div><div>% cat cout.cpp</div><div><div>#include <iostream></div><div>void Foo() { std::cout << ""; }</div></div><div><br></div><div>% clang++   -fsanitize-coverage=inline-8bit-counters,pc-table cout.cpp -O1</div><div><div>fatal error: error in backend: Undefined temporary symbol</div></div><div><br></div><div>(the error message was added in <a href="http://llvm.org/viewvc/llvm-project?view=revision&revision=253328">http://llvm.org/viewvc/llvm-project?view=revision&revision=253328</a> by Oliver Sstannard, CC-ed)</div><div><br></div><div>The error comes from lib/MC/ELFObjectWriter.cpp </div><div>and it disappears with -O0 or -O2 or -no-integrated-as</div><div><br></div><div>Thanks! </div><div><br></div><div>--kcc </div></div>