-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[BasicAA][TLI] Treat local-linkage globals or known environments as not aliasing errno #170290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 7 commits
46df14b
fee1d59
06294b9
33dea37
2775070
39819a3
05a7a9f
f8a42c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1001,7 +1001,10 @@ ModRefInfo BasicAAResult::getModRefInfo(const CallBase *Call, | |
|
|
||
| // Refine accesses to errno memory. | ||
| if ((ErrnoMR | Result) != Result) { | ||
| if (AAQI.AAR.aliasErrno(Loc, Call->getModule()) != AliasResult::NoAlias) { | ||
| // Do not make any assumptions about errno on freestanding environments. | ||
| bool IsFreestanding = Call->getFunction()->hasFnAttribute("no-builtins"); | ||
| if (IsFreestanding || | ||
| AAQI.AAR.aliasErrno(Loc, Call->getModule()) != AliasResult::NoAlias) { | ||
| // Exclusion conditions do not hold, this memory location may alias errno. | ||
| Result |= ErrnoMR; | ||
| } | ||
|
|
@@ -1870,8 +1873,21 @@ AliasResult BasicAAResult::aliasErrno(const MemoryLocation &Loc, | |
| Loc.Size.getValue().getKnownMinValue() * 8 > TLI.getIntSize()) | ||
| return AliasResult::NoAlias; | ||
|
|
||
| if (isIdentifiedFunctionLocal(getUnderlyingObject(Loc.Ptr))) | ||
| const Value *Object = getUnderlyingObject(Loc.Ptr); | ||
| if (isIdentifiedFunctionLocal(Object)) | ||
| return AliasResult::NoAlias; | ||
|
|
||
| if (auto *GV = dyn_cast<GlobalVariable>(Object)) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need additional logic for GlobalAlias? Or has it been handled by other places?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't believe so - if a GlobalAlias turns out to be a GlobalVariable, getUnderlyingObject() should tell us that. |
||
| // Errno cannot alias internal/private globals. | ||
| if (GV->hasLocalLinkage()) | ||
| return AliasResult::NoAlias; | ||
|
|
||
| // Neither can errno alias globals where environments define it as a | ||
| // function call. | ||
| if (TLI.isErrnoFunctionCall()) | ||
| return AliasResult::NoAlias; | ||
| } | ||
|
|
||
| return AliasResult::MayAlias; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this check belongs here. I'd expect freestanding to only be relevant for isErrnoFunctionCall.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rework of aliasErrno signatures sort of prevented me from checking it closer to isErrnoFunctionCall, though agree it's best suitable there.