<div dir="ltr">I reverted this in r327657 because it crashed while compiling Chromium. I'll try to get a reduction soon or re-apply it if the fix is easy.</div><br><br><div class="gmail_quote"><div dir="ltr">On Thu, Mar 15, 2018 at 4:54 AM Brock Wyma via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: bwyma<br>
Date: Thu Mar 15 04:52:17 2018<br>
New Revision: 327620<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=327620&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=327620&view=rev</a><br>
Log:<br>
[CodeView] Initial support for emitting S_BLOCK32 symbols for lexical scopes<br>
<br>
This patch sorts local variables by lexical scope and emits them inside<br>
an appropriate S_BLOCK32 CodeView symbol.<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D42926" rel="noreferrer" target="_blank">https://reviews.llvm.org/D42926</a><br>
<br>
<br>
Added:<br>
llvm/trunk/test/DebugInfo/COFF/lexicalblock.ll<br>
Modified:<br>
llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp<br>
llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h<br>
llvm/trunk/test/DebugInfo/COFF/register-variables.ll<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=327620&r1=327619&r2=327620&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=327620&r1=327619&r2=327620&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp Thu Mar 15 04:52:17 2018<br>
@@ -365,15 +365,15 @@ unsigned CodeViewDebug::getPointerSizeIn<br>
}<br>
<br>
void CodeViewDebug::recordLocalVariable(LocalVariable &&Var,<br>
- const DILocation *InlinedAt) {<br>
- if (InlinedAt) {<br>
+ const LexicalScope *LS) {<br>
+ if (const DILocation *InlinedAt = LS->getInlinedAt()) {<br>
// This variable was inlined. Associate it with the InlineSite.<br>
const DISubprogram *Inlinee = Var.DIVar->getScope()->getSubprogram();<br>
InlineSite &Site = getInlineSite(InlinedAt, Inlinee);<br>
Site.InlinedLocals.emplace_back(Var);<br>
} else {<br>
- // This variable goes in the main ProcSym.<br>
- CurFn->Locals.emplace_back(Var);<br>
+ // This variable goes into the corresponding lexical scope.<br>
+ ScopeVariables[LS].emplace_back(Var);<br>
}<br>
}<br>
<br>
@@ -905,6 +905,7 @@ void CodeViewDebug::emitDebugInfoForFunc<br>
OS.EmitLabel(ProcRecordEnd);<br>
<br>
emitLocalVariableList(FI.Locals);<br>
+ emitLexicalBlockList(FI.ChildBlocks, FI);<br>
<br>
// Emit inlined call site information. Only emit functions inlined directly<br>
// into the parent function. We'll emit the other sites recursively as part<br>
@@ -1025,7 +1026,7 @@ void CodeViewDebug::collectVariableInfoF<br>
LocalVariable Var;<br>
Var.DIVar = VI.Var;<br>
Var.DefRanges.emplace_back(std::move(DefRange));<br>
- recordLocalVariable(std::move(Var), VI.Loc->getInlinedAt());<br>
+ recordLocalVariable(std::move(Var), Scope);<br>
}<br>
}<br>
<br>
@@ -1156,7 +1157,7 @@ void CodeViewDebug::collectVariableInfo(<br>
Var.DIVar = DIVar;<br>
<br>
calculateRanges(Var, Ranges);<br>
- recordLocalVariable(std::move(Var), InlinedAt);<br>
+ recordLocalVariable(std::move(Var), Scope);<br>
}<br>
}<br>
<br>
@@ -2362,6 +2363,128 @@ void CodeViewDebug::emitLocalVariable(co<br>
}<br>
}<br>
<br>
+void CodeViewDebug::emitLexicalBlockList(ArrayRef<LexicalBlock *> Blocks,<br>
+ const FunctionInfo& FI) {<br>
+ for (LexicalBlock *Block : Blocks)<br>
+ emitLexicalBlock(*Block, FI);<br>
+}<br>
+<br>
+/// Emit an S_BLOCK32 and S_END record pair delimiting the contents of a<br>
+/// lexical block scope.<br>
+void CodeViewDebug::emitLexicalBlock(const LexicalBlock &Block,<br>
+ const FunctionInfo& FI) {<br>
+ MCSymbol *RecordBegin = MMI->getContext().createTempSymbol(),<br>
+ *RecordEnd = MMI->getContext().createTempSymbol();<br>
+<br>
+ // Lexical block symbol record.<br>
+ OS.AddComment("Record length");<br>
+ OS.emitAbsoluteSymbolDiff(RecordEnd, RecordBegin, 2); // Record Length<br>
+ OS.EmitLabel(RecordBegin);<br>
+ OS.AddComment("Record kind: S_BLOCK32");<br>
+ OS.EmitIntValue(SymbolKind::S_BLOCK32, 2); // Record Kind<br>
+ OS.AddComment("PtrParent");<br>
+ OS.EmitIntValue(0, 4); // PtrParent<br>
+ OS.AddComment("PtrEnd");<br>
+ OS.EmitIntValue(0, 4); // PtrEnd<br>
+ OS.AddComment("Code size");<br>
+ OS.emitAbsoluteSymbolDiff(Block.End, Block.Begin, 4); // Code Size<br>
+ OS.AddComment("Function section relative address");<br>
+ OS.EmitCOFFSecRel32(Block.Begin, /*Offset=*/0); // Func Offset<br>
+ OS.AddComment("Function section index");<br>
+ OS.EmitCOFFSectionIndex(FI.Begin); // Func Symbol<br>
+ OS.AddComment("Lexical block name");<br>
+ emitNullTerminatedSymbolName(OS, Block.Name); // Name<br>
+ OS.EmitLabel(RecordEnd);<br>
+<br>
+ // Emit variables local to this lexical block.<br>
+ emitLocalVariableList(Block.Locals);<br>
+<br>
+ // Emit lexical blocks contained within this block.<br>
+ emitLexicalBlockList(Block.Children, FI);<br>
+<br>
+ // Close the lexical block scope.<br>
+ OS.AddComment("Record length");<br>
+ OS.EmitIntValue(2, 2); // Record Length<br>
+ OS.AddComment("Record kind: S_END");<br>
+ OS.EmitIntValue(SymbolKind::S_END, 2); // Record Kind<br>
+}<br>
+<br>
+/// Convenience routine for collecting lexical block information for a list<br>
+/// of lexical scopes.<br>
+void CodeViewDebug::collectLexicalBlockInfo(<br>
+ SmallVectorImpl<LexicalScope *> &Scopes,<br>
+ SmallVectorImpl<LexicalBlock *> &Blocks,<br>
+ SmallVectorImpl<LocalVariable> &Locals) {<br>
+ for (LexicalScope *Scope : Scopes)<br>
+ collectLexicalBlockInfo(*Scope, Blocks, Locals);<br>
+}<br>
+<br>
+/// Populate the lexical blocks and local variable lists of the parent with<br>
+/// information about the specified lexical scope.<br>
+void CodeViewDebug::collectLexicalBlockInfo(<br>
+ LexicalScope &Scope,<br>
+ SmallVectorImpl<LexicalBlock *> &ParentBlocks,<br>
+ SmallVectorImpl<LocalVariable> &ParentLocals) {<br>
+ if (Scope.isAbstractScope())<br>
+ return;<br>
+<br>
+ auto LocalsIter = ScopeVariables.find(&Scope);<br>
+ if (LocalsIter == ScopeVariables.end()) {<br>
+ // This scope does not contain variables and can be eliminated.<br>
+ collectLexicalBlockInfo(Scope.getChildren(), ParentBlocks, ParentLocals);<br>
+ return;<br>
+ }<br>
+ SmallVectorImpl<LocalVariable> &Locals = LocalsIter->second;<br>
+<br>
+ const DILexicalBlock *DILB = dyn_cast<DILexicalBlock>(Scope.getScopeNode());<br>
+ if (!DILB) {<br>
+ // This scope is not a lexical block and can be eliminated, but keep any<br>
+ // local variables it contains.<br>
+ ParentLocals.append(Locals.begin(), Locals.end());<br>
+ collectLexicalBlockInfo(Scope.getChildren(), ParentBlocks, ParentLocals);<br>
+ return;<br>
+ }<br>
+<br>
+ const SmallVectorImpl<InsnRange> &Ranges = Scope.getRanges();<br>
+ if (Ranges.size() != 1 || !getLabelAfterInsn(Ranges.front().second)) {<br>
+ // This lexical block scope has too many address ranges to represent in the<br>
+ // current CodeView format or does not have a valid address range.<br>
+ // Eliminate this lexical scope and promote any locals it contains to the<br>
+ // parent scope.<br>
+ //<br>
+ // For lexical scopes with multiple address ranges you may be tempted to<br>
+ // construct a single range covering every instruction where the block is<br>
+ // live and everything in between. Unfortunately, Visual Studio only<br>
+ // displays variables from the first matching lexical block scope. If the<br>
+ // first lexical block contains exception handling code or cold code which<br>
+ // is moved to the bottom of the routine creating a single range covering<br>
+ // nearly the entire routine, then it will hide all other lexical blocks<br>
+ // and the variables they contain.<br>
+ //<br>
+ ParentLocals.append(Locals.begin(), Locals.end());<br>
+ collectLexicalBlockInfo(Scope.getChildren(), ParentBlocks, ParentLocals);<br>
+ return;<br>
+ }<br>
+<br>
+ // Create a new CodeView lexical block for this lexical scope. If we've<br>
+ // seen this DILexicalBlock before then the scope tree is malformed and<br>
+ // we can handle this gracefully by not processing it a second time.<br>
+ auto BlockInsertion = CurFn->LexicalBlocks.insert({DILB, LexicalBlock()});<br>
+ if (!BlockInsertion.second)<br>
+ return;<br>
+<br>
+ // Create a lexical block containing the local variables and collect the<br>
+ // the lexical block information for the children.<br>
+ const InsnRange &Range = Ranges.front();<br>
+ LexicalBlock &Block = BlockInsertion.first->second;<br>
+ Block.Begin = getLabelBeforeInsn(Range.first);<br>
+ Block.End = getLabelAfterInsn(Range.second);<br>
+ Block.Name = DILB->getName();<br>
+ Block.Locals = std::move(Locals);<br>
+ ParentBlocks.push_back(&Block);<br>
+ collectLexicalBlockInfo(Scope.getChildren(), Block.Children, Block.Locals);<br>
+}<br>
+<br>
void CodeViewDebug::endFunctionImpl(const MachineFunction *MF) {<br>
const Function &GV = MF->getFunction();<br>
assert(FnDebugInfo.count(&GV));<br>
@@ -2369,6 +2492,15 @@ void CodeViewDebug::endFunctionImpl(cons<br>
<br>
collectVariableInfo(GV.getSubprogram());<br>
<br>
+ // Build the lexical block structure to emit for this routine.<br>
+ if (LexicalScope *CFS = LScopes.getCurrentFunctionScope())<br>
+ collectLexicalBlockInfo(*CFS, CurFn->ChildBlocks, CurFn->Locals);<br>
+<br>
+ // Clear the scope and variable information from the map which will not be<br>
+ // valid after we have finished processing this routine. This also prepares<br>
+ // the map for the subsequent routine.<br>
+ ScopeVariables.clear();<br>
+<br>
// Don't emit anything if we don't have any line tables.<br>
if (!CurFn->HaveLineInfo) {<br>
FnDebugInfo.erase(&GV);<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h?rev=327620&r1=327619&r2=327620&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h?rev=327620&r1=327619&r2=327620&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h Thu Mar 15 04:52:17 2018<br>
@@ -107,6 +107,15 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDe<br>
unsigned SiteFuncId = 0;<br>
};<br>
<br>
+ // Combines information from DILexicalBlock and LexicalScope.<br>
+ struct LexicalBlock {<br>
+ SmallVector<LocalVariable, 1> Locals;<br>
+ SmallVector<LexicalBlock *, 1> Children;<br>
+ const MCSymbol *Begin;<br>
+ const MCSymbol *End;<br>
+ StringRef Name;<br>
+ };<br>
+<br>
// For each function, store a vector of labels to its instructions, as well as<br>
// to the end of the function.<br>
struct FunctionInfo {<br>
@@ -119,6 +128,11 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDe<br>
<br>
SmallVector<LocalVariable, 1> Locals;<br>
<br>
+ std::unordered_map<const DILexicalBlockBase*, LexicalBlock> LexicalBlocks;<br>
+<br>
+ // Lexical blocks containing local variables.<br>
+ SmallVector<LexicalBlock *, 1> ChildBlocks;<br>
+<br>
std::vector<std::pair<MCSymbol *, MDNode *>> Annotations;<br>
<br>
const MCSymbol *Begin = nullptr;<br>
@@ -129,6 +143,12 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDe<br>
};<br>
FunctionInfo *CurFn = nullptr;<br>
<br>
+ // Map used to seperate variables according to the lexical scope they belong<br>
+ // in. This is populated by recordLocalVariable() before<br>
+ // collectLexicalBlocks() separates the variables between the FunctionInfo<br>
+ // and LexicalBlocks.<br>
+ DenseMap<const LexicalScope *, SmallVector<LocalVariable, 1>> ScopeVariables;<br>
+<br>
/// The set of comdat .debug$S sections that we've seen so far. Each section<br>
/// must start with a magic version number that must only be emitted once.<br>
/// This set tracks which sections we've already opened.<br>
@@ -253,9 +273,18 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDe<br>
<br>
void collectVariableInfoFromMFTable(DenseSet<InlinedVariable> &Processed);<br>
<br>
+ // Construct the lexical block tree for a routine, pruning emptpy lexical<br>
+ // scopes, and populate it with local variables.<br>
+ void collectLexicalBlockInfo(SmallVectorImpl<LexicalScope *> &Scopes,<br>
+ SmallVectorImpl<LexicalBlock *> &Blocks,<br>
+ SmallVectorImpl<LocalVariable> &Locals);<br>
+ void collectLexicalBlockInfo(LexicalScope &Scope,<br>
+ SmallVectorImpl<LexicalBlock *> &ParentBlocks,<br>
+ SmallVectorImpl<LocalVariable> &ParentLocals);<br>
+<br>
/// Records information about a local variable in the appropriate scope. In<br>
/// particular, locals from inlined code live inside the inlining site.<br>
- void recordLocalVariable(LocalVariable &&Var, const DILocation *Loc);<br>
+ void recordLocalVariable(LocalVariable &&Var, const LexicalScope *LS);<br>
<br>
/// Emits local variables in the appropriate order.<br>
void emitLocalVariableList(ArrayRef<LocalVariable> Locals);<br>
@@ -263,6 +292,13 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDe<br>
/// Emits an S_LOCAL record and its associated defined ranges.<br>
void emitLocalVariable(const LocalVariable &Var);<br>
<br>
+ /// Emits a sequence of lexical block scopes and their children.<br>
+ void emitLexicalBlockList(ArrayRef<LexicalBlock *> Blocks,<br>
+ const FunctionInfo& FI);<br>
+<br>
+ /// Emit a lexical block scope and its children.<br>
+ void emitLexicalBlock(const LexicalBlock &Block, const FunctionInfo& FI);<br>
+<br>
/// Translates the DIType to codeview if necessary and returns a type index<br>
/// for it.<br>
codeview::TypeIndex getTypeIndex(DITypeRef TypeRef,<br>
<br>
Added: llvm/trunk/test/DebugInfo/COFF/lexicalblock.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/lexicalblock.ll?rev=327620&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/lexicalblock.ll?rev=327620&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/COFF/lexicalblock.ll (added)<br>
+++ llvm/trunk/test/DebugInfo/COFF/lexicalblock.ll Thu Mar 15 04:52:17 2018<br>
@@ -0,0 +1,328 @@<br>
+; RUN: llc < %s -filetype=obj | llvm-readobj - -codeview | FileCheck %s<br>
+;<br>
+; -- lexicablock.cxx begin ----------------------------------------------------<br>
+; int main(int argc, char *argv[]) {<br>
+; int localA = 1;<br>
+;<br>
+; { // S_BLOCK32 not emitted because it has multiple address ranges.<br>
+; int localB = 2;<br>
+;<br>
+; if (__builtin_expect(argc != 1, 0)) { // S_BLOCK32 containing 'localC'<br>
+; int localC = 3;<br>
+; }<br>
+; }<br>
+;<br>
+; { // S_BLOCK32 containing 'localD'<br>
+; int localD = 4;<br>
+; localA = localD;<br>
+; }<br>
+;<br>
+; { // S_BLOCK32 not emitted<br>
+; { // S_BLOCK32 containing 'localE'<br>
+; int localE = 5;<br>
+; localA = localE;<br>
+; }<br>
+; }<br>
+;<br>
+; { // S_BLOCK32 containing 'localF'<br>
+; int localF = 6;<br>
+; localA = localF;<br>
+;<br>
+; { // S_BLOCK32 containing 'localG'<br>
+; int localG = 7;<br>
+; localA = localG;<br>
+; }<br>
+; }<br>
+;<br>
+; if (localA == 7) { // S_BLOCK32 containing 'localH'<br>
+; int localH = 8;<br>
+; localA = localH;<br>
+; }<br>
+;<br>
+; return localA != 8 ? -1 : 0;<br>
+; }<br>
+; -- lexicalblock.cxx end -----------------------------------------------------<br>
+;<br>
+; To regenerate the IR below:<br>
+; $ clang -cc1 -triple i686-pc-windows -emit-llvm -o lexicalblock.tmp -debug-info-kind=limited -gcodeview lexicablock.cxx -O1 -disable-llvm-passes<br>
+; $ opt -lower-expect -S -o lexicalblock.ll < lexicalblock.tmp<br>
+;<br>
+; The commands above split the lexical block containing localB and localC into<br>
+; two parts, thus creating multiple ranges for the containing lexical block<br>
+; without optimizing out the whole thing.<br>
+;<br>
+; CHECK: {{.*}}Proc{{.*}}Sym {<br>
+; CHECK: DisplayName: main<br>
+; CHECK: }<br>
+; CHECK: LocalSym {<br>
+; CHECK: VarName: argc<br>
+; CHECK: }<br>
+; CHECK: LocalSym {<br>
+; CHECK: VarName: argv<br>
+; CHECK: }<br>
+; CHECK: LocalSym {<br>
+; CHECK: VarName: localA<br>
+; CHECK: }<br>
+; CHECK: LocalSym {<br>
+; CHECK: VarName: localB<br>
+; CHECK: }<br>
+; CHECK: BlockSym {<br>
+; CHECK: Kind: S_BLOCK32 {{.*}}<br>
+; CHECK: BlockName:<br>
+; CHECK: }<br>
+; CHECK: LocalSym {<br>
+; CHECK: VarName: localC<br>
+; CHECK: }<br>
+; CHECK: ScopeEndSym {<br>
+; CHECK: Kind: S_END {{.*}}<br>
+; CHECK: }<br>
+; CHECK: BlockSym {<br>
+; CHECK: Kind: S_BLOCK32 {{.*}}<br>
+; CHECK: BlockName:<br>
+; CHECK: }<br>
+; CHECK: LocalSym {<br>
+; CHECK: VarName: localD<br>
+; CHECK: }<br>
+; CHECK: ScopeEndSym {<br>
+; CHECK: Kind: S_END {{.*}}<br>
+; CHECK: }<br>
+; CHECK: BlockSym {<br>
+; CHECK: Kind: S_BLOCK32 {{.*}}<br>
+; CHECK: BlockName:<br>
+; CHECK: }<br>
+; CHECK: LocalSym {<br>
+; CHECK: VarName: localE<br>
+; CHECK: }<br>
+; CHECK: ScopeEndSym {<br>
+; CHECK: }<br>
+; CHECK: BlockSym {<br>
+; CHECK: Kind: S_BLOCK32 {{.*}}<br>
+; CHECK: BlockName:<br>
+; CHECK: }<br>
+; CHECK: LocalSym {<br>
+; CHECK: VarName: localF<br>
+; CHECK: }<br>
+; CHECK: BlockSym {<br>
+; CHECK: Kind: S_BLOCK32 {{.*}}<br>
+; CHECK: BlockName:<br>
+; CHECK: }<br>
+; CHECK: LocalSym {<br>
+; CHECK: VarName: localG<br>
+; CHECK: }<br>
+; CHECK: ScopeEndSym {<br>
+; CHECK: Kind: S_END {{.*}}<br>
+; CHECK: }<br>
+; CHECK: ScopeEndSym {<br>
+; CHECK: Kind: S_END {{.*}}<br>
+; CHECK: }<br>
+; CHECK: BlockSym {<br>
+; CHECK: Kind: S_BLOCK32 {{.*}}<br>
+; CHECK: BlockName:<br>
+; CHECK: }<br>
+; CHECK: LocalSym {<br>
+; CHECK: VarName: localH<br>
+; CHECK: }<br>
+; CHECK: ScopeEndSym {<br>
+; CHECK: Kind: S_END {{.*}}<br>
+; CHECK: }<br>
+; CHECK: ProcEnd {<br>
+; CHECK: }<br>
+;<br>
+; ModuleID = 'lexicalblock.cxx'<br>
+source_filename = "lexicalblock.cxx"<br>
+target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"<br>
+target triple = "i686-pc-windows-msvc"<br>
+<br>
+; Function Attrs: norecurse nounwind<br>
+define i32 @main(i32 %argc, i8** %argv) #0 !dbg !8 {<br>
+entry:<br>
+ %retval = alloca i32, align 4<br>
+ %argv.addr = alloca i8**, align 4<br>
+ %argc.addr = alloca i32, align 4<br>
+ %localA = alloca i32, align 4<br>
+ %localB = alloca i32, align 4<br>
+ %localC = alloca i32, align 4<br>
+ %localD = alloca i32, align 4<br>
+ %localE = alloca i32, align 4<br>
+ %localF = alloca i32, align 4<br>
+ %localG = alloca i32, align 4<br>
+ %localH = alloca i32, align 4<br>
+ store i32 0, i32* %retval, align 4<br>
+ store i8** %argv, i8*** %argv.addr, align 4, !tbaa !37<br>
+ call void @llvm.dbg.declare(metadata i8*** %argv.addr, metadata !17, metadata !DIExpression()), !dbg !41<br>
+ store i32 %argc, i32* %argc.addr, align 4, !tbaa !42<br>
+ call void @llvm.dbg.declare(metadata i32* %argc.addr, metadata !18, metadata !DIExpression()), !dbg !41<br>
+ %0 = bitcast i32* %localA to i8*, !dbg !44<br>
+ call void @llvm.lifetime.start.p0i8(i64 4, i8* %0) #4, !dbg !44<br>
+ call void @llvm.dbg.declare(metadata i32* %localA, metadata !19, metadata !DIExpression()), !dbg !44<br>
+ store i32 1, i32* %localA, align 4, !dbg !44, !tbaa !42<br>
+ %1 = bitcast i32* %localB to i8*, !dbg !45<br>
+ call void @llvm.lifetime.start.p0i8(i64 4, i8* %1) #4, !dbg !45<br>
+ call void @llvm.dbg.declare(metadata i32* %localB, metadata !20, metadata !DIExpression()), !dbg !45<br>
+ store i32 2, i32* %localB, align 4, !dbg !45, !tbaa !42<br>
+ %2 = load i32, i32* %argc.addr, align 4, !dbg !46, !tbaa !42<br>
+ %cmp = icmp ne i32 %2, 1, !dbg !46<br>
+ %conv = zext i1 %cmp to i32, !dbg !46<br>
+ %tobool = icmp ne i32 %conv, 0, !dbg !46<br>
+ br i1 %tobool, label %if.then, label %if.end, !dbg !46, !prof !47<br>
+<br>
+if.then: ; preds = %entry<br>
+ %3 = bitcast i32* %localC to i8*, !dbg !48<br>
+ call void @llvm.lifetime.start.p0i8(i64 4, i8* %3) #4, !dbg !48<br>
+ call void @llvm.dbg.declare(metadata i32* %localC, metadata !22, metadata !DIExpression()), !dbg !48<br>
+ store i32 3, i32* %localC, align 4, !dbg !48, !tbaa !42<br>
+ %4 = bitcast i32* %localC to i8*, !dbg !49<br>
+ call void @llvm.lifetime.end.p0i8(i64 4, i8* %4) #4, !dbg !49<br>
+ br label %if.end, !dbg !49<br>
+<br>
+if.end: ; preds = %if.then, %entry<br>
+ %5 = bitcast i32* %localB to i8*, !dbg !50<br>
+ call void @llvm.lifetime.end.p0i8(i64 4, i8* %5) #4, !dbg !50<br>
+ %6 = bitcast i32* %localD to i8*, !dbg !51<br>
+ call void @llvm.lifetime.start.p0i8(i64 4, i8* %6) #4, !dbg !51<br>
+ call void @llvm.dbg.declare(metadata i32* %localD, metadata !25, metadata !DIExpression()), !dbg !51<br>
+ store i32 4, i32* %localD, align 4, !dbg !51, !tbaa !42<br>
+ %7 = load i32, i32* %localD, align 4, !dbg !52, !tbaa !42<br>
+ store i32 %7, i32* %localA, align 4, !dbg !52, !tbaa !42<br>
+ %8 = bitcast i32* %localD to i8*, !dbg !53<br>
+ call void @llvm.lifetime.end.p0i8(i64 4, i8* %8) #4, !dbg !53<br>
+ %9 = bitcast i32* %localE to i8*, !dbg !54<br>
+ call void @llvm.lifetime.start.p0i8(i64 4, i8* %9) #4, !dbg !54<br>
+ call void @llvm.dbg.declare(metadata i32* %localE, metadata !27, metadata !DIExpression()), !dbg !54<br>
+ store i32 5, i32* %localE, align 4, !dbg !54, !tbaa !42<br>
+ %10 = load i32, i32* %localE, align 4, !dbg !55, !tbaa !42<br>
+ store i32 %10, i32* %localA, align 4, !dbg !55, !tbaa !42<br>
+ %11 = bitcast i32* %localE to i8*, !dbg !56<br>
+ call void @llvm.lifetime.end.p0i8(i64 4, i8* %11) #4, !dbg !56<br>
+ %12 = bitcast i32* %localF to i8*, !dbg !57<br>
+ call void @llvm.lifetime.start.p0i8(i64 4, i8* %12) #4, !dbg !57<br>
+ call void @llvm.dbg.declare(metadata i32* %localF, metadata !30, metadata !DIExpression()), !dbg !57<br>
+ store i32 6, i32* %localF, align 4, !dbg !57, !tbaa !42<br>
+ %13 = load i32, i32* %localF, align 4, !dbg !58, !tbaa !42<br>
+ store i32 %13, i32* %localA, align 4, !dbg !58, !tbaa !42<br>
+ %14 = bitcast i32* %localG to i8*, !dbg !59<br>
+ call void @llvm.lifetime.start.p0i8(i64 4, i8* %14) #4, !dbg !59<br>
+ call void @llvm.dbg.declare(metadata i32* %localG, metadata !32, metadata !DIExpression()), !dbg !59<br>
+ store i32 7, i32* %localG, align 4, !dbg !59, !tbaa !42<br>
+ %15 = load i32, i32* %localG, align 4, !dbg !60, !tbaa !42<br>
+ store i32 %15, i32* %localA, align 4, !dbg !60, !tbaa !42<br>
+ %16 = bitcast i32* %localG to i8*, !dbg !61<br>
+ call void @llvm.lifetime.end.p0i8(i64 4, i8* %16) #4, !dbg !61<br>
+ %17 = bitcast i32* %localF to i8*, !dbg !62<br>
+ call void @llvm.lifetime.end.p0i8(i64 4, i8* %17) #4, !dbg !62<br>
+ %18 = load i32, i32* %localA, align 4, !dbg !63, !tbaa !42<br>
+ %cmp1 = icmp eq i32 %18, 7, !dbg !63<br>
+ br i1 %cmp1, label %if.then2, label %if.end3, !dbg !63<br>
+<br>
+if.then2: ; preds = %if.end<br>
+ %19 = bitcast i32* %localH to i8*, !dbg !64<br>
+ call void @llvm.lifetime.start.p0i8(i64 4, i8* %19) #4, !dbg !64<br>
+ call void @llvm.dbg.declare(metadata i32* %localH, metadata !34, metadata !DIExpression()), !dbg !64<br>
+ store i32 8, i32* %localH, align 4, !dbg !64, !tbaa !42<br>
+ %20 = load i32, i32* %localH, align 4, !dbg !65, !tbaa !42<br>
+ store i32 %20, i32* %localA, align 4, !dbg !65, !tbaa !42<br>
+ %21 = bitcast i32* %localH to i8*, !dbg !66<br>
+ call void @llvm.lifetime.end.p0i8(i64 4, i8* %21) #4, !dbg !66<br>
+ br label %if.end3, !dbg !66<br>
+<br>
+if.end3: ; preds = %if.then2, %if.end<br>
+ %22 = load i32, i32* %localA, align 4, !dbg !67, !tbaa !42<br>
+ %cmp4 = icmp ne i32 %22, 8, !dbg !67<br>
+ %23 = zext i1 %cmp4 to i64, !dbg !67<br>
+ %cond = select i1 %cmp4, i32 -1, i32 0, !dbg !67<br>
+ %24 = bitcast i32* %localA to i8*, !dbg !68<br>
+ call void @llvm.lifetime.end.p0i8(i64 4, i8* %24) #4, !dbg !68<br>
+ ret i32 %cond, !dbg !67<br>
+}<br>
+<br>
+; Function Attrs: nounwind readnone speculatable<br>
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #1<br>
+<br>
+; Function Attrs: argmemonly nounwind<br>
+declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #2<br>
+<br>
+; Function Attrs: nounwind readnone<br>
+declare i32 @llvm.expect.i32(i32, i32) #3<br>
+<br>
+; Function Attrs: argmemonly nounwind<br>
+declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #2<br>
+<br>
+attributes #0 = { norecurse nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }<br>
+attributes #1 = { nounwind readnone speculatable }<br>
+attributes #2 = { argmemonly nounwind }<br>
+attributes #3 = { nounwind readnone }<br>
+attributes #4 = { nounwind }<br>
+<br>
+!<a href="http://llvm.dbg.cu" rel="noreferrer" target="_blank">llvm.dbg.cu</a> = !{!0}<br>
+!llvm.module.flags = !{!3, !4, !5, !6}<br>
+!llvm.ident = !{!7}<br>
+<br>
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 7.0.0 (trunk)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)<br>
+!1 = !DIFile(filename: "<stdin>", directory: "C:/path/to/directory", checksumkind: CSK_MD5, checksum: "169b810b4f895de9a9e19d8d0634af5d")<br>
+!2 = !{}<br>
+!3 = !{i32 1, !"NumRegisterParameters", i32 0}<br>
+!4 = !{i32 2, !"CodeView", i32 1}<br>
+!5 = !{i32 2, !"Debug Info Version", i32 3}<br>
+!6 = !{i32 1, !"wchar_size", i32 2}<br>
+!7 = !{!"clang version 7.0.0 (trunk)"}<br>
+!8 = distinct !DISubprogram(name: "main", scope: !9, file: !9, line: 1, type: !10, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !16)<br>
+!9 = !DIFile(filename: "lexicalblock.cxx", directory: "C:/path/to/directory", checksumkind: CSK_MD5, checksum: "169b810b4f895de9a9e19d8d0634af5d")<br>
+!10 = !DISubroutineType(types: !11)<br>
+!11 = !{!12, !12, !13}<br>
+!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)<br>
+!13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 32)<br>
+!14 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !15, size: 32)<br>
+!15 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)<br>
+!16 = !{!17, !18, !19, !20, !22, !25, !27, !30, !32, !34}<br>
+!17 = !DILocalVariable(name: "argv", arg: 2, scope: !8, file: !9, line: 1, type: !13)<br>
+!18 = !DILocalVariable(name: "argc", arg: 1, scope: !8, file: !9, line: 1, type: !12)<br>
+!19 = !DILocalVariable(name: "localA", scope: !8, file: !9, line: 2, type: !12)<br>
+!20 = !DILocalVariable(name: "localB", scope: !21, file: !9, line: 5, type: !12)<br>
+!21 = distinct !DILexicalBlock(scope: !8, file: !9, line: 4)<br>
+!22 = !DILocalVariable(name: "localC", scope: !23, file: !9, line: 8, type: !12)<br>
+!23 = distinct !DILexicalBlock(scope: !24, file: !9, line: 7)<br>
+!24 = distinct !DILexicalBlock(scope: !21, file: !9, line: 7)<br>
+!25 = !DILocalVariable(name: "localD", scope: !26, file: !9, line: 13, type: !12)<br>
+!26 = distinct !DILexicalBlock(scope: !8, file: !9, line: 12)<br>
+!27 = !DILocalVariable(name: "localE", scope: !28, file: !9, line: 19, type: !12)<br>
+!28 = distinct !DILexicalBlock(scope: !29, file: !9, line: 18)<br>
+!29 = distinct !DILexicalBlock(scope: !8, file: !9, line: 17)<br>
+!30 = !DILocalVariable(name: "localF", scope: !31, file: !9, line: 25, type: !12)<br>
+!31 = distinct !DILexicalBlock(scope: !8, file: !9, line: 24)<br>
+!32 = !DILocalVariable(name: "localG", scope: !33, file: !9, line: 29, type: !12)<br>
+!33 = distinct !DILexicalBlock(scope: !31, file: !9, line: 28)<br>
+!34 = !DILocalVariable(name: "localH", scope: !35, file: !9, line: 35, type: !12)<br>
+!35 = distinct !DILexicalBlock(scope: !36, file: !9, line: 34)<br>
+!36 = distinct !DILexicalBlock(scope: !8, file: !9, line: 34)<br>
+!37 = !{!38, !38, i64 0}<br>
+!38 = !{!"any pointer", !39, i64 0}<br>
+!39 = !{!"omnipotent char", !40, i64 0}<br>
+!40 = !{!"Simple C++ TBAA"}<br>
+!41 = !DILocation(line: 1, scope: !8)<br>
+!42 = !{!43, !43, i64 0}<br>
+!43 = !{!"int", !39, i64 0}<br>
+!44 = !DILocation(line: 2, scope: !8)<br>
+!45 = !DILocation(line: 5, scope: !21)<br>
+!46 = !DILocation(line: 7, scope: !21)<br>
+!47 = !{!"branch_weights", i32 1, i32 2000}<br>
+!48 = !DILocation(line: 8, scope: !23)<br>
+!49 = !DILocation(line: 9, scope: !23)<br>
+!50 = !DILocation(line: 10, scope: !21)<br>
+!51 = !DILocation(line: 13, scope: !26)<br>
+!52 = !DILocation(line: 14, scope: !26)<br>
+!53 = !DILocation(line: 15, scope: !26)<br>
+!54 = !DILocation(line: 19, scope: !28)<br>
+!55 = !DILocation(line: 20, scope: !28)<br>
+!56 = !DILocation(line: 21, scope: !28)<br>
+!57 = !DILocation(line: 25, scope: !31)<br>
+!58 = !DILocation(line: 26, scope: !31)<br>
+!59 = !DILocation(line: 29, scope: !33)<br>
+!60 = !DILocation(line: 30, scope: !33)<br>
+!61 = !DILocation(line: 31, scope: !33)<br>
+!62 = !DILocation(line: 32, scope: !31)<br>
+!63 = !DILocation(line: 34, scope: !8)<br>
+!64 = !DILocation(line: 35, scope: !35)<br>
+!65 = !DILocation(line: 36, scope: !35)<br>
+!66 = !DILocation(line: 37, scope: !35)<br>
+!67 = !DILocation(line: 39, scope: !8)<br>
+!68 = !DILocation(line: 40, scope: !8)<br>
<br>
Modified: llvm/trunk/test/DebugInfo/COFF/register-variables.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/register-variables.ll?rev=327620&r1=327619&r2=327620&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/register-variables.ll?rev=327620&r1=327619&r2=327620&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/COFF/register-variables.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/COFF/register-variables.ll Thu Mar 15 04:52:17 2018<br>
@@ -61,12 +61,12 @@<br>
; ASM: .cv_def_range .Lfunc_begin0 [[p_ecx_esi]], "A\021\022\000\000\000"<br>
; ASM: .cv_def_range [[p_ecx_esi]] [[func_end]], "A\021\027\000\000\000"<br>
; ASM: .short 4414 # Record kind: S_LOCAL<br>
-; ASM: .asciz "a"<br>
-; ASM: .cv_def_range [[after_getint]] [[after_inc_eax]], "A\021\021\000\000\000"<br>
-; ASM: .short 4414 # Record kind: S_LOCAL<br>
; ASM: .asciz "c"<br>
; ASM: .cv_def_range [[after_getint]] [[after_je]], "A\021\021\000\000\000"<br>
; ASM: .short 4414 # Record kind: S_LOCAL<br>
+; ASM: .asciz "a"<br>
+; ASM: .cv_def_range [[after_getint]] [[after_inc_eax]], "A\021\021\000\000\000"<br>
+; ASM: .short 4414 # Record kind: S_LOCAL<br>
; ASM: .asciz "b"<br>
; ASM: .cv_def_range [[after_inc_eax]] [[after_if]], "A\021\021\000\000\000"<br>
<br>
@@ -111,28 +111,28 @@<br>
; OBJ: Type: int (0x74)<br>
; OBJ: Flags [ (0x0)<br>
; OBJ: ]<br>
-; OBJ: VarName: a<br>
+; OBJ: VarName: c<br>
; OBJ: }<br>
; OBJ: DefRangeRegisterSym {<br>
; OBJ: Register: EAX (0x11)<br>
; OBJ: LocalVariableAddrRange {<br>
; OBJ: OffsetStart: .text+0xC<br>
; OBJ: ISectStart: 0x0<br>
-; OBJ: Range: 0x7<br>
+; OBJ: Range: 0x4<br>
; OBJ: }<br>
; OBJ: }<br>
; OBJ: LocalSym {<br>
; OBJ: Type: int (0x74)<br>
; OBJ: Flags [ (0x0)<br>
; OBJ: ]<br>
-; OBJ: VarName: c<br>
+; OBJ: VarName: a<br>
; OBJ: }<br>
; OBJ: DefRangeRegisterSym {<br>
; OBJ: Register: EAX (0x11)<br>
; OBJ: LocalVariableAddrRange {<br>
; OBJ: OffsetStart: .text+0xC<br>
; OBJ: ISectStart: 0x0<br>
-; OBJ: Range: 0x4<br>
+; OBJ: Range: 0x7<br>
; OBJ: }<br>
; OBJ: }<br>
; OBJ: LocalSym {<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>