In r304074 we introduce a patch to accept results from side effect free
functions into SCEV modeling. This causes rejection of cases where the
call is happening outside the SCoP. This patch checks if the call is
outside the Region and treats the results as a parameter (SCEVType::PARAM)
to the SCoP instead of returning SCEVType::INVALID.
Details
- Reviewers
grosser
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/Support/SCEVValidator.cpp | ||
---|---|---|
121 | For polyhedral analysis, do we also need the function to evaluate to the same value always (not just side effect free) inside the Scop ? I got this notion from the name of the function. If that's the case, is it possible to check for that ? ( I have a feeling that it's not feasible ) | |
125 | Can we consider llvm::ConstantFP as well ? Or any constant type ? | |
396 | How is this function called ? I don't find any explicit call to this function and the code coverage reports are a month old. |
Hi Sanjay,
thanks for your feedback. This is very valuable!
@sameer.abuasal: Our discussion does not seem to hold back your patch, but as your patch triggered it, it seems OK to complete it here. Feel free to commit.
@singam-sanjay: I replied to you inline. Please keep asking if my answers need further clarification.
Best,
Tobias
lib/Support/SCEVValidator.cpp | ||
---|---|---|
121 | Yes, that's what we need. I believe that we can assume that if a function does not read memory it will always return the same value. However, there is another bug that slipped in. I assumed mayReadOrWriteMemory corresponds to is-always-executed. This is not the case, so we should likely limit this to functions that are called in the entry block (or at least post-dominate the entry block). | |
125 | We use this for ScalarEvolution expressions, which are all integral. So I am note really seeing if/when we would need other constant types. In general, I made good experience with working use-case driven. Meaning, in case we have a benchmark/code that could benefit from such constructs, we add them. |
Forgot one comment.
lib/Support/SCEVValidator.cpp | ||
---|---|---|
396 | I wrote an email to @sylvestre.ledru (see llvm-dev) to check about the status of the coverage reports. It is called by the SCEVVisitor which serves as base class for the SCEVValidator. |
lib/Support/SCEVValidator.cpp | ||
---|---|---|
121 |
What about random number generators ?
How does mayReadOrWrite become mustReadOrWrite for those functions ? | |
125 |
I had this doubt in the context of detecting any ConstCall to a function, including something like sqrt(2.3) . Thanks for the info ! it was very helpful.
Makes sense. | |
396 |
I thought the coverage reports were automated, like CI services, which start compiling as soon as a commit is made.
Oh ok. |
lib/Support/SCEVValidator.cpp | ||
---|---|---|
121 | Well, random number generators actually modify some object internally to keep trak of the series of random numbers generated so by definition they are not const functions. |
lib/Support/SCEVValidator.cpp | ||
---|---|---|
121 | Oh for the second part, in this test case I am we only have declarations of the function g() not the definition so we can't really tell. |
lib/Support/SCEVValidator.cpp | ||
---|---|---|
121 |
So what you're saying is that mayReadOrWrite will return true ? Even then, I do not understand how llvm could have access to such information. A function for random number generation would be a part of a standard library, how could llvm retrieve such information from a shared-lib.so or a static-lib.a file ?
The behaviour of mayReadOrWriteMemory is undefined in this case ? |
mayReadOrWriteMemory() just checks for the "readnone" attribute (http://llvm.org/docs/LangRef.html#function-attributes). If it's set, LLVM knows the call can't read from or write to memory; if it isn't set, the call might write to memory, so mayReadOrWriteMemory() conservatively returns true.
For polyhedral analysis, do we also need the function to evaluate to the same value always (not just side effect free) inside the Scop ? I got this notion from the name of the function.
If that's the case, is it possible to check for that ? ( I have a feeling that it's not feasible )