-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[flang][nfc] Support volatility in Fir ops #134858
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
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 |
---|---|---|
|
@@ -15,13 +15,26 @@ | |
|
||
namespace fir { | ||
|
||
/// Return true iff the Operation is a non-volatile LoadOp or ArrayLoadOp. | ||
inline bool nonVolatileLoad(mlir::Operation *op) { | ||
if (auto load = mlir::dyn_cast<fir::LoadOp>(op)) | ||
return !load->getAttr("volatile"); | ||
if (auto arrLoad = mlir::dyn_cast<fir::ArrayLoadOp>(op)) | ||
return !arrLoad->getAttr("volatile"); | ||
return false; | ||
/// The LLVM dialect represents volatile memory accesses as read and write | ||
/// effects to an unknown memory location, but this may be overly conservative. | ||
/// LLVM Language Reference only specifies that volatile memory accesses | ||
/// must not be reordered relative to other volatile memory accesses, so it | ||
/// is more precise to use a separate memory resource for volatile memory | ||
/// accesses. | ||
inline void addVolatileMemoryEffects( | ||
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 you have a patch in your stack using this on the HLFIR operations (hlfir.assign, intrinsics, ....)? 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. I do - do you have concerns about them that I should look into? 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. Let me add some more tests in #134858. 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. No specific concerns, I just wanted to make sure this was not forgotten and that the |
||
mlir::TypeRange type, | ||
llvm::SmallVectorImpl< | ||
mlir::SideEffects::EffectInstance<mlir::MemoryEffects::Effect>> | ||
&effects) { | ||
for (mlir::Type t : type) { | ||
if (fir::isa_volatile_type(t)) { | ||
effects.emplace_back(mlir::MemoryEffects::Read::get(), | ||
fir::VolatileMemoryResource::get()); | ||
effects.emplace_back(mlir::MemoryEffects::Write::get(), | ||
fir::VolatileMemoryResource::get()); | ||
break; | ||
} | ||
ashermancinelli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
|
||
/// Return true iff the Operation is a call. | ||
|
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 think this could even be
Pure
since this is a "no-op" at runtime and can be safely hoisted from if/then/else and do loop regions.