Skip to content

Commit 0208a6e

Browse files
kzhuravljmmartinez
andauthored
[AMDGPU][DebugInfo] Drop DIExpression we encounter something else tha… (#265)
…n a pointer during FrameLowering Only happens during optimized builds (the DIExpression is not dropped with -O0). This is a workaround, since rocthurst crashes. Did not have the time to root cause the issue. Fixes SWDEV-508902 Co-authored-by: Juan Manuel Martinez Caamaño <[email protected]>
1 parent 9f412b0 commit 0208a6e

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
@@ -3244,13 +3244,6 @@ class DIExpression : public MDNode {
32443244
->getElements();
32453245
}
32463246

3247-
DIExpression *getPoisoned() const {
3248-
std::optional<FragmentInfo> Frag = getFragmentInfo();
3249-
if (!Frag)
3250-
return DIExpression::get(getContext(), PoisonedExpr);
3251-
return getPoisonedFragment(Frag->OffsetInBits, Frag->SizeInBits);
3252-
}
3253-
32543247
DIExpression(LLVMContext &C, StorageType Storage, ArrayRef<uint64_t> Elements)
32553248
: MDNode(C, DIExpressionKind, Storage, std::nullopt),
32563249
Elements(std::in_place_type<OldElements>, Elements.begin(),
@@ -3278,6 +3271,13 @@ class DIExpression : public MDNode {
32783271
}
32793272

32803273
public:
3274+
DIExpression *getPoisoned() const {
3275+
std::optional<FragmentInfo> Frag = getFragmentInfo();
3276+
if (!Frag)
3277+
return DIExpression::get(getContext(), PoisonedExpr);
3278+
return getPoisonedFragment(Frag->OffsetInBits, Frag->SizeInBits);
3279+
}
3280+
32813281
DEFINE_MDNODE_GET(DIExpression, (std::nullopt_t Elements), (Elements))
32823282
DEFINE_MDNODE_GET(DIExpression, (ArrayRef<uint64_t> Elements), (Elements))
32833283
// 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)