Skip to content

Commit

Permalink
[clang][CodeGen] Remove the signed version of createExpression
Browse files Browse the repository at this point in the history
Fix a TODO. Remove the callers of this signed version and delete.

Reviewed By: CodaFi

Differential Revision: https://reviews.llvm.org/D116014
  • Loading branch information
Shao-Ce SUN committed Dec 27, 2021
1 parent 5d47e7d commit ec501f1
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 21 deletions.
12 changes: 6 additions & 6 deletions clang/lib/CodeGen/CGDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {
auto *LowerBound =
llvm::ConstantAsMetadata::get(llvm::ConstantInt::getSigned(
llvm::Type::getInt64Ty(CGM.getLLVMContext()), 0));
SmallVector<int64_t, 9> Expr(
SmallVector<uint64_t, 9> Expr(
{llvm::dwarf::DW_OP_constu, NumElemsPerVG, llvm::dwarf::DW_OP_bregx,
/* AArch64::VG */ 46, 0, llvm::dwarf::DW_OP_mul,
llvm::dwarf::DW_OP_constu, 1, llvm::dwarf::DW_OP_minus});
Expand Down Expand Up @@ -768,7 +768,7 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {
}

// Element count = (VLENB / SEW) x LMUL
SmallVector<int64_t, 12> Expr(
SmallVector<uint64_t, 12> Expr(
// The DW_OP_bregx operation has two operands: a register which is
// specified by an unsigned LEB128 number, followed by a signed LEB128
// offset.
Expand Down Expand Up @@ -4325,7 +4325,7 @@ void CGDebugInfo::CreateLexicalBlock(SourceLocation Loc) {
}

void CGDebugInfo::AppendAddressSpaceXDeref(
unsigned AddressSpace, SmallVectorImpl<int64_t> &Expr) const {
unsigned AddressSpace, SmallVectorImpl<uint64_t> &Expr) const {
Optional<unsigned> DWARFAddressSpace =
CGM.getTarget().getDWARFAddressSpace(AddressSpace);
if (!DWARFAddressSpace)
Expand Down Expand Up @@ -4494,7 +4494,7 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD,
Line = getLineNumber(VD->getLocation());
Column = getColumnNumber(VD->getLocation());
}
SmallVector<int64_t, 13> Expr;
SmallVector<uint64_t, 13> Expr;
llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
if (VD->isImplicit())
Flags |= llvm::DINode::FlagArtificial;
Expand Down Expand Up @@ -4720,7 +4720,7 @@ void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(
target.getStructLayout(blockInfo.StructureType)
->getElementOffset(blockInfo.getCapture(VD).getIndex()));

SmallVector<int64_t, 9> addr;
SmallVector<uint64_t, 9> addr;
addr.push_back(llvm::dwarf::DW_OP_deref);
addr.push_back(llvm::dwarf::DW_OP_plus_uconst);
addr.push_back(offset.getQuantity());
Expand Down Expand Up @@ -5191,7 +5191,7 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
} else {
auto Align = getDeclAlignIfRequired(D, CGM.getContext());

SmallVector<int64_t, 4> Expr;
SmallVector<uint64_t, 4> Expr;
unsigned AddressSpace =
CGM.getContext().getTargetAddressSpace(D->getType());
if (CGM.getLangOpts().CUDA && CGM.getLangOpts().CUDAIsDevice) {
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGDebugInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ class CGDebugInfo {
/// Extended dereferencing mechanism is has the following format:
/// DW_OP_constu <DWARF Address Space> DW_OP_swap DW_OP_xderef
void AppendAddressSpaceXDeref(unsigned AddressSpace,
SmallVectorImpl<int64_t> &Expr) const;
SmallVectorImpl<uint64_t> &Expr) const;

/// A helper function to collect debug info for the default elements of a
/// block.
Expand Down
2 changes: 1 addition & 1 deletion llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ value llvm_instr_set_debug_loc(LLVMValueRef Inst, LLVMMetadataRef Loc) {
LLVMMetadataRef llvm_dibuild_create_constant_value_expression(value Builder,
value Value) {
return LLVMDIBuilderCreateConstantValueExpression(DIBuilder_val(Builder),
(int64_t)Int_val(Value));
(uint64_t)Int_val(Value));
}

LLVMMetadataRef llvm_dibuild_create_global_variable_expression_native(
Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm-c/DebugInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,7 @@ LLVMMetadataRef LLVMDIBuilderGetOrCreateArray(LLVMDIBuilderRef Builder,
* \param Length Length of the address operation array.
*/
LLVMMetadataRef LLVMDIBuilderCreateExpression(LLVMDIBuilderRef Builder,
int64_t *Addr, size_t Length);
uint64_t *Addr, size_t Length);

/**
* Create a new descriptor for the specified variable that does not have an
Expand All @@ -1112,7 +1112,7 @@ LLVMMetadataRef LLVMDIBuilderCreateExpression(LLVMDIBuilderRef Builder,
*/
LLVMMetadataRef
LLVMDIBuilderCreateConstantValueExpression(LLVMDIBuilderRef Builder,
int64_t Value);
uint64_t Value);

/**
* Create a new descriptor for the specified variable.
Expand Down
1 change: 0 additions & 1 deletion llvm/include/llvm/IR/DIBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,6 @@ namespace llvm {
/// variable which has a complex address expression for its address.
/// \param Addr An array of complex address operations.
DIExpression *createExpression(ArrayRef<uint64_t> Addr = None);
DIExpression *createExpression(ArrayRef<int64_t> Addr);

/// Create an expression for a variable that does not have an address, but
/// does have a constant value.
Expand Down
6 changes: 0 additions & 6 deletions llvm/lib/IR/DIBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -821,12 +821,6 @@ DIExpression *DIBuilder::createExpression(ArrayRef<uint64_t> Addr) {
return DIExpression::get(VMContext, Addr);
}

DIExpression *DIBuilder::createExpression(ArrayRef<int64_t> Signed) {
// TODO: Remove the callers of this signed version and delete.
SmallVector<uint64_t, 8> Addr(Signed.begin(), Signed.end());
return createExpression(Addr);
}

template <class... Ts>
static DISubprogram *getSubprogram(bool IsDistinct, Ts &&...Args) {
if (IsDistinct)
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/IR/DebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1436,14 +1436,14 @@ LLVMDIBuilderCreateSubroutineType(LLVMDIBuilderRef Builder,
}

LLVMMetadataRef LLVMDIBuilderCreateExpression(LLVMDIBuilderRef Builder,
int64_t *Addr, size_t Length) {
return wrap(unwrap(Builder)->createExpression(ArrayRef<int64_t>(Addr,
Length)));
uint64_t *Addr, size_t Length) {
return wrap(
unwrap(Builder)->createExpression(ArrayRef<uint64_t>(Addr, Length)));
}

LLVMMetadataRef
LLVMDIBuilderCreateConstantValueExpression(LLVMDIBuilderRef Builder,
int64_t Value) {
uint64_t Value) {
return wrap(unwrap(Builder)->createConstantValueExpression(Value));
}

Expand Down

1 comment on commit ec501f1

@antondaubert
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.