[cfe-commits] r51553 - in /cfe/trunk: include/clang/AST/Type.h lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGDebugInfo.h lib/CodeGen/CGStmt.cpp lib/CodeGen/CodeGenFunction.cpp
Eli Friedman
eli.friedman at gmail.com
Sat May 24 22:41:53 PDT 2008
On Sat, May 24, 2008 at 10:15 PM, Sanjiv Gupta
<sanjiv.gupta at microchip.com> wrote:
> + default:
> + {
> + assert (0 && "Unsupported type");
This assertion isn't very nice; it fires on real code.
> /// EmitRegionStart- Constructs the debug code for entering a declarative
> /// region - "llvm.dbg.region.start.".
> -void CGDebugInfo::EmitFunctionStart(llvm::Function *Fn, llvm::IRBuilder &Builder)
> +void CGDebugInfo::EmitRegionStart(llvm::Function *Fn, llvm::IRBuilder &Builder)
> {
> - // Get the appropriate compile unit.
> - llvm::CompileUnitDesc *Unit = getOrCreateCompileUnit(CurLoc);
> + llvm::BlockDesc *Block = new llvm::BlockDesc();
> + if (RegionStack.size() > 0)
> + Block->setContext(RegionStack.back());
> + RegionStack.push_back(Block);
> +
> + // Lazily construct llvm.dbg.region.start function.
> + if (!RegionStartFn)
> + RegionStartFn = llvm::Intrinsic::getDeclaration(&M->getModule(),
> + llvm::Intrinsic::dbg_region_start);
>
> - llvm::SubprogramDesc* Block = new llvm::SubprogramDesc;
> - DebugAllocationList.push_back(Block);
> - Block->setFile(Unit);
> - Block->setContext(Unit);
> - if (!SubProgramAnchor) {
> - SubProgramAnchor = new llvm::AnchorDesc(Block);
> - SR->Serialize(SubProgramAnchor);
> - }
> - Block->setAnchor(SubProgramAnchor);
> - Block->setName(Fn->getName());
> - Block->setFullName(Fn->getName());
> - Block->setIsDefinition(true);
> - SourceManager &SM = M->getContext().getSourceManager();
> - Block->setLine(SM.getLogicalLineNumber(CurLoc));
> - CurFuncDesc = getCastValueFor(Block);
> - if (!FuncStartFn)
> - FuncStartFn = llvm::Intrinsic::getDeclaration(&M->getModule(),
> - llvm::Intrinsic::dbg_func_start);
> - Builder.CreateCall(FuncStartFn, CurFuncDesc);
> + // Call llvm.dbg.func.start.
> + Builder.CreateCall(RegionStartFn, getCastValueFor(Block), "");
> }
>
> /// EmitRegionEnd - Constructs the debug code for exiting a declarative
> /// region - "llvm.dbg.region.end."
> -void CGDebugInfo::EmitFunctionEnd(llvm::Function *Fn, llvm::IRBuilder &Builder)
> +void CGDebugInfo::EmitRegionEnd(llvm::Function *Fn, llvm::IRBuilder &Builder)
> {
> // Lazily construct llvm.dbg.region.end function.
> if (!RegionEndFn)
> @@ -196,6 +507,8 @@
> EmitStopPoint(Fn, Builder);
>
> // Call llvm.dbg.func.end.
> - Builder.CreateCall(RegionEndFn, CurFuncDesc, "");
> + llvm::DebugInfoDesc *DID = RegionStack.back();
> + Builder.CreateCall(RegionEndFn, getCastValueFor(DID), "");
> + RegionStack.pop_back();
> }
Curious: does llc actually support regions? llvm-gcc doesn't generate them.
> - CGDebugInfo *DI = CGM.getDebugInfo();
> - if (DI) {
> - CompoundStmt* body = cast<CompoundStmt>(CurFuncDecl->getBody());
> - if (body->getRBracLoc().isValid()) {
> - DI->setLocation(body->getRBracLoc());
> - }
> - DI->EmitFunctionEnd(CurFn, Builder);
> - }
> -
What happens if the last block gets zapped by SimplfyCFG or something similar?
-Eli
More information about the cfe-commits
mailing list