[PATCH] D39069: CodeGen: Fix missing debug loc due to alloca

Liu, Yaxun (Sam) via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 23 11:20:06 PDT 2017

I will simplify the test. Thanks.


From: David Blaikie [mailto:dblaikie at gmail.com]
Sent: Monday, October 23, 2017 2:08 PM
To: reviews+D39069+public+8da79e110d30366c at reviews.llvm.org; Yaxun Liu via Phabricator <reviews at reviews.llvm.org>; Liu, Yaxun (Sam) <Yaxun.Liu at amd.com>; rjmccall at gmail.com
Cc: cfe-commits at lists.llvm.org
Subject: Re: [PATCH] D39069: CodeGen: Fix missing debug loc due to alloca

What John said, but also a narrower test would be good - checking that the appropriate call instruction gets a debug location, rather than checking that a bunch of inlining doesn't cause the assertion/verifier failure, would be good. (Clang tests should, as much as possible, not rely on or run the LLVM optimization passes - but check the IR coming directly from Clang before any of that)
On Wed, Oct 18, 2017 at 2:15 PM Yaxun Liu via Phabricator via cfe-commits <cfe-commits at lists.llvm.org<mailto:cfe-commits at lists.llvm.org>> wrote:
yaxunl created this revision.

Builder save/restores insertion pointer when emitting addr space cast
for alloca, but does not save/restore debug loc, which causes verifier
failure for certain call instructions.

This patch fixes that.



Index: test/CodeGenOpenCL/func-call-dbg-loc.cl<http://func-call-dbg-loc.cl>
--- /dev/null
+++ test/CodeGenOpenCL/func-call-dbg-loc.cl<http://func-call-dbg-loc.cl>
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple amdgcn---amdgizcl -debug-info-kind=limited -dwarf-version=2 -debugger-tuning=gdb -O0 -emit-llvm -o - %s | FileCheck %s
+// Checks the file compiles without verifier error: inlinable function call in a function with debug info must have a !dbg location.
+typedef struct
+    float m_max;
+} Struct;
+typedef struct
+    Struct m_volume;
+} Node;
+Struct buzz(Node node)
+    return node.m_volume;
+float bar(Struct aabb)
+    return 0.0f;
+void foo()
+    Node node;
+    // CHECK: store float 0.000000e+00, float addrspace(5)* %f, align 4, !dbg !{{[0-9]+}}
+    float f = bar(buzz(node));
Index: lib/CodeGen/CGExpr.cpp
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -75,11 +75,13 @@
   if (CastToDefaultAddrSpace && getASTAllocaAddressSpace() != LangAS::Default) {
     auto DestAddrSpace = getContext().getTargetAddressSpace(LangAS::Default);
     auto CurIP = Builder.saveIP();
+    auto DbgLoc = Builder.getCurrentDebugLocation();
     V = getTargetHooks().performAddrSpaceCast(
         *this, V, getASTAllocaAddressSpace(), LangAS::Default,
         Ty->getPointerTo(DestAddrSpace), /*non-null*/ true);
+    Builder.SetCurrentDebugLocation(DbgLoc);

   return Address(V, Align);

cfe-commits mailing list
cfe-commits at lists.llvm.org<mailto:cfe-commits at lists.llvm.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171023/075f3fd4/attachment-0001.html>

More information about the cfe-commits mailing list