|
29 | 29 | #include "clang/Basic/LangOptions.h" |
30 | 30 | #include "clang/Frontend/CodeGenOptions.h" |
31 | 31 | #include "clang/Parse/ParseHLSL.h" // root sig would be in Parser if part of lang |
| 32 | +#include "clang/Sema/SemaDiagnostic.h" |
32 | 33 | #include "CodeGenFunction.h" |
33 | 34 |
|
34 | 35 | #include "dxc/DXIL/DxilConstants.h" |
@@ -3309,7 +3310,7 @@ void AddDxBreak(Module &M, |
3309 | 3310 |
|
3310 | 3311 | namespace CGHLSLMSHelper { |
3311 | 3312 |
|
3312 | | -ScopeInfo::ScopeInfo(Function *F) : maxRetLevel(0), bAllReturnsInIf(true) { |
| 3313 | +ScopeInfo::ScopeInfo(Function *F, clang::SourceLocation loc) : maxRetLevel(0), bAllReturnsInIf(true), sourceLoc(loc) { |
3313 | 3314 | Scope FuncScope; |
3314 | 3315 | FuncScope.kind = Scope::ScopeKind::FunctionScope; |
3315 | 3316 | FuncScope.EndScopeBB = nullptr; |
@@ -3549,12 +3550,21 @@ static void ChangePredBranch(BasicBlock *BB, BasicBlock *NewBB) { |
3549 | 3550 | // } |
3550 | 3551 | // return vRet; |
3551 | 3552 | // } |
3552 | | -void StructurizeMultiRetFunction(Function *F, ScopeInfo &ScopeInfo, |
| 3553 | +void StructurizeMultiRetFunction(Function *F, clang::DiagnosticsEngine &Diags, ScopeInfo &ScopeInfo, |
3553 | 3554 | bool bWaveEnabledStage, |
3554 | 3555 | SmallVector<BranchInst *, 16> &DxBreaks) { |
3555 | 3556 |
|
3556 | 3557 | if (ScopeInfo.CanSkipStructurize()) |
3557 | 3558 | return; |
| 3559 | + |
| 3560 | + // If there are cleanup blocks generated for lifetime markers, do |
| 3561 | + // not structurize returns. The scope info recorded is no longer correct. |
| 3562 | + if (ScopeInfo.HasCleanupBlocks()) { |
| 3563 | + Diags.Report(ScopeInfo.GetSourceLocation(), clang::diag::warn_hlsl_structurize_exits_lifetime_markers_conflict) |
| 3564 | + << F->getName(); |
| 3565 | + return; |
| 3566 | + } |
| 3567 | + |
3558 | 3568 | // Get bbWithRets. |
3559 | 3569 | auto &rets = ScopeInfo.GetRetScopes(); |
3560 | 3570 |
|
@@ -3722,7 +3732,8 @@ void StructurizeMultiRet(Module &M, clang::CodeGen::CodeGenModule &CGM, |
3722 | 3732 | auto it = ScopeMap.find(&F); |
3723 | 3733 | if (it == ScopeMap.end()) |
3724 | 3734 | continue; |
3725 | | - StructurizeMultiRetFunction(&F, it->second, bWaveEnabledStage, DxBreaks); |
| 3735 | + |
| 3736 | + StructurizeMultiRetFunction(&F, CGM.getDiags(), it->second, bWaveEnabledStage, DxBreaks); |
3726 | 3737 | } |
3727 | 3738 | } |
3728 | 3739 |
|
|
0 commit comments