<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>