This is an archive of the discontinued LLVM Phabricator instance.

[Sanitizers][CFG][arm64e] Fix test because -fsanitize-coverage=control-flow does not sign BB entry
ClosedPublic

Authored by thetruestblue on Dec 8 2022, 12:08 PM.

Details

Summary

-fsanitize-coverage=control-flow does not sign entries into basic blocks on arm64e. This test compares a local pointer to a function [signed] with the basic block pointer. Because the entry into the
basic block is unsigned the addresses being compared are signed and unsigned, causing the path never to be taken.
This is a "bandaid" to get this test passing. We strip the signed bits from the pointer to the local functions so that the comparisons pass.
Filed radar: rdar://103042879 to note the behavior.

context: https://github.com/llvm/llvm-project/blob/main/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp#L1068

// blockaddress can not be used on function's entry block.
if (&BB == &F.getEntryBlock())
  CFs.push_back((Constant *)IRB.CreatePointerCast(&F, IntptrPtrTy));
else
  CFs.push_back((Constant *)IRB.CreatePointerCast(BlockAddress::get(&BB),
                                                  IntptrPtrTy));

BlockAddress::get is responsible for signing the pointer.

Because of:
https://reviews.llvm.org/D133157

rdar://103042879

Diff Detail

Event Timeline

thetruestblue created this revision.Dec 8 2022, 12:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 8 2022, 12:08 PM
thetruestblue requested review of this revision.Dec 8 2022, 12:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 8 2022, 12:08 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
vitalybuka accepted this revision.Dec 8 2022, 1:44 PM
vitalybuka added inline comments.
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_control_flow.cpp
11–13
59–62
This revision is now accepted and ready to land.Dec 8 2022, 1:44 PM