@@ -247,13 +247,6 @@ void DwarfCompileUnit::addLocationAttribute(
247247 DIELoc *Loc = nullptr ;
248248 std::optional<unsigned > NVPTXAddressSpace;
249249 std::unique_ptr<DIEDwarfExpression> DwarfExpr;
250-
251- // Check if this variable is of boolean type
252- bool isBoolean = false ;
253- if (GV && GV->getType ())
254- if (auto *BasicType = dyn_cast<DIBasicType>(GV->getType ()))
255- isBoolean = BasicType->getEncoding () == dwarf::DW_ATE_boolean;
256-
257250 for (const auto &GE : GlobalExprs) {
258251 const GlobalVariable *Global = GE.Var ;
259252 const DIExpression *Expr = GE.Expr ;
@@ -264,17 +257,11 @@ void DwarfCompileUnit::addLocationAttribute(
264257 // DW_AT_const_value(X).
265258 if (GlobalExprs.size () == 1 && Expr && Expr->isConstant ()) {
266259 addToAccelTable = true ;
267-
268- // Determine the value to use, normalizing booleans to 0 or 1
269- int64_t valueToUse = Expr->getElement (1 );
270- if (isBoolean)
271- valueToUse = valueToUse ? 1 : 0 ;
272-
273260 addConstantValue (
274261 *VariableDIE,
275262 DIExpression::SignedOrUnsignedConstant::UnsignedConstant ==
276263 *Expr->isConstant (),
277- valueToUse );
264+ Expr-> getElement ( 1 ) );
278265 break ;
279266 }
280267
@@ -835,22 +822,6 @@ void DwarfCompileUnit::applyConcreteDbgVariableAttributes(
835822 }
836823 if (!DVal->isVariadic ()) {
837824 const DbgValueLocEntry *Entry = DVal->getLocEntries ().begin ();
838-
839- // Helper function to handle boolean constant values with type safety
840- auto addConstantValueWithBooleanNormalization =
841- [&](DIE &VariableDie, uint64_t intValue, const DIType *Type) {
842- if (auto *BasicType = dyn_cast_or_null<DIBasicType>(Type)) {
843- if (BasicType->getEncoding () == dwarf::DW_ATE_boolean) {
844- // Normalize boolean values: any non-zero becomes 1, zero stays 0
845- uint64_t normalizedBoolValue = (intValue) ? 1 : 0 ;
846- addConstantValue (VariableDie, normalizedBoolValue, Type);
847- return ;
848- }
849- }
850- // For non-boolean types, use the original constant value
851- addConstantValue (VariableDie, intValue, Type);
852- };
853-
854825 if (Entry->isLocation ()) {
855826 addVariableAddress (DV, VariableDie, Entry->getLoc ());
856827 } else if (Entry->isInt ()) {
@@ -867,8 +838,7 @@ void DwarfCompileUnit::applyConcreteDbgVariableAttributes(
867838 addUInt (VariableDie, dwarf::DW_AT_LLVM_tag_offset,
868839 dwarf::DW_FORM_data1, *DwarfExpr.TagOffset );
869840 } else
870- addConstantValueWithBooleanNormalization (VariableDie, Entry->getInt (),
871- DV.getType ());
841+ addConstantValue (VariableDie, Entry->getInt (), DV.getType ());
872842 } else if (Entry->isConstantFP ()) {
873843 addConstantFPValue (VariableDie, Entry->getConstantFP ());
874844 } else if (Entry->isConstantInt ()) {
0 commit comments