This is an archive of the discontinued LLVM Phabricator instance.

[Sanitizers] Replaced getMaxPointerSizeInBits with getPointerSizeInBits, which was causing failures for 32bit x86.
ClosedPublic

Authored by kstoimenov on Oct 14 2021, 12:36 PM.

Diff Detail

Event Timeline

kstoimenov created this revision.Oct 14 2021, 12:36 PM
kstoimenov requested review of this revision.Oct 14 2021, 12:36 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 14 2021, 12:36 PM

Can you add a test? maybe clone small piece of 64bit version.

Added a test, which fails without my fix. I named it i386-bug-fix.ll, let me know if you prefer a better name.
The culprit is the 'target datalayout' statement. I didn't dig deeper, but it somehow makes the max pointer size to be 64.

kstoimenov planned changes to this revision.Oct 15 2021, 3:14 PM

Need to actually add the FileCheck statement. Hold off your review.

nikic added a subscriber: nikic.Oct 15 2021, 3:25 PM
nikic added inline comments.
llvm/lib/Analysis/StackSafetyAnalysis.cpp
157

The pointer size depends on the address space, you probably want DL.getPointerTypeSizeInBits(AI.getType()).

vitalybuka added inline comments.Oct 15 2021, 3:54 PM
llvm/lib/Analysis/StackSafetyAnalysis.cpp
157

getPointerSizeInBits() should be fine but we need to checks that address space is default. I am not sure this analysis is true for alternative address spaces and current users also ignore non default ones.

Made the test run using FileCheck and changed one place to use DL.getPointerTypeSizeInBits(AI.getType()).

kstoimenov marked 2 inline comments as done.Oct 15 2021, 3:59 PM
kstoimenov added inline comments.
llvm/lib/Analysis/StackSafetyAnalysis.cpp
157

I can change it back if you think getPointerSizeInBits() is the right approach.

756

I don't think we have access to AllocaInst here, right? I will keep it like this.

llvm/test/Analysis/StackSafetyAnalysis/i386-bug-fix.ll
2

Added the test instructions, PTAL.

vitalybuka added inline comments.Oct 15 2021, 4:06 PM
llvm/lib/Analysis/StackSafetyAnalysis.cpp
825

I guess here, if AddressSpace is not 0, then skip it for now.

vitalybuka added inline comments.Oct 15 2021, 4:12 PM
llvm/lib/Analysis/StackSafetyAnalysis.cpp
157

I'd prefer assert( getAddressSpace() == 0
and just getMaxPointerSizeInBits()

with change at line ~825 to skip them

vitalybuka added inline comments.Oct 15 2021, 4:32 PM
llvm/lib/Analysis/StackSafetyAnalysis.cpp
756

yes

kstoimenov marked an inline comment as done.

Added requires to the test. Maybe this will solve Debian and Win builts?

vitalybuka accepted this revision.Oct 15 2021, 4:59 PM

LGTM with skip/assert
I guess in a separate patch we need to review how we handle accesses of different address spaces.

@nikic Thanks for pointing to address space issue.

This revision is now accepted and ready to land.Oct 15 2021, 4:59 PM
kstoimenov marked an inline comment as done.Oct 18 2021, 9:28 AM
kstoimenov added inline comments.
llvm/lib/Analysis/StackSafetyAnalysis.cpp
157

The issue is that this function is also called from another place and will fail if I add a check there too. I will keep the code as is.