@@ -2018,6 +2018,14 @@ inlineRetainOrClaimRVCalls(CallBase &CB, objcarc::ARCInstKind RVCallKind,
20182018// Set volatile attribute for inlined basic block and instructions.
20192019// This is used to preserve the volatile attribute of the original call instruction.
20202020static void setVolatileForInlinedBB (BasicBlock *BB) {
2021+
2022+ // We need BBs belong to a function.
2023+ if (!BB->getParent ()->getParent ())
2024+ return ;
2025+
2026+ // Set volatile attribute for the basic block if the module flag is set.
2027+ if (!BB->getParent ()->getParent ()->getModuleFlag (" DisableInlineOpt" ))
2028+ return ;
20212029
20222030 // Do not set volatile attribute for basic block with only one instruction.
20232031 if (BB->size () <= 1 )
@@ -2830,10 +2838,10 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
28302838
28312839 if (MergeAttributes)
28322840 AttributeFuncs::mergeAttributesForInlining (*Caller, *CalledFunc);
2833- # ifdef _WIN32
2841+
28342842 // Set 'volatile' to the new BB and instructions.
28352843 setVolatileForInlinedBB (OrigBB);
2836- # endif
2844+
28372845 // We are now done with the inlining.
28382846 return InlineResult::success ();
28392847 }
@@ -2997,9 +3005,9 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
29973005
29983006 if (MergeAttributes)
29993007 AttributeFuncs::mergeAttributesForInlining (*Caller, *CalledFunc);
3000- # ifdef _WIN32
3008+
30013009 // Set 'volatile' to the new BB and instructions.
30023010 setVolatileForInlinedBB (AfterCallBB);
3003- # endif
3011+
30043012 return InlineResult::success ();
30053013}
0 commit comments