@@ -1002,14 +1002,7 @@ void IRGenDebugInfo::emitVariableDeclaration(
1002
1002
1003
1003
// Create the descriptor for the variable.
1004
1004
llvm::DILocalVariable *Var = nullptr ;
1005
- llvm::DIExpression *Expr = DBuilder.createExpression ();
1006
1005
1007
- if (Indirection) {
1008
- // Classes are always passed by reference.
1009
- int64_t Addr[] = { llvm::dwarf::DW_OP_deref };
1010
- Expr = DBuilder.createExpression (Addr);
1011
- // FIXME: assert(Flags == 0 && "Complex variables cannot have flags");
1012
- }
1013
1006
// / This could be Opts.Optimize if we would also unique DIVariables here.
1014
1007
bool Optimized = false ;
1015
1008
Var = (ArgNo > 0 )
@@ -1027,6 +1020,10 @@ void IRGenDebugInfo::emitVariableDeclaration(
1027
1020
ElementSizes EltSizes (DITy, DIRefMap, IndirectEnumCases);
1028
1021
auto Dim = EltSizes.getNext ();
1029
1022
for (llvm::Value *Piece : Storage) {
1023
+ SmallVector<uint64_t , 3 > Operands;
1024
+ if (Indirection)
1025
+ Operands.push_back (llvm::dwarf::DW_OP_deref);
1026
+
1030
1027
// There are variables without storage, such as "struct { func foo() {} }".
1031
1028
// Emit them as constant 0.
1032
1029
if (isa<llvm::UndefValue>(Piece))
@@ -1053,27 +1050,25 @@ void IRGenDebugInfo::emitVariableDeclaration(
1053
1050
assert (Dim.SizeInBits < VarSizeInBits
1054
1051
&& " piece covers entire var" );
1055
1052
assert (OffsetInBits+Dim.SizeInBits <= VarSizeInBits && " pars > totum" );
1056
- SmallVector<uint64_t , 3 > Elts;
1057
- if (Indirection)
1058
- Elts.push_back (llvm::dwarf::DW_OP_deref);
1059
- Elts.push_back (llvm::dwarf::DW_OP_bit_piece);
1060
- Elts.push_back (OffsetInBits);
1061
- Elts.push_back (Dim.SizeInBits );
1062
- Expr = DBuilder.createExpression (Elts);
1053
+ Operands.push_back (llvm::dwarf::DW_OP_bit_piece);
1054
+ Operands.push_back (OffsetInBits);
1055
+ Operands.push_back (Dim.SizeInBits );
1063
1056
1064
1057
auto Size = Dim.SizeInBits ;
1065
1058
Dim = EltSizes.getNext ();
1066
1059
OffsetInBits +=
1067
1060
llvm::RoundUpToAlignment (Size, Dim.AlignInBits ? Dim.AlignInBits
1068
1061
: SizeOfByte);
1069
1062
}
1070
- emitDbgIntrinsic (BB, Piece, Var, Expr, Line, Loc.Col , Scope, DS);
1063
+ emitDbgIntrinsic (BB, Piece, Var, DBuilder.createExpression (Operands), Line,
1064
+ Loc.Col , Scope, DS);
1071
1065
}
1072
1066
1073
1067
// Emit locationless intrinsic for variables that were optimized away.
1074
1068
if (Storage.size () == 0 ) {
1075
1069
auto *undef = llvm::UndefValue::get (DbgTy.StorageType );
1076
- emitDbgIntrinsic (BB, undef, Var, Expr, Line, Loc.Col , Scope, DS);
1070
+ emitDbgIntrinsic (BB, undef, Var, DBuilder.createExpression (), Line, Loc.Col ,
1071
+ Scope, DS);
1077
1072
}
1078
1073
}
1079
1074
0 commit comments