Skip to content

Commit 870b785

Browse files
authored
Merge pull request #4893 from adrian-prantl/D20147
Update for LLVM API change D20147.
2 parents 224ab4b + 0e9c8e9 commit 870b785

File tree

5 files changed

+14
-16
lines changed

5 files changed

+14
-16
lines changed

lib/IRGen/GenInit.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ Address IRGenModule::emitSILGlobalVariable(SILGlobalVariable *var) {
4141
// just return undef.
4242
if (ti.isKnownEmpty(ResilienceExpansion::Minimal)) {
4343
if (DebugInfo && var->getDecl()) {
44-
auto Zero = llvm::ConstantInt::get(Int64Ty, 0);
4544
DebugTypeInfo DbgTy(var->getDecl(), var->getLoweredType().getSwiftType(),
4645
Int8Ty, Size(0), Alignment(1));
4746
DebugInfo->emitGlobalVariableDeclaration(
48-
Zero, var->getDecl()->getName().str(), "", DbgTy,
47+
nullptr, var->getDecl()->getName().str(), "", DbgTy,
4948
var->getLinkage() != SILLinkage::Public, SILLocation(var->getDecl()));
5049
}
5150
return ti.getUndefAddress();

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,13 +1000,9 @@ void IRGenDebugInfo::emitDbgIntrinsic(llvm::BasicBlock *BB,
10001000
DBuilder.insertDbgValueIntrinsic(Storage, 0, Var, Expr, DL, BB);
10011001
}
10021002

1003-
1004-
void IRGenDebugInfo::emitGlobalVariableDeclaration(llvm::Constant *Var,
1005-
StringRef Name,
1006-
StringRef LinkageName,
1007-
DebugTypeInfo DbgTy,
1008-
bool IsLocalToUnit,
1009-
Optional<SILLocation> Loc) {
1003+
void IRGenDebugInfo::emitGlobalVariableDeclaration(
1004+
llvm::GlobalVariable *Var, StringRef Name, StringRef LinkageName,
1005+
DebugTypeInfo DbgTy, bool IsLocalToUnit, Optional<SILLocation> Loc) {
10101006
if (Opts.DebugInfoKind <= IRGenDebugInfoKind::LineTables)
10111007
return;
10121008

@@ -1022,8 +1018,11 @@ void IRGenDebugInfo::emitGlobalVariableDeclaration(llvm::Constant *Var,
10221018
auto File = getOrCreateFile(L.Filename);
10231019

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

10291028
StringRef IRGenDebugInfo::getMangledName(DebugTypeInfo DbgTy) {

lib/IRGen/IRGenDebugInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ class IRGenDebugInfo {
194194
const SILDebugScope *DS);
195195

196196
/// Create debug metadata for a global variable.
197-
void emitGlobalVariableDeclaration(llvm::Constant *Storage, StringRef Name,
198-
StringRef LinkageName,
197+
void emitGlobalVariableDeclaration(llvm::GlobalVariable *Storage,
198+
StringRef Name, StringRef LinkageName,
199199
DebugTypeInfo DebugType,
200200
bool IsLocalToUnit,
201201
Optional<SILLocation> Loc);

test/DebugInfo/enum.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// RUN: %target-swift-frontend -primary-file %s -emit-ir -g -o - | %FileCheck %s
22
// RUN: %target-swift-frontend -primary-file %s -emit-ir -gdwarf-types -o - | %FileCheck %s --check-prefix=DWARF
33

4-
// CHECK: ![[EMPTY:.*]] = !{}
5-
64
protocol P {}
75

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

test/DebugInfo/nostorage.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ public func app() {
3737
public enum empty { case exists }
3838
public let globalvar = empty.exists
3939
// CHECK3: !DIGlobalVariable(name: "globalvar", {{.*}}line: [[@LINE-1]],
40-
// CHECK3-SAME: isLocal: false, isDefinition: true, variable: i64 0)
40+
// CHECK3-SAME: isLocal: false, isDefinition: true, expr: ![[ZERO:.*]])
41+
// CHECK3: ![[ZERO]] = !DIExpression(DW_OP_constu, 0, DW_OP_stack_value)

0 commit comments

Comments
 (0)