diff options
author | Sanne Wouda <sanne.wouda@arm.com> | 2017-02-28 10:34:48 +0000 |
---|---|---|
committer | Sanne Wouda <sanne.wouda@arm.com> | 2017-02-28 10:34:48 +0000 |
commit | 98f027501d2763cfff1f3b87a8029472e026cf25 (patch) | |
tree | 33ab6468395dca8621bed289e0dc0c7957939817 | |
parent | 4fb6748cca7a7ae12c689da81ae4d3e191d69d27 (diff) | |
download | bcm5719-llvm-98f027501d2763cfff1f3b87a8029472e026cf25.tar.gz bcm5719-llvm-98f027501d2763cfff1f3b87a8029472e026cf25.zip |
[Assembler] Add test for !srcloc references in assembler diags
Summary:
clang adds !srcloc metadata to inline assembly in LLVM bitcode generated
for inline assembly in C. The value of this !srcloc is passed to the
diagnostics handler if the inline assembly generates a diagnostic.
clang is able to turn this cookie back to a location in the C source
file.
To test this functionality without a dependency, make llc print the
!srcloc metadata if it is present. The added test uses this mechanism
to test that the correct !srclocs are passed to the diag handler.
Reviewers: rengolin, rnk, echristo, grosbach, mehdi_amini
Reviewed By: mehdi_amini
Subscribers: mehdi_amini, llvm-commits
Differential Revision: https://reviews.llvm.org/D30167
llvm-svn: 296465
-rw-r--r-- | llvm/test/MC/ARM/inline-asm-srcloc.ll | 37 | ||||
-rw-r--r-- | llvm/tools/llc/llc.cpp | 6 |
2 files changed, 42 insertions, 1 deletions
diff --git a/llvm/test/MC/ARM/inline-asm-srcloc.ll b/llvm/test/MC/ARM/inline-asm-srcloc.ll new file mode 100644 index 00000000000..9fb9c5b4ef9 --- /dev/null +++ b/llvm/test/MC/ARM/inline-asm-srcloc.ll @@ -0,0 +1,37 @@ +; RUN: not llc -filetype=obj 2>&1 -o /dev/null < %s | FileCheck %s + +; ModuleID = '/scratch/llvm/master/tools/clang/test/Misc/inline-asm-diags.c' +source_filename = "/scratch/llvm/master/tools/clang/test/Misc/inline-asm-diags.c" +target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" +target triple = "armv7-arm-none-eabi" + +; Function Attrs: noinline nounwind +define void @foo2() #0 { +entry: + call void asm sideeffect " wibble", ""() #1, !srcloc !3 +; CHECK: note: !srcloc = 107 + ret void +} + +; Function Attrs: noinline nounwind +define void @foo() #0 { +entry: + call void asm sideeffect " .word -bar", ""() #1, !srcloc !4 +; CHECK: note: !srcloc = 181 + call void asm sideeffect " .word -foo", ""() #1, !srcloc !5 +; CHECK: note: !srcloc = 257 + ret void +} + +attributes #0 = { noinline nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="cortex-a8" "target-features"="+dsp,+neon,+strict-align,+vfp3" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { nounwind } + +!llvm.module.flags = !{!0, !1} +!llvm.ident = !{!2} + +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 1, !"min_enum_size", i32 4} +!2 = !{!"clang version 5.0.0 "} +!3 = !{i32 107} +!4 = !{i32 181} +!5 = !{i32 257} diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp index b8c613d5099..43f97f112f6 100644 --- a/llvm/tools/llc/llc.cpp +++ b/llvm/tools/llc/llc.cpp @@ -254,12 +254,16 @@ static void DiagnosticHandler(const DiagnosticInfo &DI, void *Context) { } static void InlineAsmDiagHandler(const SMDiagnostic &SMD, void *Context, - unsigned) { + unsigned LocCookie) { bool *HasError = static_cast<bool *>(Context); if (SMD.getKind() == SourceMgr::DK_Error) *HasError = true; SMD.print(nullptr, errs()); + + // For testing purposes, we print the LocCookie here. + if (LocCookie) + errs() << "note: !srcloc = " << LocCookie << "\n"; } // main - Entry point for the llc compiler. |