@@ -1576,11 +1576,6 @@ llvm::Function *CGOpenMPRuntimeGPU::emitParallelOutlinedFunction(
1576
1576
auto *OutlinedFun =
1577
1577
cast<llvm::Function>(CGOpenMPRuntime::emitParallelOutlinedFunction (
1578
1578
D, ThreadIDVar, InnermostKind, CodeGen));
1579
- if (CGM.getLangOpts ().Optimize ) {
1580
- OutlinedFun->removeFnAttr (llvm::Attribute::NoInline);
1581
- OutlinedFun->removeFnAttr (llvm::Attribute::OptimizeNone);
1582
- OutlinedFun->addFnAttr (llvm::Attribute::AlwaysInline);
1583
- }
1584
1579
IsInTargetMasterThreadRegion = PrevIsInTargetMasterThreadRegion;
1585
1580
IsInTTDRegion = PrevIsInTTDRegion;
1586
1581
if (getExecutionMode () != CGOpenMPRuntimeGPU::EM_SPMD &&
@@ -1698,11 +1693,6 @@ llvm::Function *CGOpenMPRuntimeGPU::emitTeamsOutlinedFunction(
1698
1693
CodeGen.setAction(Action);
1699
1694
llvm::Function *OutlinedFun = CGOpenMPRuntime::emitTeamsOutlinedFunction(
1700
1695
D, ThreadIDVar, InnermostKind, CodeGen);
1701
- if (CGM.getLangOpts().Optimize) {
1702
- OutlinedFun->removeFnAttr (llvm::Attribute::NoInline);
1703
- OutlinedFun->removeFnAttr (llvm::Attribute::OptimizeNone);
1704
- OutlinedFun->addFnAttr (llvm::Attribute::AlwaysInline);
1705
- }
1706
1696
1707
1697
return OutlinedFun;
1708
1698
}
@@ -2102,6 +2092,14 @@ void CGOpenMPRuntimeGPU::emitNonSPMDParallelCall(
2102
2092
// Force inline this outlined function at its call site.
2103
2093
Fn->setLinkage (llvm::GlobalValue::InternalLinkage);
2104
2094
2095
+ // Ensure we do not inline the function. This is trivially true for the ones
2096
+ // passed to __kmpc_fork_call but the ones calles in serialized regions
2097
+ // could be inlined. This is not a perfect but it is closer to the invariant
2098
+ // we want, namely, every data environment starts with a new function.
2099
+ // TODO: We should pass the if condition to the runtime function and do the
2100
+ // handling there. Much cleaner code.
2101
+ cast<llvm::Function>(OutlinedFn)->addFnAttr (llvm::Attribute::NoInline);
2102
+
2105
2103
Address ZeroAddr = CGF.CreateDefaultAlignTempAlloca (CGF.Int32Ty ,
2106
2104
/* Name=*/ " .zero.addr" );
2107
2105
CGF.InitTempAlloca (ZeroAddr, CGF.Builder .getInt32 (/* C*/ 0 ));
@@ -3134,11 +3132,6 @@ static llvm::Function *emitShuffleAndReduceFunction(
3134
3132
" _omp_reduction_shuffle_and_reduce_func" , &CGM.getModule ());
3135
3133
CGM.SetInternalFunctionAttributes (GlobalDecl (), Fn, CGFI);
3136
3134
Fn->setDoesNotRecurse ();
3137
- if (CGM.getLangOpts ().Optimize ) {
3138
- Fn->removeFnAttr (llvm::Attribute::NoInline);
3139
- Fn->removeFnAttr (llvm::Attribute::OptimizeNone);
3140
- Fn->addFnAttr (llvm::Attribute::AlwaysInline);
3141
- }
3142
3135
3143
3136
CodeGenFunction CGF (CGM);
3144
3137
CGF.StartFunction (GlobalDecl (), C.VoidTy , Fn, CGFI, Args, Loc, Loc);
0 commit comments