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(); Builder.SetInsertPoint(AllocaInsertPt); V = getTargetHooks().performAddrSpaceCast( *this, V, getASTAllocaAddressSpace(), LangAS::Default, Ty->getPointerTo(DestAddrSpace), /*non-null*/ true); Builder.restoreIP(CurIP); + Builder.SetCurrentDebugLocation(DbgLoc); } return Address(V, Align); Index: test/CodeGenOpenCL/func-call-dbg-loc.cl =================================================================== --- /dev/null +++ test/CodeGenOpenCL/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; +} + +__attribute__((always_inline)) +float bar(Struct aabb) +{ + return 0.0f; +} + +__attribute__((used)) +void foo() +{ + Node node; + // CHECK: store float 0.000000e+00, float addrspace(5)* %f, align 4, !dbg !{{[0-9]+}} + float f = bar(buzz(node)); +} + +