From 123bf5f46c31a016768b7ecd9b164bde5ef881d9 Mon Sep 17 00:00:00 2001 From: Orlando Cazalet-Hyams Date: Fri, 23 May 2025 10:15:42 +0100 Subject: [KeyInstr][Clang] If stmt atom (#134642) This patch is part of a stack that teaches Clang to generate Key Instructions metadata for C and C++. RFC: https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668 The feature is only functional in LLVM if LLVM is built with CMake flag LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed. --- clang/lib/CodeGen/CodeGenFunction.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp') diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 2256cc0..0356952 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -2118,6 +2118,8 @@ void CodeGenFunction::EmitBranchOnBoolExpr( llvm::Instruction *BrInst = Builder.CreateCondBr(CondV, TrueBlock, FalseBlock, Weights, Unpredictable); + addInstToNewSourceAtom(BrInst, CondV); + switch (HLSLControlFlowAttr) { case HLSLControlFlowHintAttr::Microsoft_branch: case HLSLControlFlowHintAttr::Microsoft_flatten: { @@ -3338,3 +3340,11 @@ void CodeGenFunction::addInstToSpecificSourceAtom( if (CGDebugInfo *DI = getDebugInfo()) DI->addInstToSpecificSourceAtom(KeyInstruction, Backup, Atom); } + +void CodeGenFunction::addInstToNewSourceAtom(llvm::Instruction *KeyInstruction, + llvm::Value *Backup) { + if (CGDebugInfo *DI = getDebugInfo()) { + ApplyAtomGroup Grp(getDebugInfo()); + DI->addInstToCurrentSourceAtom(KeyInstruction, Backup); + } +} \ No newline at end of file -- cgit v1.1