Skip to content

Update for LLVM API change D20147. #4893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/IRGen/GenInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ Address IRGenModule::emitSILGlobalVariable(SILGlobalVariable *var) {
// just return undef.
if (ti.isKnownEmpty(ResilienceExpansion::Minimal)) {
if (DebugInfo && var->getDecl()) {
auto Zero = llvm::ConstantInt::get(Int64Ty, 0);
DebugTypeInfo DbgTy(var->getDecl(), var->getLoweredType().getSwiftType(),
Int8Ty, Size(0), Alignment(1));
DebugInfo->emitGlobalVariableDeclaration(
Zero, var->getDecl()->getName().str(), "", DbgTy,
nullptr, var->getDecl()->getName().str(), "", DbgTy,
var->getLinkage() != SILLinkage::Public, SILLocation(var->getDecl()));
}
return ti.getUndefAddress();
Expand Down
17 changes: 8 additions & 9 deletions lib/IRGen/IRGenDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -999,13 +999,9 @@ void IRGenDebugInfo::emitDbgIntrinsic(llvm::BasicBlock *BB,
DBuilder.insertDbgValueIntrinsic(Storage, 0, Var, Expr, DL, BB);
}


void IRGenDebugInfo::emitGlobalVariableDeclaration(llvm::Constant *Var,
StringRef Name,
StringRef LinkageName,
DebugTypeInfo DbgTy,
bool IsLocalToUnit,
Optional<SILLocation> Loc) {
void IRGenDebugInfo::emitGlobalVariableDeclaration(
llvm::GlobalVariable *Var, StringRef Name, StringRef LinkageName,
DebugTypeInfo DbgTy, bool IsLocalToUnit, Optional<SILLocation> Loc) {
if (Opts.DebugInfoKind <= IRGenDebugInfoKind::LineTables)
return;

Expand All @@ -1021,8 +1017,11 @@ void IRGenDebugInfo::emitGlobalVariableDeclaration(llvm::Constant *Var,
auto File = getOrCreateFile(L.Filename);

// Emit it as global variable of the current module.
DBuilder.createGlobalVariable(MainModule, Name, LinkageName, File, L.Line, Ty,
IsLocalToUnit, Var, nullptr);
auto *Expr = Var ? nullptr : DBuilder.createConstantValueExpression(0);
auto *GV = DBuilder.createGlobalVariable(MainModule, Name, LinkageName, File,
L.Line, Ty, IsLocalToUnit, Expr);
if (Var)
Var->addDebugInfo(GV);
}

StringRef IRGenDebugInfo::getMangledName(DebugTypeInfo DbgTy) {
Expand Down
4 changes: 2 additions & 2 deletions lib/IRGen/IRGenDebugInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ class IRGenDebugInfo {
const SILDebugScope *DS);

/// Create debug metadata for a global variable.
void emitGlobalVariableDeclaration(llvm::Constant *Storage, StringRef Name,
StringRef LinkageName,
void emitGlobalVariableDeclaration(llvm::GlobalVariable *Storage,
StringRef Name, StringRef LinkageName,
DebugTypeInfo DebugType,
bool IsLocalToUnit,
Optional<SILLocation> Loc);
Expand Down
3 changes: 1 addition & 2 deletions test/DebugInfo/enum.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// RUN: %target-swift-frontend -primary-file %s -emit-ir -g -o - | %FileCheck %s
// RUN: %target-swift-frontend -primary-file %s -emit-ir -gdwarf-types -o - | %FileCheck %s --check-prefix=DWARF

// CHECK: ![[EMPTY:.*]] = !{}

protocol P {}

enum Either {
Expand All @@ -11,6 +9,7 @@ enum Either {
// CHECK-SAME: line: [[@LINE-3]],
// CHECK-SAME: size: {{328|168}},
}
// CHECK: ![[EMPTY:.*]] = !{}
// DWARF: ![[INT:.*]] = !DICompositeType({{.*}}identifier: "_TtSi"
let E : Either = .Neither;

Expand Down
3 changes: 2 additions & 1 deletion test/DebugInfo/nostorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ public func app() {
public enum empty { case exists }
public let globalvar = empty.exists
// CHECK3: !DIGlobalVariable(name: "globalvar", {{.*}}line: [[@LINE-1]],
// CHECK3-SAME: isLocal: false, isDefinition: true, variable: i64 0)
// CHECK3-SAME: isLocal: false, isDefinition: true, expr: ![[ZERO:.*]])
// CHECK3: ![[ZERO]] = !DIExpression(DW_OP_constu, 0, DW_OP_stack_value)