From 5fa8186b8dcc0be77f4ab64b1ef46ad919315b54 Mon Sep 17 00:00:00 2001 From: Daniel Malea Date: Fri, 28 Jun 2013 20:37:20 +0000 Subject: Adding tests for DebugIR pass - lit tests verify that each line of input LLVM IR gets a !dbg node and a corresponding entry of metadata that contains the line number - unit tests verify that DebugIR works as advertised in the interface - refactored some useful IR generation functionality from the MCJIT unit tests so it can be reused git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185212 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Transforms/DebugIR/crash.ll | 42 +++++++++++ test/Transforms/DebugIR/exception.ll | 127 ++++++++++++++++++++++++++++++++++ test/Transforms/DebugIR/function.ll | 51 ++++++++++++++ test/Transforms/DebugIR/lit.local.cfg | 1 + test/Transforms/DebugIR/simple.ll | 25 +++++++ test/Transforms/DebugIR/struct.ll | 24 +++++++ test/Transforms/DebugIR/vector.ll | 93 +++++++++++++++++++++++++ 7 files changed, 363 insertions(+) create mode 100644 test/Transforms/DebugIR/crash.ll create mode 100644 test/Transforms/DebugIR/exception.ll create mode 100644 test/Transforms/DebugIR/function.ll create mode 100644 test/Transforms/DebugIR/lit.local.cfg create mode 100644 test/Transforms/DebugIR/simple.ll create mode 100644 test/Transforms/DebugIR/struct.ll create mode 100644 test/Transforms/DebugIR/vector.ll (limited to 'test/Transforms/DebugIR') diff --git a/test/Transforms/DebugIR/crash.ll b/test/Transforms/DebugIR/crash.ll new file mode 100644 index 0000000000..f4a88d7234 --- /dev/null +++ b/test/Transforms/DebugIR/crash.ll @@ -0,0 +1,42 @@ +; ModuleID = 'crash.c' +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-pc-linux-gnu" + +@.str = private unnamed_addr constant [18 x i8] c"Hello, segfault!\0A\00", align 1 +@.str1 = private unnamed_addr constant [14 x i8] c"Now crash %d\0A\00", align 1 + +; Function Attrs: nounwind uwtable +define i32 @main(i32 %argc, i8** %argv) #0 { + %1 = alloca i32, align 4 ;CHECK: !dbg + %2 = alloca i32, align 4 ;CHECK-NEXT: !dbg + %3 = alloca i8**, align 8 ;CHECK-NEXT: !dbg + %null_ptr = alloca i32*, align 8 ;CHECK-NEXT: !dbg + store i32 0, i32* %1 ;CHECK-NEXT: !dbg + store i32 %argc, i32* %2, align 4 ;CHECK-NEXT: !dbg + store i8** %argv, i8*** %3, align 8 ;CHECK-NEXT: !dbg + store i32* null, i32** %null_ptr, align 8 ;CHECK-NEXT: !dbg + %4 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([18 x i8]* @.str, i32 0, i32 0)) ;CHECK-NEXT: !dbg + %5 = load i32** %null_ptr, align 8 ;CHECK-NEXT: !dbg + %6 = load i32* %5, align 4 ;CHECK-NEXT: !dbg + %7 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([14 x i8]* @.str1, i32 0, i32 0), i32 %6) ;CHECK-NEXT: !dbg + %8 = load i32* %2, align 4 ;CHECK-NEXT: !dbg + ret i32 %8 ;CHECK-NEXT: !dbg +} + +declare i32 @printf(i8*, ...) #1 + +attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } + +; CHECK: = metadata !{i32 14, +; CHECK-NEXT: = metadata !{i32 15, +; CHECK-NEXT: = metadata !{i32 16, +; CHECK-NEXT: = metadata !{i32 17, +; CHECK-NEXT: = metadata !{i32 18, +; CHECK-NEXT: = metadata !{i32 19, +; CHECK-NEXT: = metadata !{i32 20, +; CHECK-NEXT: = metadata !{i32 21, +; CHECK-NEXT: = metadata !{i32 22, +; CHECK-NEXT: = metadata !{i32 23, + +; RUN: opt %s -debug-ir -S | FileCheck %s diff --git a/test/Transforms/DebugIR/exception.ll b/test/Transforms/DebugIR/exception.ll new file mode 100644 index 0000000000..2436d38968 --- /dev/null +++ b/test/Transforms/DebugIR/exception.ll @@ -0,0 +1,127 @@ +; ModuleID = 'exception.cpp' +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-pc-linux-gnu" + +@_ZTIi = external constant i8* + +; Function Attrs: uwtable +define i32 @main(i32 %argc, i8** %argv) #0 { + %1 = alloca i32, align 4 ; CHECK: !dbg + %2 = alloca i32, align 4 ; CHECK-NEXT: !dbg + %3 = alloca i8**, align 8 ; CHECK-NEXT: !dbg + %4 = alloca i8* ; CHECK-NEXT: !dbg + %5 = alloca i32 ; CHECK-NEXT: !dbg + %e = alloca i32, align 4 ; CHECK-NEXT: !dbg + %6 = alloca i32 ; CHECK-NEXT: !dbg + store i32 0, i32* %1 ; CHECK-NEXT: !dbg + store i32 %argc, i32* %2, align 4 ; CHECK-NEXT: !dbg + store i8** %argv, i8*** %3, align 8 ; CHECK-NEXT: !dbg + %7 = call i8* @__cxa_allocate_exception(i64 4) #2 ; CHECK-NEXT: !dbg + %8 = bitcast i8* %7 to i32* ; CHECK-NEXT: !dbg + %9 = load i32* %2, align 4 ; CHECK-NEXT: !dbg + store i32 %9, i32* %8 ; CHECK-NEXT: !dbg + invoke void @__cxa_throw(i8* %7, i8* bitcast (i8** @_ZTIi to i8*), i8* null) #3 + to label %31 unwind label %10 ; CHECK: !dbg + +;