@@ -2018,6 +2018,14 @@ inlineRetainOrClaimRVCalls(CallBase &CB, objcarc::ARCInstKind RVCallKind,
2018
2018
// Set volatile attribute for inlined basic block and instructions.
2019
2019
// This is used to preserve the volatile attribute of the original call instruction.
2020
2020
static 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 ;
2021
2029
2022
2030
// Do not set volatile attribute for basic block with only one instruction.
2023
2031
if (BB->size () <= 1 )
@@ -2830,10 +2838,10 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
2830
2838
2831
2839
if (MergeAttributes)
2832
2840
AttributeFuncs::mergeAttributesForInlining (*Caller, *CalledFunc);
2833
- # ifdef _WIN32
2841
+
2834
2842
// Set 'volatile' to the new BB and instructions.
2835
2843
setVolatileForInlinedBB (OrigBB);
2836
- # endif
2844
+
2837
2845
// We are now done with the inlining.
2838
2846
return InlineResult::success ();
2839
2847
}
@@ -2997,9 +3005,9 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
2997
3005
2998
3006
if (MergeAttributes)
2999
3007
AttributeFuncs::mergeAttributesForInlining (*Caller, *CalledFunc);
3000
- # ifdef _WIN32
3008
+
3001
3009
// Set 'volatile' to the new BB and instructions.
3002
3010
setVolatileForInlinedBB (AfterCallBB);
3003
- # endif
3011
+
3004
3012
return InlineResult::success ();
3005
3013
}
0 commit comments