-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[FlattenCFG] Fix an Imprecise Usage of AA #128117
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
Changes from all commits
2d987ba
5cd91b8
cc3b893
68c4c7b
ee15a70
12293ce
28dfc43
6f3217a
326c5de
137257d
2d000dc
6cb7208
2e93b5c
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 | ||
---|---|---|---|---|
|
@@ -336,6 +336,26 @@ ModRefInfo AAResults::getModRefInfo(const CallBase *Call1, | |||
return Result; | ||||
} | ||||
|
||||
ModRefInfo AAResults::getModRefInfo(const Instruction *I1, | ||||
const Instruction *I2) { | ||||
SimpleAAQueryInfo AAQIP(*this); | ||||
return getModRefInfo(I1, I2, AAQIP); | ||||
} | ||||
|
||||
ModRefInfo AAResults::getModRefInfo(const Instruction *I1, | ||||
const Instruction *I2, AAQueryInfo &AAQI) { | ||||
// Early-exit if either instruction does not read or write memory. | ||||
if (!I1->mayReadOrWriteMemory() || !I2->mayReadOrWriteMemory()) | ||||
return ModRefInfo::NoModRef; | ||||
|
||||
if (const auto *Call2 = dyn_cast<CallBase>(I2)) | ||||
return getModRefInfo(I1, Call2, AAQI); | ||||
|
||||
// FIXME: We can have a more precise result. | ||||
ModRefInfo MR = getModRefInfo(I1, MemoryLocation::getOrNone(I2), AAQI); | ||||
return isModOrRefSet(MR) ? ModRefInfo::ModRef : ModRefInfo::NoModRef; | ||||
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. This could be more precise, but it's okay to start with. 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. What would be a better / more precise way to check the 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. Basically, what you are currently doing is a very crude check that the two instructions somehow access the same memory. It can be made more precise by checking the kind of access. For example, if both instructions only read memory, we can actually return NoModRef, because read-read dependences can be ignored. I guess you could easily handle that part by updating your mayReadOrWriteMemory checks to check that at least one is a write instead. Then if I1 is a read (and I2 a write) we can return Ref instead. If I1 is write (and I1 a read) we can return Mod. (This is why the order of the argument matters.) Basically, what the Call-Call handling does starting from:
I think it's ok if you add a FIXME. |
||||
} | ||||
|
||||
MemoryEffects AAResults::getMemoryEffects(const CallBase *Call, | ||||
AAQueryInfo &AAQI) { | ||||
MemoryEffects Result = MemoryEffects::unknown(); | ||||
|
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.
Should accept AAQueryInfo as parameter.
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.
To clarify this bit: We should have a method taking AAQI, and another helper that uses SimplieAAQueryInfo and call the main method.
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 have updated the methods. Let me know whether it is you expected.