Index: lib/Transforms/Utils/InlineFunction.cpp =================================================================== --- lib/Transforms/Utils/InlineFunction.cpp +++ lib/Transforms/Utils/InlineFunction.cpp @@ -466,7 +466,13 @@ for (BasicBlock::iterator BI = FI->begin(), BE = FI->end(); BI != BE; ++BI) { DebugLoc DL = BI->getDebugLoc(); - if (!DL.isUnknown()) { + if (DL.isUnknown()) { + // If the inlined instruction has no line number, make it look as if it + // originates from the call location. This is important for + // ((__always_inline__, __nodebug__)) functions which must use caller + // location for all instructions in their function body. + BI->setDebugLoc(TheCallDL); + } else { BI->setDebugLoc(updateInlinedAtInfo(DL, TheCallDL, BI->getContext())); if (DbgValueInst *DVI = dyn_cast(BI)) { LLVMContext &Ctx = BI->getContext(); Index: projects/compiler-rt/test/msan/vector_cvt.cc =================================================================== --- projects/compiler-rt/test/msan/vector_cvt.cc +++ projects/compiler-rt/test/msan/vector_cvt.cc @@ -8,7 +8,7 @@ int x = _mm_cvtsd_si32(t); return x; // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value - // CHECK: #{{.*}} in to_int{{.*}}vector_cvt.cc:[[@LINE-4]] + // CHECK: #{{.*}} in to_int{{.*}}vector_cvt.cc:[[@LINE-3]] } int main() { Index: test/Transforms/Inline/inline-line-numbers.ll =================================================================== --- test/Transforms/Inline/inline-line-numbers.ll +++ test/Transforms/Inline/inline-line-numbers.ll @@ -0,0 +1,65 @@ +; RUN: opt < %s -inline -S | FileCheck %s + +; This was generated from the following source: +; int a, b; +; void callee() { a = 1; b = 2; } +; void caller() { callee(); } +; by running +; clang -S test.c -emit-llvm -O1 -gline-tables-only -fno-strict-aliasing +; and manually removing !dbg metadata from the first store instruction. + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +@a = common global i32 0, align 4 +@b = common global i32 0, align 4 + +; Function Attrs: nounwind uwtable +define void @callee() #0 { +entry: + store i32 1, i32* @a, align 4 + store i32 2, i32* @b, align 4, !dbg !11 + ret void, !dbg !11 +} + +; Function Attrs: nounwind uwtable +define void @caller() #0 { +entry: + tail call void @callee(), !dbg !12 + ret void, !dbg !12 +} + +; CHECK-LABEL: @caller( + +; This instruction did not have a !dbg metadata in the callee. +; CHECK: store i32 1, {{.*}}, !dbg [[A:!.*]] + +; This instruction came from callee with a !dbg metadata. +; CHECK: store i32 2, {{.*}}, !dbg [[B:!.*]] + +; The remaining instruction from the caller. +; CHECK: ret void, !dbg [[A]] + +; Debug location of the inlined code. +; CHECK-DAG: [[B]] = metadata !{i32 3, i32 0, metadata !{{[01-9]+}}, metadata !{{[01-9]+}}} + + +attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!8, !9} +!llvm.ident = !{!10} + +!0 = metadata !{i32 786449, metadata !1, i32 12, metadata !"clang version 3.5.0 (210008)", i1 true, metadata !"", i32 0, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2, metadata !"", i32 2} ; [ DW_TAG_compile_unit ] [/code/llvm/build0/../2.c] [DW_LANG_C99] +!1 = metadata !{metadata !"../2.c", metadata !"/code/llvm/build0"} +!2 = metadata !{} +!3 = metadata !{metadata !4, metadata !7} +!4 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"callee", metadata !"callee", metadata !"", i32 3, metadata !6, i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 true, void ()* @callee, null, null, metadata !2, i32 3} ; [ DW_TAG_subprogram ] [line 3] [def] [callee] +!5 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ] [/code/llvm/build0/../2.c] +!6 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !2, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!7 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"caller", metadata !"caller", metadata !"", i32 4, metadata !6, i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 true, void ()* @caller, null, null, metadata !2, i32 4} ; [ DW_TAG_subprogram ] [line 4] [def] [caller] +!8 = metadata !{i32 2, metadata !"Dwarf Version", i32 4} +!9 = metadata !{i32 2, metadata !"Debug Info Version", i32 1} +!10 = metadata !{metadata !"clang version 3.5.0 (210008)"} +!11 = metadata !{i32 3, i32 0, metadata !4, null} +!12 = metadata !{i32 4, i32 0, metadata !7, null} Index: tools/clang/test/CodeGen/sse-builtins.c =================================================================== --- tools/clang/test/CodeGen/sse-builtins.c +++ tools/clang/test/CodeGen/sse-builtins.c @@ -6,7 +6,7 @@ __m128 test_rsqrt_ss(__m128 x) { // CHECK: define {{.*}} @test_rsqrt_ss - // CHECK: call <4 x float> @llvm.x86.sse.rsqrt.ss + // CHECK: call <4 x float> @llvm.x86.sse.rsqrt.ss{{.*}}, !dbg // CHECK: extractelement <4 x float> {{.*}}, i32 0 // CHECK: extractelement <4 x float> {{.*}}, i32 1 // CHECK: extractelement <4 x float> {{.*}}, i32 2 @@ -16,7 +16,7 @@ __m128 test_rcp_ss(__m128 x) { // CHECK: define {{.*}} @test_rcp_ss - // CHECK: call <4 x float> @llvm.x86.sse.rcp.ss + // CHECK: call <4 x float> @llvm.x86.sse.rcp.ss{{.*}}, !dbg // CHECK: extractelement <4 x float> {{.*}}, i32 0 // CHECK: extractelement <4 x float> {{.*}}, i32 1 // CHECK: extractelement <4 x float> {{.*}}, i32 2 @@ -26,7 +26,7 @@ __m128 test_sqrt_ss(__m128 x) { // CHECK: define {{.*}} @test_sqrt_ss - // CHECK: call <4 x float> @llvm.x86.sse.sqrt.ss + // CHECK: call <4 x float> @llvm.x86.sse.sqrt.ss{{.*}}, !dbg // CHECK: extractelement <4 x float> {{.*}}, i32 0 // CHECK: extractelement <4 x float> {{.*}}, i32 1 // CHECK: extractelement <4 x float> {{.*}}, i32 2 @@ -36,7 +36,7 @@ __m128 test_loadl_pi(__m128 x, void* y) { // CHECK: define {{.*}} @test_loadl_pi - // CHECK: load <2 x float>* {{.*}}, align 1{{$}} + // CHECK: load <2 x float>* {{.*}}, align 1, !dbg // CHECK: shufflevector {{.*}} <4 x i32> return _mm_loadl_pi(x,y); @@ -44,7 +44,7 @@ __m128 test_loadh_pi(__m128 x, void* y) { // CHECK: define {{.*}} @test_loadh_pi - // CHECK: load <2 x float>* {{.*}}, align 1{{$}} + // CHECK: load <2 x float>* {{.*}}, align 1, !dbg // CHECK: shufflevector {{.*}} <4 x i32> return _mm_loadh_pi(x,y); @@ -52,206 +52,206 @@ __m128 test_load_ss(void* y) { // CHECK: define {{.*}} @test_load_ss - // CHECK: load float* {{.*}}, align 1{{$}} + // CHECK: load float* {{.*}}, align 1, !dbg return _mm_load_ss(y); } __m128 test_load1_ps(void* y) { // CHECK: define {{.*}} @test_load1_ps - // CHECK: load float* {{.*}}, align 1{{$}} + // CHECK: load float* {{.*}}, align 1, !dbg return _mm_load1_ps(y); } void test_store_ss(__m128 x, void* y) { // CHECK-LABEL: define void @test_store_ss - // CHECK: store {{.*}} float* {{.*}}, align 1, + // CHECK: store {{.*}} float* {{.*}}, align 1, !dbg _mm_store_ss(y, x); } __m128d test_load1_pd(__m128 x, void* y) { // CHECK: define {{.*}} @test_load1_pd - // CHECK: load double* {{.*}}, align 1{{$}} + // CHECK: load double* {{.*}}, align 1, !dbg return _mm_load1_pd(y); } __m128d test_loadr_pd(__m128 x, void* y) { // CHECK: define {{.*}} @test_loadr_pd - // CHECK: load <2 x double>* {{.*}}, align 16{{$}} + // CHECK: load <2 x double>* {{.*}}, align 16, !dbg return _mm_loadr_pd(y); } __m128d test_load_sd(void* y) { // CHECK: define {{.*}} @test_load_sd - // CHECK: load double* {{.*}}, align 1{{$}} + // CHECK: load double* {{.*}}, align 1, !dbg return _mm_load_sd(y); } __m128d test_loadh_pd(__m128d x, void* y) { // CHECK: define {{.*}} @test_loadh_pd - // CHECK: load double* {{.*}}, align 1{{$}} + // CHECK: load double* {{.*}}, align 1, !dbg return _mm_loadh_pd(x, y); } __m128d test_loadl_pd(__m128d x, void* y) { // CHECK: define {{.*}} @test_loadl_pd - // CHECK: load double* {{.*}}, align 1{{$}} + // CHECK: load double* {{.*}}, align 1, !dbg return _mm_loadl_pd(x, y); } void test_store_sd(__m128d x, void* y) { // CHECK-LABEL: define void @test_store_sd - // CHECK: store {{.*}} double* {{.*}}, align 1{{$}} + // CHECK: store {{.*}} double* {{.*}}, align 1, !dbg _mm_store_sd(y, x); } void test_store1_pd(__m128d x, void* y) { // CHECK-LABEL: define void @test_store1_pd - // CHECK: store {{.*}} double* {{.*}}, align 1{{$}} - // CHECK: store {{.*}} double* {{.*}}, align 1{{$}} + // CHECK: store {{.*}} double* {{.*}}, align 1, !dbg + // CHECK: store {{.*}} double* {{.*}}, align 1, !dbg _mm_store1_pd(y, x); } void test_storer_pd(__m128d x, void* y) { // CHECK-LABEL: define void @test_storer_pd - // CHECK: store {{.*}} <2 x double>* {{.*}}, align 16{{$}} + // CHECK: store {{.*}} <2 x double>* {{.*}}, align 16, !dbg _mm_storer_pd(y, x); } void test_storeh_pd(__m128d x, void* y) { // CHECK-LABEL: define void @test_storeh_pd - // CHECK: store {{.*}} double* {{.*}}, align 1{{$}} + // CHECK: store {{.*}} double* {{.*}}, align 1, !dbg _mm_storeh_pd(y, x); } void test_storel_pd(__m128d x, void* y) { // CHECK-LABEL: define void @test_storel_pd - // CHECK: store {{.*}} double* {{.*}}, align 1{{$}} + // CHECK: store {{.*}} double* {{.*}}, align 1, !dbg _mm_storel_pd(y, x); } __m128i test_loadl_epi64(void* y) { // CHECK: define {{.*}} @test_loadl_epi64 - // CHECK: load i64* {{.*}}, align 1{{$}} + // CHECK: load i64* {{.*}}, align 1, !dbg return _mm_loadl_epi64(y); } __m128i test_mm_minpos_epu16(__m128i x) { // CHECK: define {{.*}} @test_mm_minpos_epu16 - // CHECK: @llvm.x86.sse41.phminposuw + // CHECK: @llvm.x86.sse41.phminposuw{{.*}}, !dbg return _mm_minpos_epu16(x); } __m128i test_mm_mpsadbw_epu8(__m128i x, __m128i y) { // CHECK: define {{.*}} @test_mm_mpsadbw_epu8 - // CHECK: @llvm.x86.sse41.mpsadbw + // CHECK: @llvm.x86.sse41.mpsadbw{{.*}}, !dbg return _mm_mpsadbw_epu8(x, y, 1); } __m128 test_mm_dp_ps(__m128 x, __m128 y) { // CHECK: define {{.*}} @test_mm_dp_ps - // CHECK: @llvm.x86.sse41.dpps + // CHECK: @llvm.x86.sse41.dpps{{.*}}, !dbg return _mm_dp_ps(x, y, 2); } __m128d test_mm_dp_pd(__m128d x, __m128d y) { // CHECK: define {{.*}} @test_mm_dp_pd - // CHECK: @llvm.x86.sse41.dppd + // CHECK: @llvm.x86.sse41.dppd{{.*}}, !dbg return _mm_dp_pd(x, y, 2); } __m128 test_mm_round_ps(__m128 x) { // CHECK: define {{.*}} @test_mm_round_ps - // CHECK: @llvm.x86.sse41.round.ps + // CHECK: @llvm.x86.sse41.round.ps{{.*}}, !dbg return _mm_round_ps(x, 2); } __m128 test_mm_round_ss(__m128 x, __m128 y) { // CHECK: define {{.*}} @test_mm_round_ss - // CHECK: @llvm.x86.sse41.round.ss + // CHECK: @llvm.x86.sse41.round.ss{{.*}}, !dbg return _mm_round_ss(x, y, 2); } __m128d test_mm_round_pd(__m128d x) { // CHECK: define {{.*}} @test_mm_round_pd - // CHECK: @llvm.x86.sse41.round.pd + // CHECK: @llvm.x86.sse41.round.pd{{.*}}, !dbg return _mm_round_pd(x, 2); } __m128d test_mm_round_sd(__m128d x, __m128d y) { // CHECK: define {{.*}} @test_mm_round_sd - // CHECK: @llvm.x86.sse41.round.sd + // CHECK: @llvm.x86.sse41.round.sd{{.*}}, !dbg return _mm_round_sd(x, y, 2); } void test_storel_epi64(__m128i x, void* y) { // CHECK-LABEL: define void @test_storel_epi64 - // CHECK: store {{.*}} i64* {{.*}}, align 1{{$}} + // CHECK: store {{.*}} i64* {{.*}}, align 1, !dbg _mm_storel_epi64(y, x); } void test_stream_si32(int x, void *y) { // CHECK-LABEL: define void @test_stream_si32 - // CHECK: store {{.*}} i32* {{.*}}, align 1, !nontemporal + // CHECK: store {{.*}} i32* {{.*}}, align 1, !dbg !{{.*}}, !nontemporal _mm_stream_si32(y, x); } void test_stream_si64(long long x, void *y) { // CHECK-LABEL: define void @test_stream_si64 - // CHECK: store {{.*}} i64* {{.*}}, align 1, !nontemporal + // CHECK: store {{.*}} i64* {{.*}}, align 1, !dbg !{{.*}}, !nontemporal _mm_stream_si64(y, x); } void test_stream_si128(__m128i x, void *y) { // CHECK-LABEL: define void @test_stream_si128 - // CHECK: store {{.*}} <2 x i64>* {{.*}}, align 16, !nontemporal + // CHECK: store {{.*}} <2 x i64>* {{.*}}, align 16, !dbg !{{.*}}, !nontemporal _mm_stream_si128(y, x); } void test_extract_epi16(__m128i __a) { // CHECK-LABEL: define void @test_extract_epi16 // CHECK: [[x:%.*]] = and i32 %{{.*}}, 7 - // CHECK: extractelement <8 x i16> %{{.*}}, i32 [[x]] + // CHECK: extractelement <8 x i16> %{{.*}}, i32 [[x]], !dbg _mm_extract_epi16(__a, 8); } int test_extract_ps(__m128i __a) { // CHECK-LABEL: @test_extract_ps - // CHECK: extractelement <4 x float> %{{.*}}, i32 0 + // CHECK: extractelement <4 x float> %{{.*}}, i32 0, !dbg return _mm_extract_ps(__a, 4); } int test_extract_epi8(__m128i __a) { // CHECK-LABEL: @test_extract_epi8 - // CHECK: extractelement <16 x i8> %{{.*}}, i32 0 + // CHECK: extractelement <16 x i8> %{{.*}}, i32 0, !dbg return _mm_extract_epi8(__a, 16); } int test_extract_epi32(__m128i __a) { // CHECK-LABEL: @test_extract_epi32 - // CHECK: extractelement <4 x i32> %{{.*}}, i32 0 + // CHECK: extractelement <4 x i32> %{{.*}}, i32 0, !dbg return _mm_extract_epi32(__a, 4); } void test_insert_epi32(__m128i __a, int b) { // CHECK-LABEL: @test_insert_epi32 - // CHECK: insertelement <4 x i32> %{{.*}}, i32 %{{.*}}, i32 0 + // CHECK: insertelement <4 x i32> %{{.*}}, i32 %{{.*}}, i32 0, !dbg _mm_insert_epi32(__a, b, 4); } __m128d test_blend_pd(__m128d V1, __m128d V2) { // CHECK-LABEL: @test_blend_pd - // CHECK: shufflevector <2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x i32> + // CHECK: shufflevector <2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x i32> , !dbg return _mm_blend_pd(V1, V2, 1); } __m128 test_blend_ps(__m128 V1, __m128 V2) { // CHECK-LABEL: @test_blend_ps - // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> + // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x i32> , !dbg return _mm_blend_ps(V1, V2, 5); } __m128i test_blend_epi16(__m128i V1, __m128i V2) { // CHECK-LABEL: @test_blend_epi16 - // CHECK: shufflevector <8 x i16> %{{.*}}, <8 x i16> %{{.*}}, <8 x i32> + // CHECK: shufflevector <8 x i16> %{{.*}}, <8 x i16> %{{.*}}, <8 x i32> , !dbg return _mm_blend_epi16(V1, V2, 42); }