Skip to content

Commit a8b41c5

Browse files
authored
Merge pull request llvm#177 from AMD-Lightning-Internal/amd/dev/juamarti/fi_dbg_unexpected_ptr
[AMDGPU][DebugInfo] Drop DIExpression when we encounter something else than a pointer during FrameLowering
2 parents b9526f1 + eb16031 commit a8b41c5

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

llvm/include/llvm/IR/DebugInfoMetadata.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3307,13 +3307,6 @@ class DIExpression : public MDNode {
33073307
->getElements();
33083308
}
33093309

3310-
DIExpression *getPoisoned() const {
3311-
std::optional<FragmentInfo> Frag = getFragmentInfo();
3312-
if (!Frag)
3313-
return DIExpression::get(getContext(), PoisonedExpr);
3314-
return getPoisonedFragment(Frag->OffsetInBits, Frag->SizeInBits);
3315-
}
3316-
33173310
DIExpression(LLVMContext &C, StorageType Storage, ArrayRef<uint64_t> Elements)
33183311
: MDNode(C, DIExpressionKind, Storage, {}),
33193312
Elements(std::in_place_type<OldElements>, Elements.begin(),
@@ -3341,6 +3334,13 @@ class DIExpression : public MDNode {
33413334
}
33423335

33433336
public:
3337+
DIExpression *getPoisoned() const {
3338+
std::optional<FragmentInfo> Frag = getFragmentInfo();
3339+
if (!Frag)
3340+
return DIExpression::get(getContext(), PoisonedExpr);
3341+
return getPoisonedFragment(Frag->OffsetInBits, Frag->SizeInBits);
3342+
}
3343+
33443344
DEFINE_MDNODE_GET(DIExpression, (std::nullopt_t Elements), (Elements))
33453345
DEFINE_MDNODE_GET(DIExpression, (ArrayRef<uint64_t> Elements), (Elements))
33463346
// The bool parameter is ignored, and only present to disambiguate the

llvm/lib/Target/AMDGPU/AMDGPUFrameLowering.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,13 @@ DIExpression *AMDGPUFrameLowering::lowerFIArgToFPArg(const MachineFunction &MF,
101101
if (auto *Arg = std::get_if<DIOp::Arg>(&*I)) {
102102
if (Arg->getIndex() != ArgIndex)
103103
continue;
104+
104105
Type *ResultType = Arg->getResultType();
106+
// Weird case: we expect a pointer but on optimized builds it may not be
107+
// the case.
108+
if (!ResultType->isPointerTy())
109+
return Expr->getPoisoned();
110+
105111
unsigned PointerSizeInBits =
106112
DL.getPointerSizeInBits(ResultType->getPointerAddressSpace());
107113
auto *IntTy = IntegerType::get(Context, PointerSizeInBits);

0 commit comments

Comments
 (0)