-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[LLVM-C] Allow LLVM{Get,Set}Volatile
to work on memory intrinsics
#162810
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 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 |
---|---|---|
|
@@ -4106,6 +4106,8 @@ LLVMBool LLVMGetVolatile(LLVMValueRef MemAccessInst) { | |
return SI->isVolatile(); | ||
if (AtomicRMWInst *AI = dyn_cast<AtomicRMWInst>(P)) | ||
return AI->isVolatile(); | ||
if (MemIntrinsic *MI = dyn_cast<MemIntrinsic>(P)) | ||
return MI->isVolatile(); | ||
return cast<AtomicCmpXchgInst>(P)->isVolatile(); | ||
} | ||
|
||
|
@@ -4117,6 +4119,8 @@ void LLVMSetVolatile(LLVMValueRef MemAccessInst, LLVMBool isVolatile) { | |
return SI->setVolatile(isVolatile); | ||
if (AtomicRMWInst *AI = dyn_cast<AtomicRMWInst>(P)) | ||
return AI->setVolatile(isVolatile); | ||
if (MemIntrinsic *MI = dyn_cast<MemIntrinsic>(P)) | ||
return MI->setVolatile(ConstantInt::getBool(P->getContext(), isVolatile)); | ||
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. After thinking about this a bit more, I'm not sure we should do this. I am planning to change the volatile representation for memory intrinsics from an argument to an operand bundle. This means that it will no longer be possible to make the intrinsic volatile in-place, it requires creating a new one. So there is a high risk that this support is going to be very short-lived. |
||
return cast<AtomicCmpXchgInst>(P)->setVolatile(isVolatile); | ||
} | ||
|
||
|
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.
We could replace this whole function with
cast<Instruction>(P)->isVolatile()
. This would just return false for instructions that don't support volatile.