Skip to content

Commit

Permalink
Fix setting volatile attribute for inlined basic blocks and instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
gmh5225 authored Mar 12, 2024
1 parent c6b4db7 commit f13903b
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions llvm/lib/Transforms/Utils/InlineFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2018,23 +2018,30 @@ inlineRetainOrClaimRVCalls(CallBase &CB, objcarc::ARCInstKind RVCallKind,
// Set volatile attribute for inlined basic block and instructions.
// This is used to preserve the volatile attribute of the original call instruction.
static void setVolatileForInlinedBB(BasicBlock *BB) {

// Do not set volatile attribute for basic block with only one instruction.
if (BB->size() <= 1)
return;

BB->setVolatile(true);
// Filter out BBs that contain EH pad.
if (BB->isEHPad())
return;

// Set volatile attribute for all instructions in the basic block.
for (auto &I : *BB) {
if (I.isEHPad())
continue;
if (I.isTerminator())
continue;
if (I.isPHINodeOrSelectInstOrSwitchInst())
continue;
if (isa<InvokeInst>(&I))
if (I.isPHINodeOrSelectInstOrSwitchInst())
continue;
if (isa<IntrinsicInst>(&I))
continue;
if (isa<InvokeInst>(&I))
continue;
I.setVolatile(true);
}

// Set volatile attribute for the basic block.
BB->setVolatile(true);
}

/// This function inlines the called function into the basic block of the
Expand Down

0 comments on commit f13903b

Please sign in to comment.