<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">This is causing buildbot failures:<div><br></div><div><a href="http://lab.llvm.org:8013/builders/clang-x86_64-darwin11-nobootstrap-RAincremental/builds/3683/steps/make/logs/stdio">http://lab.llvm.org:8013/builders/clang-x86_64-darwin11-nobootstrap-RAincremental/builds/3683/steps/make/logs/stdio</a></div><div><br></div><div>Michael</div><div><br><div><div>On Jun 28, 2013, at 1:37 PM, Daniel Malea <<a href="mailto:daniel.malea@intel.com">daniel.malea@intel.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Author: dmalea<br>Date: Fri Jun 28 15:37:20 2013<br>New Revision: 185212<br><br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=185212&view=rev">http://llvm.org/viewvc/llvm-project?rev=185212&view=rev</a><br>Log:<br>Adding tests for DebugIR pass<br>- lit tests verify that each line of input LLVM IR gets a !dbg node and a<br> corresponding entry of metadata that contains the line number<span class="Apple-converted-space"> </span><br>- unit tests verify that DebugIR works as advertised in the interface<br>- refactored some useful IR generation functionality from the MCJIT unit tests<br> so it can be reused<br><br><br>Added:<br> llvm/trunk/test/Transforms/DebugIR/<br> llvm/trunk/test/Transforms/DebugIR/crash.ll<br> llvm/trunk/test/Transforms/DebugIR/exception.ll<br> llvm/trunk/test/Transforms/DebugIR/function.ll<br> llvm/trunk/test/Transforms/DebugIR/lit.local.cfg<br> llvm/trunk/test/Transforms/DebugIR/simple.ll<br> llvm/trunk/test/Transforms/DebugIR/struct.ll<br> llvm/trunk/test/Transforms/DebugIR/vector.ll<br> llvm/trunk/unittests/Transforms/DebugIR/<br> llvm/trunk/unittests/Transforms/DebugIR/CMakeLists.txt<br> llvm/trunk/unittests/Transforms/DebugIR/DebugIR.cpp<br> llvm/trunk/unittests/Transforms/DebugIR/Makefile<br>Modified:<br> llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h<br> llvm/trunk/unittests/Transforms/CMakeLists.txt<br> llvm/trunk/unittests/Transforms/Makefile<br><br>Added: llvm/trunk/test/Transforms/DebugIR/crash.ll<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DebugIR/crash.ll?rev=185212&view=auto">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DebugIR/crash.ll?rev=185212&view=auto</a><br>==============================================================================<br>--- llvm/trunk/test/Transforms/DebugIR/crash.ll (added)<br>+++ llvm/trunk/test/Transforms/DebugIR/crash.ll Fri Jun 28 15:37:20 2013<br>@@ -0,0 +1,42 @@<br>+; ModuleID = 'crash.c'<br>+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"<br>+target triple = "x86_64-pc-linux-gnu"<br>+<br>+@.str = private unnamed_addr constant [18 x i8] c"Hello, segfault!\0A\00", align 1<br>+@.str1 = private unnamed_addr constant [14 x i8] c"Now crash %d\0A\00", align 1<br>+<br>+; Function Attrs: nounwind uwtable<br>+define i32 @main(i32 %argc, i8** %argv) #0 {<br>+ %1 = alloca i32, align 4 ;CHECK: !dbg<br>+ %2 = alloca i32, align 4 ;CHECK-NEXT: !dbg<br>+ %3 = alloca i8**, align 8 ;CHECK-NEXT: !dbg<br>+ %null_ptr = alloca i32*, align 8 ;CHECK-NEXT: !dbg<br>+ store i32 0, i32* %1 ;CHECK-NEXT: !dbg<br>+ store i32 %argc, i32* %2, align 4 ;CHECK-NEXT: !dbg<br>+ store i8** %argv, i8*** %3, align 8 ;CHECK-NEXT: !dbg<br>+ store i32* null, i32** %null_ptr, align 8 ;CHECK-NEXT: !dbg<br>+ %4 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([18 x i8]* @.str, i32 0, i32 0)) ;CHECK-NEXT: !dbg<br>+ %5 = load i32** %null_ptr, align 8 ;CHECK-NEXT: !dbg<br>+ %6 = load i32* %5, align 4 ;CHECK-NEXT: !dbg<br>+ %7 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([14 x i8]* @.str1, i32 0, i32 0), i32 %6) ;CHECK-NEXT: !dbg<br>+ %8 = load i32* %2, align 4 ;CHECK-NEXT: !dbg<br>+ ret i32 %8 ;CHECK-NEXT: !dbg<br>+}<br>+<br>+declare i32 @printf(i8*, ...) #1<br>+<br>+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" }<br>+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" }<br>+<br>+; CHECK: = metadata !{i32 14,<br>+; CHECK-NEXT: = metadata !{i32 15,<br>+; CHECK-NEXT: = metadata !{i32 16,<br>+; CHECK-NEXT: = metadata !{i32 17,<br>+; CHECK-NEXT: = metadata !{i32 18,<br>+; CHECK-NEXT: = metadata !{i32 19,<br>+; CHECK-NEXT: = metadata !{i32 20,<br>+; CHECK-NEXT: = metadata !{i32 21,<br>+; CHECK-NEXT: = metadata !{i32 22,<br>+; CHECK-NEXT: = metadata !{i32 23,<br>+<br>+; RUN: opt %s -debug-ir -S | FileCheck %s<br><br>Added: llvm/trunk/test/Transforms/DebugIR/exception.ll<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DebugIR/exception.ll?rev=185212&view=auto">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DebugIR/exception.ll?rev=185212&view=auto</a><br>==============================================================================<br>--- llvm/trunk/test/Transforms/DebugIR/exception.ll (added)<br>+++ llvm/trunk/test/Transforms/DebugIR/exception.ll Fri Jun 28 15:37:20 2013<br>@@ -0,0 +1,127 @@<br>+; ModuleID = 'exception.cpp'<br>+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"<br>+target triple = "x86_64-pc-linux-gnu"<br>+<br>+@_ZTIi = external constant i8*<br>+<br>+; Function Attrs: uwtable<br>+define i32 @main(i32 %argc, i8** %argv) #0 {<br>+ %1 = alloca i32, align 4 ; CHECK: !dbg<br>+ %2 = alloca i32, align 4 ; CHECK-NEXT: !dbg<br>+ %3 = alloca i8**, align 8 ; CHECK-NEXT: !dbg<br>+ %4 = alloca i8* ; CHECK-NEXT: !dbg<br>+ %5 = alloca i32 ; CHECK-NEXT: !dbg<br>+ %e = alloca i32, align 4 ; CHECK-NEXT: !dbg<br>+ %6 = alloca i32 ; CHECK-NEXT: !dbg<br>+ store i32 0, i32* %1 ; CHECK-NEXT: !dbg<br>+ store i32 %argc, i32* %2, align 4 ; CHECK-NEXT: !dbg<br>+ store i8** %argv, i8*** %3, align 8 ; CHECK-NEXT: !dbg<br>+ %7 = call i8* @__cxa_allocate_exception(i64 4) #2 ; CHECK-NEXT: !dbg<br>+ %8 = bitcast i8* %7 to i32* ; CHECK-NEXT: !dbg<br>+ %9 = load i32* %2, align 4 ; CHECK-NEXT: !dbg<br>+ store i32 %9, i32* %8 ; CHECK-NEXT: !dbg<br>+ invoke void @__cxa_throw(i8* %7, i8* bitcast (i8** @_ZTIi to i8*), i8* null) #3<br>+ to label %31 unwind label %10 ; CHECK: !dbg<br>+<br>+; <label>:10 ; preds = %0<br>+ %11 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)<br>+ catch i8* bitcast (i8** @_ZTIi to i8*) ; CHECK: !dbg<br>+ %12 = extractvalue { i8*, i32 } %11, 0 ; CHECK-NEXT: !dbg<br>+ store i8* %12, i8** %4 ; CHECK-NEXT: !dbg<br>+ %13 = extractvalue { i8*, i32 } %11, 1 ; CHECK-NEXT: !dbg<br>+ store i32 %13, i32* %5 ; CHECK-NEXT: !dbg<br>+ br label %14 ; CHECK-NEXT: !dbg<br>+<br>+; <label>:14 ; preds = %10<br>+ %15 = load i32* %5 ; CHECK: !dbg<br>+ %16 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #2 ; CHECK-NEXT: !dbg<br>+ %17 = icmp eq i32 %15, %16 ; CHECK-NEXT: !dbg<br>+ br i1 %17, label %18, label %26 ; CHECK-NEXT: !dbg<br>+<br>+; <label>:18 ; preds = %14<br>+ %19 = load i8** %4 ; CHECK: !dbg<br>+ %20 = call i8* @__cxa_begin_catch(i8* %19) #2 ; CHECK-NEXT: !dbg<br>+ %21 = bitcast i8* %20 to i32* ; CHECK-NEXT: !dbg<br>+ %22 = load i32* %21, align 4 ; CHECK-NEXT: !dbg<br>+ store i32 %22, i32* %e, align 4 ; CHECK-NEXT: !dbg<br>+ %23 = load i32* %e, align 4 ; CHECK-NEXT: !dbg<br>+ store i32 %23, i32* %1 ; CHECK-NEXT: !dbg<br>+ store i32 1, i32* %6 ; CHECK-NEXT: !dbg<br>+ call void @__cxa_end_catch() #2 ; CHECK-NEXT: !dbg<br>+ br label %24 ; CHECK-NEXT: !dbg<br>+<br>+; <label>:24 ; preds = %18<br>+ %25 = load i32* %1 ; CHECK: !dbg<br>+ ret i32 %25 ; CHECK-NEXT: !dbg<br>+<br>+; <label>:26 ; preds = %14<br>+ %27 = load i8** %4 ; CHECK: !dbg<br>+ %28 = load i32* %5 ; CHECK-NEXT: !dbg<br>+ %29 = insertvalue { i8*, i32 } undef, i8* %27, 0 ; CHECK-NEXT: !dbg<br>+ %30 = insertvalue { i8*, i32 } %29, i32 %28, 1 ; CHECK-NEXT: !dbg<br>+ resume { i8*, i32 } %30 ; CHECK-NEXT: !dbg<br>+<br>+; <label>:31 ; preds = %0<br>+ unreachable ; CHECK: !dbg<br>+}<br>+<br>+declare i8* @__cxa_allocate_exception(i64)<br>+<br>+declare void @__cxa_throw(i8*, i8*, i8*)<br>+<br>+declare i32 @__gxx_personality_v0(...)<br>+<br>+; Function Attrs: nounwind readnone<br>+declare i32 @llvm.eh.typeid.for(i8*) #1<br>+<br>+declare i8* @__cxa_begin_catch(i8*)<br>+<br>+declare void @__cxa_end_catch()<br>+<br>+attributes #0 = { 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" }<br>+attributes #1 = { nounwind readnone }<br>+attributes #2 = { nounwind }<br>+attributes #3 = { noreturn }<br>+; CHECK: = metadata !{i32 16,<br>+; CHECK-NEXT: = metadata !{i32 17,<br>+; CHECK-NEXT: = metadata !{i32 18,<br>+; CHECK-NEXT: = metadata !{i32 19,<br>+; CHECK-NEXT: = metadata !{i32 20,<br>+; CHECK-NEXT: = metadata !{i32 21,<br>+; CHECK-NEXT: = metadata !{i32 22,<br>+; CHECK-NEXT: = metadata !{i32 24,<br>+<br>+; CHECK-NEXT: = metadata !{i32 28,<br>+; CHECK-NEXT: = metadata !{i32 29,<br>+; CHECK-NEXT: = metadata !{i32 30,<br>+; CHECK-NEXT: = metadata !{i32 31,<br>+; CHECK-NEXT: = metadata !{i32 32,<br>+; CHECK-NEXT: = metadata !{i32 33,<br>+<br>+; CHECK-NEXT: = metadata !{i32 36,<br>+; CHECK-NEXT: = metadata !{i32 37,<br>+; CHECK-NEXT: = metadata !{i32 38,<br>+; CHECK-NEXT: = metadata !{i32 39,<br>+<br>+; CHECK-NEXT: = metadata !{i32 42,<br>+; CHECK-NEXT: = metadata !{i32 43,<br>+; CHECK-NEXT: = metadata !{i32 44,<br>+; CHECK-NEXT: = metadata !{i32 45,<br>+; CHECK-NEXT: = metadata !{i32 46,<br>+; CHECK-NEXT: = metadata !{i32 47,<br>+; CHECK-NEXT: = metadata !{i32 48,<br>+; CHECK-NEXT: = metadata !{i32 49,<br>+; CHECK-NEXT: = metadata !{i32 50,<br>+; CHECK-NEXT: = metadata !{i32 51,<br>+<br>+; CHECK-NEXT: = metadata !{i32 54,<br>+; CHECK-NEXT: = metadata !{i32 55,<br>+<br>+; CHECK-NEXT: = metadata !{i32 58,<br>+; CHECK-NEXT: = metadata !{i32 59,<br>+; CHECK-NEXT: = metadata !{i32 60,<br>+; CHECK-NEXT: = metadata !{i32 61,<br>+; CHECK-NEXT: = metadata !{i32 62,<br>+; CHECK-NEXT: = metadata !{i32 65,<br>+<br>+; RUN: opt %s -debug-ir -S | FileCheck %s<br><br>Added: llvm/trunk/test/Transforms/DebugIR/function.ll<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DebugIR/function.ll?rev=185212&view=auto">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DebugIR/function.ll?rev=185212&view=auto</a><br>==============================================================================<br>--- llvm/trunk/test/Transforms/DebugIR/function.ll (added)<br>+++ llvm/trunk/test/Transforms/DebugIR/function.ll Fri Jun 28 15:37:20 2013<br>@@ -0,0 +1,51 @@<br>+; ModuleID = 'function.c'<br>+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"<br>+target triple = "x86_64-pc-linux-gnu"<br>+<br>+; Function Attrs: nounwind uwtable<br>+define void @blah(i32* %i) #0 {<br>+ %1 = alloca i32*, align 8 ; CHECK: !dbg<br>+ store i32* %i, i32** %1, align 8 ; CHECK-NEXT: !dbg<br>+ %2 = load i32** %1, align 8 ; CHECK-NEXT: !dbg<br>+ %3 = load i32* %2, align 4 ; CHECK-NEXT: !dbg<br>+ %4 = add nsw i32 %3, 1 ; CHECK-NEXT: !dbg<br>+ store i32 %4, i32* %2, align 4 ; CHECK-NEXT: !dbg<br>+ ret void ; CHECK-NEXT: !dbg<br>+}<br>+<br>+; Function Attrs: nounwind uwtable<br>+define i32 @main(i32 %argc, i8** %argv) #0 {<br>+ %1 = alloca i32, align 4 ; CHECK: !dbg<br>+ %2 = alloca i32, align 4 ; CHECK-NEXT: !dbg<br>+ %3 = alloca i8**, align 8 ; CHECK-NEXT: !dbg<br>+ %i = alloca i32, align 4 ; CHECK-NEXT: !dbg<br>+ store i32 0, i32* %1 ; CHECK-NEXT: !dbg<br>+ store i32 %argc, i32* %2, align 4 ; CHECK-NEXT: !dbg<br>+ store i8** %argv, i8*** %3, align 8 ; CHECK-NEXT: !dbg<br>+ store i32 7, i32* %i, align 4 ; CHECK-NEXT: !dbg<br>+ call void @blah(i32* %i) ; CHECK-NEXT: !dbg<br>+ %4 = load i32* %i, align 4 ; CHECK-NEXT: !dbg<br>+ ret i32 %4 ; CHECK-NEXT: !dbg<br>+}<br>+<br>+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" }<br>+; CHECK: = metadata !{i32 8,<br>+; CHECK-NEXT: = metadata !{i32 9,<br>+; CHECK-NEXT: = metadata !{i32 10,<br>+; CHECK-NEXT: = metadata !{i32 11,<br>+; CHECK-NEXT: = metadata !{i32 12,<br>+; CHECK-NEXT: = metadata !{i32 13,<br>+<br>+; CHECK-NEXT: = metadata !{i32 18,<br>+; CHECK-NEXT: = metadata !{i32 19,<br>+; CHECK-NEXT: = metadata !{i32 20,<br>+; CHECK-NEXT: = metadata !{i32 21,<br>+; CHECK-NEXT: = metadata !{i32 22,<br>+; CHECK-NEXT: = metadata !{i32 23,<br>+; CHECK-NEXT: = metadata !{i32 24,<br>+; CHECK-NEXT: = metadata !{i32 25,<br>+; CHECK-NEXT: = metadata !{i32 26,<br>+; CHECK-NEXT: = metadata !{i32 27,<br>+; CHECK-NEXT: = metadata !{i32 28,<br>+<br>+; RUN: opt %s -debug-ir -S | FileCheck %s<br><br>Added: llvm/trunk/test/Transforms/DebugIR/lit.local.cfg<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DebugIR/lit.local.cfg?rev=185212&view=auto">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DebugIR/lit.local.cfg?rev=185212&view=auto</a><br>==============================================================================<br>--- llvm/trunk/test/Transforms/DebugIR/lit.local.cfg (added)<br>+++ llvm/trunk/test/Transforms/DebugIR/lit.local.cfg Fri Jun 28 15:37:20 2013<br>@@ -0,0 +1 @@<br>+config.suffixes = ['.ll']<br><br>Added: llvm/trunk/test/Transforms/DebugIR/simple.ll<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DebugIR/simple.ll?rev=185212&view=auto">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DebugIR/simple.ll?rev=185212&view=auto</a><br>==============================================================================<br>--- llvm/trunk/test/Transforms/DebugIR/simple.ll (added)<br>+++ llvm/trunk/test/Transforms/DebugIR/simple.ll Fri Jun 28 15:37:20 2013<br>@@ -0,0 +1,25 @@<br>+; ModuleID = 'simple.c'<br>+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"<br>+target triple = "x86_64-pc-linux-gnu"<br>+<br>+; Function Attrs: nounwind uwtable<br>+define i32 @main(i32 %argc, i8** %argv) #0 {<br>+ %1 = alloca i32, align 4 ; CHECK: !dbg<br>+ %2 = alloca i32, align 4 ; CHECK-NEXT: !dbg<br>+ %3 = alloca i8**, align 8 ; CHECK-NEXT: !dbg<br>+ store i32 0, i32* %1 ; CHECK-NEXT: !dbg<br>+ store i32 %argc, i32* %2, align 4 ; CHECK-NEXT: !dbg<br>+ store i8** %argv, i8*** %3, align 8 ; CHECK-NEXT: !dbg<br>+ %4 = load i32* %2, align 4 ; CHECK-NEXT: !dbg<br>+ ret i32 %4 ; CHECK-NEXT: !dbg<br>+}<br>+<br>+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" }<br>+<br>+; CHECK: = metadata !{i32 10,<br>+; CHECK-NEXT: = metadata !{i32 11,<br>+; CHECK-NEXT: = metadata !{i32 12,<br>+; CHECK-NEXT: = metadata !{i32 13,<br>+; CHECK-NEXT: = metadata !{i32 14,<br>+<br>+; RUN: opt %s -debug-ir -S | FileCheck %s<br><br>Added: llvm/trunk/test/Transforms/DebugIR/struct.ll<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DebugIR/struct.ll?rev=185212&view=auto">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DebugIR/struct.ll?rev=185212&view=auto</a><br>==============================================================================<br>--- llvm/trunk/test/Transforms/DebugIR/struct.ll (added)<br>+++ llvm/trunk/test/Transforms/DebugIR/struct.ll Fri Jun 28 15:37:20 2013<br>@@ -0,0 +1,24 @@<br>+; ModuleID = 'struct.cpp'<br>+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"<br>+target triple = "x86_64-pc-linux-gnu"<br>+<br>+%struct.blah = type { i32, float, i8 }<br>+<br>+; Function Attrs: nounwind uwtable<br>+define i32 @main() #0 {<br>+ %1 = alloca i32, align 4 ; CHECK: !dbg<br>+ %b = alloca %struct.blah, align 4 ; CHECK-NEXT: !dbg<br>+ store i32 0, i32* %1 ; CHECK-NEXT: !dbg<br>+ %2 = getelementptr inbounds %struct.blah* %b, i32 0, i32 0 ; CHECK-NEXT: !dbg<br>+ %3 = load i32* %2, align 4 ; CHECK-NEXT: !dbg<br>+ ret i32 %3 ; CHECK-NEXT: !dbg<br>+}<br>+<br>+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" }<br>+<br>+; CHECK: = metadata !{i32 11,<br>+; CHECK-NEXT: = metadata !{i32 12,<br>+; CHECK-NEXT: = metadata !{i32 13,<br>+; CHECK-NEXT: = metadata !{i32 14,<br>+<br>+; RUN: opt %s -debug-ir -S | FileCheck %s<br><br>Added: llvm/trunk/test/Transforms/DebugIR/vector.ll<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DebugIR/vector.ll?rev=185212&view=auto">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DebugIR/vector.ll?rev=185212&view=auto</a><br>==============================================================================<br>--- llvm/trunk/test/Transforms/DebugIR/vector.ll (added)<br>+++ llvm/trunk/test/Transforms/DebugIR/vector.ll Fri Jun 28 15:37:20 2013<br>@@ -0,0 +1,93 @@<br>+; ModuleID = 'vector.cpp'<br>+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"<br>+target triple = "x86_64-pc-linux-gnu"<br>+<br>+; Function Attrs: noinline nounwind uwtable<br>+define <4 x float> @_Z3fooDv2_fS_(double %a.coerce, double %b.coerce) #0 {<br>+ %1 = alloca <2 x float>, align 8 ; CHECK: !dbg<br>+ %2 = alloca <2 x float>, align 8 ; CHECK-NEXT: !dbg<br>+ %3 = alloca <2 x float>, align 8 ; CHECK-NEXT: !dbg<br>+ %4 = alloca <2 x float>, align 8 ; CHECK-NEXT: !dbg<br>+ %c = alloca <4 x float>, align 16 ; CHECK-NEXT: !dbg<br>+ %5 = bitcast <2 x float>* %1 to double* ; CHECK-NEXT: !dbg<br>+ store double %a.coerce, double* %5, align 1 ; CHECK-NEXT: !dbg<br>+ %a = load <2 x float>* %1, align 8 ; CHECK-NEXT: !dbg<br>+ store <2 x float> %a, <2 x float>* %2, align 8 ; CHECK-NEXT: !dbg<br>+ %6 = bitcast <2 x float>* %3 to double* ; CHECK-NEXT: !dbg<br>+ store double %b.coerce, double* %6, align 1 ; CHECK-NEXT: !dbg<br>+ %b = load <2 x float>* %3, align 8 ; CHECK-NEXT: !dbg<br>+ store <2 x float> %b, <2 x float>* %4, align 8 ; CHECK-NEXT: !dbg<br>+ %7 = load <2 x float>* %2, align 8 ; CHECK-NEXT: !dbg<br>+ %8 = load <4 x float>* %c, align 16 ; CHECK-NEXT: !dbg<br>+ %9 = shufflevector <2 x float> %7, <2 x float> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef> ; CHECK-NEXT: !dbg<br>+ %10 = shufflevector <4 x float> %8, <4 x float> %9, <4 x i32> <i32 4, i32 1, i32 5, i32 3> ; CHECK-NEXT: !dbg<br>+ store <4 x float> %10, <4 x float>* %c, align 16 ; CHECK-NEXT: !dbg<br>+ %11 = load <2 x float>* %4, align 8 ; CHECK-NEXT: !dbg<br>+ %12 = load <4 x float>* %c, align 16 ; CHECK-NEXT: !dbg<br>+ %13 = shufflevector <2 x float> %11, <2 x float> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef> ; CHECK-NEXT: !dbg<br>+ %14 = shufflevector <4 x float> %12, <4 x float> %13, <4 x i32> <i32 0, i32 4, i32 2, i32 5> ; CHECK-NEXT: !dbg<br>+ store <4 x float> %14, <4 x float>* %c, align 16 ; CHECK-NEXT: !dbg<br>+ %15 = load <4 x float>* %c, align 16 ; CHECK-NEXT: !dbg<br>+ ret <4 x float> %15 ; CHECK-NEXT: !dbg<br>+}<br>+<br>+; Function Attrs: nounwind uwtable<br>+define i32 @main() #1 {<br>+ %1 = alloca i32, align 4 ; CHECK: !dbg<br>+ %a = alloca <2 x float>, align 8 ; CHECK-NEXT: !dbg<br>+ %b = alloca <2 x float>, align 8 ; CHECK-NEXT: !dbg<br>+ %x = alloca <4 x float>, align 16 ; CHECK-NEXT: !dbg<br>+ %2 = alloca <2 x float>, align 8 ; CHECK-NEXT: !dbg<br>+ %3 = alloca <2 x float>, align 8 ; CHECK-NEXT: !dbg<br>+ store i32 0, i32* %1 ; CHECK-NEXT: !dbg<br>+ store <2 x float> <float 1.000000e+00, float 2.000000e+00>, <2 x float>* %a, align 8 ; CHECK-NEXT: !dbg<br>+ store <2 x float> <float 1.000000e+00, float 2.000000e+00>, <2 x float>* %b, align 8 ; CHECK-NEXT: !dbg<br>+ %4 = load <2 x float>* %a, align 8 ; CHECK-NEXT: !dbg<br>+ %5 = load <2 x float>* %b, align 8 ; CHECK-NEXT: !dbg<br>+ store <2 x float> %4, <2 x float>* %2, align 8 ; CHECK-NEXT: !dbg<br>+ %6 = bitcast <2 x float>* %2 to double* ; CHECK-NEXT: !dbg<br>+ %7 = load double* %6, align 1 ; CHECK-NEXT: !dbg<br>+ store <2 x float> %5, <2 x float>* %3, align 8 ; CHECK-NEXT: !dbg<br>+ %8 = bitcast <2 x float>* %3 to double* ; CHECK-NEXT: !dbg<br>+ %9 = load double* %8, align 1 ; CHECK-NEXT: !dbg<br>+ %10 = call <4 x float> @_Z3fooDv2_fS_(double %7, double %9) ; CHECK-NEXT: !dbg<br>+ store <4 x float> %10, <4 x float>* %x, align 16 ; CHECK-NEXT: !dbg<br>+ %11 = load <4 x float>* %x, align 16 ; CHECK-NEXT: !dbg<br>+ %12 = extractelement <4 x float> %11, i32 0 ; CHECK-NEXT: !dbg<br>+ %13 = load <4 x float>* %x, align 16 ; CHECK-NEXT: !dbg<br>+ %14 = extractelement <4 x float> %13, i32 1 ; CHECK-NEXT: !dbg<br>+ %15 = fadd float %12, %14 ; CHECK-NEXT: !dbg<br>+ %16 = load <4 x float>* %x, align 16 ; CHECK-NEXT: !dbg<br>+ %17 = extractelement <4 x float> %16, i32 2 ; CHECK-NEXT: !dbg<br>+ %18 = fadd float %15, %17 ; CHECK-NEXT: !dbg<br>+ %19 = load <4 x float>* %x, align 16 ; CHECK-NEXT: !dbg<br>+ %20 = extractelement <4 x float> %19, i32 3 ; CHECK-NEXT: !dbg<br>+ %21 = fadd float %18, %20 ; CHECK-NEXT: !dbg<br>+ %22 = fptosi float %21 to i32 ; CHECK-NEXT: !dbg<br>+ ret i32 %22 ; CHECK-NEXT: !dbg<br>+}<br>+<br>+attributes #0 = { noinline 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" }<br>+attributes #1 = { 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" }<br>+<br>+; CHECK: = metadata !{i32 13,<br>+; CHECK-NEXT: = metadata !{i32 14,<br>+; CHECK-NEXT: = metadata !{i32 15,<br>+; CHECK-NEXT: = metadata !{i32 16,<br>+; CHECK-NEXT: = metadata !{i32 17,<br>+; CHECK-NEXT: = metadata !{i32 18,<br>+; CHECK-NEXT: = metadata !{i32 19,<br>+; CHECK-NEXT: = metadata !{i32 20,<br>+; CHECK-NEXT: = metadata !{i32 21,<br>+; CHECK-NEXT: = metadata !{i32 22,<br>+; CHECK-NEXT: = metadata !{i32 23,<br>+; CHECK-NEXT: = metadata !{i32 24,<br>+; CHECK-NEXT: = metadata !{i32 25,<br>+; CHECK-NEXT: = metadata !{i32 26,<br>+; CHECK-NEXT: = metadata !{i32 27,<br>+; CHECK-NEXT: = metadata !{i32 28,<br>+; CHECK-NEXT: = metadata !{i32 29,<br>+; CHECK-NEXT: = metadata !{i32 30,<br>+; CHECK-NEXT: = metadata !{i32 31,<br>+<br>+; RUN: opt %s -debug-ir -S | FileCheck %s<br><br>Modified: llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h?rev=185212&r1=185211&r2=185212&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h?rev=185212&r1=185211&r2=185212&view=diff</a><br>==============================================================================<br>--- llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h (original)<br>+++ llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h Fri Jun 28 15:37:20 2013<br>@@ -30,42 +30,19 @@<br><br>namespace llvm {<br><br>-class MCJITTestBase : public MCJITTestAPICommon {<br>+/// Helper class that can build very simple Modules<br>+class TrivialModuleBuilder {<br>protected:<br>+ LLVMContext Context;<br>+ IRBuilder<> Builder;<br>+ std::string BuilderTriple;<br><br>- MCJITTestBase()<br>- : OptLevel(CodeGenOpt::None)<br>- , RelocModel(Reloc::Default)<br>- , CodeModel(CodeModel::Default)<br>- , MArch("")<br>- , Builder(Context)<br>- , MM(new SectionMemoryManager)<br>- {<br>- // The architectures below are known to be compatible with MCJIT as they<br>- // are copied from test/ExecutionEngine/MCJIT/lit.local.cfg and should be<br>- // kept in sync.<br>- SupportedArchs.push_back(Triple::aarch64);<br>- SupportedArchs.push_back(Triple::arm);<br>- SupportedArchs.push_back(Triple::x86);<br>- SupportedArchs.push_back(Triple::x86_64);<br>-<br>- // Some architectures have sub-architectures in which tests will fail, like<br>- // ARM. These two vectors will define if they do have sub-archs (to avoid<br>- // extra work for those who don't), and if so, if they are listed to work<br>- HasSubArchs.push_back(Triple::arm);<br>- SupportedSubArchs.push_back("armv6");<br>- SupportedSubArchs.push_back("armv7");<br>-<br>- // The operating systems below are known to be incompatible with MCJIT as<br>- // they are copied from the test/ExecutionEngine/MCJIT/lit.local.cfg and<br>- // should be kept in sync.<br>- UnsupportedOSs.push_back(Triple::Cygwin);<br>- UnsupportedOSs.push_back(Triple::Darwin);<br>- }<br>+ TrivialModuleBuilder(const std::string &Triple)<br>+ : Builder(Context), BuilderTriple(Triple) {}<br><br>- Module *createEmptyModule(StringRef Name) {<br>+ Module *createEmptyModule(StringRef Name = StringRef()) {<br> Module * M = new Module(Name, Context);<br>- M->setTargetTriple(Triple::normalize(HostTriple));<br>+ M->setTargetTriple(Triple::normalize(BuilderTriple));<br> return M;<br> }<br><br>@@ -161,6 +138,40 @@ protected:<br> name);<br> return Global;<br> }<br>+};<br>+<br>+class MCJITTestBase : public MCJITTestAPICommon, public TrivialModuleBuilder {<br>+protected:<br>+ <br>+ MCJITTestBase()<br>+ : TrivialModuleBuilder(HostTriple)<br>+ , OptLevel(CodeGenOpt::None)<br>+ , RelocModel(Reloc::Default)<br>+ , CodeModel(CodeModel::Default)<br>+ , MArch("")<br>+ , MM(new SectionMemoryManager)<br>+ {<br>+ // The architectures below are known to be compatible with MCJIT as they<br>+ // are copied from test/ExecutionEngine/MCJIT/lit.local.cfg and should be<br>+ // kept in sync.<br>+ SupportedArchs.push_back(Triple::aarch64);<br>+ SupportedArchs.push_back(Triple::arm);<br>+ SupportedArchs.push_back(Triple::x86);<br>+ SupportedArchs.push_back(Triple::x86_64);<br>+<br>+ // Some architectures have sub-architectures in which tests will fail, like<br>+ // ARM. These two vectors will define if they do have sub-archs (to avoid<br>+ // extra work for those who don't), and if so, if they are listed to work<br>+ HasSubArchs.push_back(Triple::arm);<br>+ SupportedSubArchs.push_back("armv6");<br>+ SupportedSubArchs.push_back("armv7");<br>+<br>+ // The operating systems below are known to be incompatible with MCJIT as<br>+ // they are copied from the test/ExecutionEngine/MCJIT/lit.local.cfg and<br>+ // should be kept in sync.<br>+ UnsupportedOSs.push_back(Triple::Cygwin);<br>+ UnsupportedOSs.push_back(Triple::Darwin);<br>+ }<br><br> void createJIT(Module *M) {<br><br>@@ -186,14 +197,12 @@ protected:<br> assert(TheJIT.get() != NULL && "error creating MCJIT with EngineBuilder");<br> }<br><br>- LLVMContext Context;<br> CodeGenOpt::Level OptLevel;<br> Reloc::Model RelocModel;<br> CodeModel::Model CodeModel;<br> StringRef MArch;<br> SmallVector<std::string, 1> MAttrs;<br> OwningPtr<ExecutionEngine> TheJIT;<br>- IRBuilder<> Builder;<br> RTDyldMemoryManager *MM;<br><br> OwningPtr<Module> M;<br><br>Modified: llvm/trunk/unittests/Transforms/CMakeLists.txt<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/CMakeLists.txt?rev=185212&r1=185211&r2=185212&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/CMakeLists.txt?rev=185212&r1=185211&r2=185212&view=diff</a><br>==============================================================================<br>--- llvm/trunk/unittests/Transforms/CMakeLists.txt (original)<br>+++ llvm/trunk/unittests/Transforms/CMakeLists.txt Fri Jun 28 15:37:20 2013<br>@@ -1 +1,2 @@<br>+add_subdirectory(DebugIR)<br>add_subdirectory(Utils)<br><br>Added: llvm/trunk/unittests/Transforms/DebugIR/CMakeLists.txt<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/DebugIR/CMakeLists.txt?rev=185212&view=auto">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/DebugIR/CMakeLists.txt?rev=185212&view=auto</a><br>==============================================================================<br>--- llvm/trunk/unittests/Transforms/DebugIR/CMakeLists.txt (added)<br>+++ llvm/trunk/unittests/Transforms/DebugIR/CMakeLists.txt Fri Jun 28 15:37:20 2013<br>@@ -0,0 +1,7 @@<br>+set(LLVM_LINK_COMPONENTS<br>+ Instrumentation<br>+ )<br>+<br>+add_llvm_unittest(DebugIRTests<br>+ DebugIR.cpp<br>+ )<br><br>Added: llvm/trunk/unittests/Transforms/DebugIR/DebugIR.cpp<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/DebugIR/DebugIR.cpp?rev=185212&view=auto">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/DebugIR/DebugIR.cpp?rev=185212&view=auto</a><br>==============================================================================<br>--- llvm/trunk/unittests/Transforms/DebugIR/DebugIR.cpp (added)<br>+++ llvm/trunk/unittests/Transforms/DebugIR/DebugIR.cpp Fri Jun 28 15:37:20 2013<br>@@ -0,0 +1,296 @@<br>+//===- DebugIR.cpp - Unit tests for the DebugIR pass ----------------------===//<br>+//<br>+// The LLVM Compiler Infrastructure<br>+//<br>+// This file is distributed under the University of Illinois Open Source<br>+// License. See LICENSE.TXT for details.<br>+//<br>+//===----------------------------------------------------------------------===//<br>+//<br>+// The tests in this file verify the DebugIR pass that generates debug metadata<br>+// for LLVM IR.<br>+//<br>+//===----------------------------------------------------------------------===//<br>+<br>+#include "llvm/ADT/Triple.h"<br>+#include "llvm/Config/config.h"<br>+#include "llvm/DebugInfo.h"<br>+#include "llvm/DIBuilder.h"<br>+#include "llvm/IR/Module.h"<br>+#include "llvm/Support/Host.h"<br>+#include "llvm/Support/FileSystem.h"<br>+#include "llvm/Support/Path.h"<br>+#include "llvm/Transforms/Instrumentation.h"<br>+<br>+#include "../lib/Transforms/Instrumentation/DebugIR.h"<br>+<br>+// These tests do not depend on MCJIT, but we use the TrivialModuleBuilder<br>+// helper class to construct some trivial Modules.<br>+#include "../unittests/ExecutionEngine/MCJIT/MCJITTestBase.h"<br>+<br>+#include <string><br>+<br>+#include "gtest/gtest.h"<br>+<br>+using namespace llvm;<br>+using namespace std;<br>+<br>+namespace {<br>+<br>+/// Insert a mock CUDescriptor with the specified producer<br>+void insertCUDescriptor(Module *M, StringRef File, StringRef Dir,<br>+ StringRef Producer) {<br>+ DIBuilder B(*M);<br>+ B.createCompileUnit(dwarf::DW_LANG_C99, File, Dir, Producer, false, "", 0);<br>+ B.finalize();<br>+}<br>+<br>+/// Attempts to remove file at Path and returns true if it existed, or false if<br>+/// it did not.<br>+bool removeIfExists(StringRef Path) {<br>+ bool existed = false;<br>+ sys::fs::remove(Path, existed);<br>+ return existed;<br>+}<br>+<br>+class TestDebugIR : public ::testing::Test, public TrivialModuleBuilder {<br>+protected:<br>+ TestDebugIR()<br>+ : TrivialModuleBuilder(sys::getProcessTriple())<br>+#ifdef HAVE_GETCWD<br>+ ,<br>+ cwd(get_current_dir_name())<br>+#else<br>+ ,<br>+ cwd(0)<br>+#endif<br>+ {<br>+ }<br>+<br>+ ~TestDebugIR() { free(cwd); }<br>+<br>+ /// Returns a concatenated path string consisting of Dir and Filename<br>+ string getPath(const string &Dir, const string &Filename) {<br>+ SmallVector<char, 8> Path;<br>+ sys::path::append(Path, Dir, Filename);<br>+ Path.resize(Dir.size() + Filename.size() + 2);<br>+ Path[Dir.size() + Filename.size() + 1] = '\0';<br>+ return string(Path.data());<br>+ }<br>+<br>+ LLVMContext Context;<br>+ char *cwd;<br>+ OwningPtr<Module> M;<br>+ OwningPtr<DebugIR> D;<br>+};<br>+<br>+// Test empty named Module that is not supposed to be output to disk.<br>+TEST_F(TestDebugIR, EmptyNamedModuleNoWrite) {<br>+ string name = "/mock/path/to/empty_module.ll";<br>+ M.reset(createEmptyModule(name));<br>+ D.reset(static_cast<DebugIR *>(llvm::createDebugIRPass()));<br>+ string Path;<br>+ D->runOnModule(*M, Path);<br>+<br>+ // verify DebugIR was able to correctly parse the file name from module ID<br>+ ASSERT_EQ(Path, name);<br>+<br>+ // verify DebugIR did not generate a file<br>+ ASSERT_FALSE(removeIfExists(Path)) << "Unexpected file " << Path;<br>+}<br>+<br>+// Test a non-empty unnamed module that is output to an autogenerated file name.<br>+TEST_F(TestDebugIR, NonEmptyUnnamedModuleWriteToAutogeneratedFile) {<br>+ M.reset(createEmptyModule());<br>+ insertAddFunction(M.get());<br>+ D.reset(static_cast<DebugIR *>(llvm::createDebugIRPass(true, true)));<br>+<br>+ string Path;<br>+ D->runOnModule(*M, Path);<br>+<br>+ // verify DebugIR generated a file, and clean it up<br>+ ASSERT_TRUE(removeIfExists(Path)) << "Missing expected file at " << Path;<br>+}<br>+<br>+// Test not specifying a name in the module -- DebugIR should generate a name<br>+// and write the file contents.<br>+TEST_F(TestDebugIR, EmptyModuleWriteAnonymousFile) {<br>+ M.reset(createEmptyModule());<br>+ D.reset(static_cast<DebugIR *>(llvm::createDebugIRPass(false, false)));<br>+<br>+ string Path;<br>+ D->runOnModule(*M, Path);<br>+<br>+ // verify DebugIR generated a file and clean it up<br>+ ASSERT_TRUE(removeIfExists(Path)) << "Missing expected file at " << Path;<br>+}<br>+<br>+#ifdef HAVE_GETCWD // These tests require get_current_dir_name()<br>+<br>+// Test empty named Module that is to be output to path specified at Module<br>+// construction.<br>+TEST_F(TestDebugIR, EmptyNamedModuleWriteFile) {<br>+ string Filename("NamedFile1");<br>+ string ExpectedPath(getPath(cwd, Filename));<br>+<br>+ M.reset(createEmptyModule(ExpectedPath));<br>+ D.reset(static_cast<DebugIR *>(llvm::createDebugIRPass(true, true)));<br>+<br>+ string Path;<br>+ D->runOnModule(*M, Path);<br>+<br>+ // verify DebugIR was able to correctly parse the file name from module ID<br>+ ASSERT_EQ(ExpectedPath, Path);<br>+<br>+ // verify DebugIR generated a file, and clean it up<br>+ ASSERT_TRUE(removeIfExists(Path)) << "Missing expected file at " << Path;<br>+}<br>+<br>+// Test an empty unnamed module generates an output file whose path is specified<br>+// at DebugIR construction.<br>+TEST_F(TestDebugIR, EmptyUnnamedModuleWriteNamedFile) {<br>+ string Filename("NamedFile2");<br>+<br>+ M.reset(createEmptyModule());<br>+ D.reset(static_cast<DebugIR *>(llvm::createDebugIRPass(<br>+ false, false, StringRef(cwd), StringRef(Filename))));<br>+ string Path;<br>+ D->runOnModule(*M, Path);<br>+<br>+ string ExpectedPath(getPath(cwd, Filename));<br>+ ASSERT_EQ(ExpectedPath, Path);<br>+<br>+ // verify DebugIR generated a file, and clean it up<br>+ ASSERT_TRUE(removeIfExists(Path)) << "Missing expected file at " << Path;<br>+}<br>+<br>+// Test an empty named module generates an output file at the path specified<br>+// during DebugIR construction.<br>+TEST_F(TestDebugIR, EmptyNamedModuleWriteNamedFile) {<br>+ string Filename("NamedFile3");<br>+<br>+ string UnexpectedPath(getPath(cwd, "UnexpectedFilename"));<br>+ M.reset(createEmptyModule(UnexpectedPath));<br>+<br>+ D.reset(static_cast<DebugIR *>(llvm::createDebugIRPass(<br>+ false, false, StringRef(cwd), StringRef(Filename))));<br>+ string Path;<br>+ D->runOnModule(*M, Path);<br>+<br>+ string ExpectedPath(getPath(cwd, Filename));<br>+ ASSERT_EQ(ExpectedPath, Path);<br>+<br>+ // verify DebugIR generated a file, and clean it up<br>+ ASSERT_TRUE(removeIfExists(Path)) << "Missing expected file at " << Path;<br>+<br>+ // verify DebugIR did not generate a file at the path specified at Module<br>+ // construction.<br>+ ASSERT_FALSE(removeIfExists(UnexpectedPath)) << "Unexpected file " << Path;<br>+}<br>+<br>+// Test a non-empty named module that is not supposed to be output to disk<br>+TEST_F(TestDebugIR, NonEmptyNamedModuleNoWrite) {<br>+ string Filename("NamedFile4");<br>+ string ExpectedPath(getPath(cwd, Filename));<br>+<br>+ M.reset(createEmptyModule(ExpectedPath));<br>+ insertAddFunction(M.get());<br>+<br>+ D.reset(static_cast<DebugIR *>(llvm::createDebugIRPass()));<br>+<br>+ string Path;<br>+ D->runOnModule(*M, Path);<br>+ ASSERT_EQ(ExpectedPath, Path);<br>+<br>+ // verify DebugIR did not generate a file<br>+ ASSERT_FALSE(removeIfExists(Path)) << "Unexpected file " << Path;<br>+}<br>+<br>+// Test a non-empty named module that is output to disk.<br>+TEST_F(TestDebugIR, NonEmptyNamedModuleWriteFile) {<br>+ string Filename("NamedFile5");<br>+ string ExpectedPath(getPath(cwd, Filename));<br>+<br>+ M.reset(createEmptyModule(ExpectedPath));<br>+ insertAddFunction(M.get());<br>+<br>+ D.reset(static_cast<DebugIR *>(llvm::createDebugIRPass(true, true)));<br>+<br>+ string Path;<br>+ D->runOnModule(*M, Path);<br>+ ASSERT_EQ(ExpectedPath, Path);<br>+<br>+ // verify DebugIR generated a file, and clean it up<br>+ ASSERT_TRUE(removeIfExists(Path)) << "Missing expected file at " << Path;<br>+}<br>+<br>+// Test a non-empty unnamed module is output to a path specified at DebugIR<br>+// construction.<br>+TEST_F(TestDebugIR, NonEmptyUnnamedModuleWriteToNamedFile) {<br>+ string Filename("NamedFile6");<br>+<br>+ M.reset(createEmptyModule());<br>+ insertAddFunction(M.get());<br>+<br>+ D.reset(static_cast<DebugIR *>(<br>+ llvm::createDebugIRPass(true, true, cwd, Filename)));<br>+ string Path;<br>+ D->runOnModule(*M, Path);<br>+<br>+ string ExpectedPath(getPath(cwd, Filename));<br>+ ASSERT_EQ(ExpectedPath, Path);<br>+<br>+ // verify DebugIR generated a file, and clean it up<br>+ ASSERT_TRUE(removeIfExists(Path)) << "Missing expected file at " << Path;<br>+}<br>+<br>+// Test that information inside existing debug metadata is retained<br>+TEST_F(TestDebugIR, ExistingMetadataRetained) {<br>+ string Filename("NamedFile7");<br>+ string ExpectedPath(getPath(cwd, Filename));<br>+<br>+ M.reset(createEmptyModule(ExpectedPath));<br>+ insertAddFunction(M.get());<br>+<br>+ StringRef Producer("TestProducer");<br>+ insertCUDescriptor(M.get(), Filename, cwd, Producer);<br>+<br>+ DebugInfoFinder Finder;<br>+ Finder.processModule(*M);<br>+ ASSERT_EQ((unsigned)1, Finder.compile_unit_count());<br>+ D.reset(static_cast<DebugIR *>(llvm::createDebugIRPass()));<br>+<br>+ string Path;<br>+ D->runOnModule(*M, Path);<br>+ ASSERT_EQ(ExpectedPath, Path);<br>+<br>+ // verify DebugIR did not generate a file<br>+ ASSERT_FALSE(removeIfExists(Path)) << "Unexpected file " << Path;<br>+<br>+ DICompileUnit CU(*Finder.compile_unit_begin());<br>+<br>+ // Verify original CU information is retained<br>+ ASSERT_EQ(Filename, CU.getFilename());<br>+ ASSERT_EQ(cwd, CU.getDirectory());<br>+ ASSERT_EQ(Producer, CU.getProducer());<br>+}<br>+<br>+#endif // HAVE_GETCWD<br>+<br>+#ifdef GTEST_HAS_DEATH_TEST<br>+<br>+// Test a non-empty unnamed module that is not supposed to be output to disk<br>+// NOTE: this test is expected to die with LLVM_ERROR, and such depends on<br>+// google test's "death test" mode.<br>+TEST_F(TestDebugIR, NonEmptyUnnamedModuleNoWrite) {<br>+ M.reset(createEmptyModule(StringRef()));<br>+ insertAddFunction(M.get());<br>+ D.reset(static_cast<DebugIR *>(llvm::createDebugIRPass()));<br>+<br>+ // No name in module or on DebugIR construction ==> DebugIR should assert<br>+ EXPECT_DEATH(D->runOnModule(*M),<br>+ "DebugIR unable to determine file name in input.");<br>+}<br>+<br>+#endif // GTEST_HAS_DEATH_TEST<br>+}<br><br>Added: llvm/trunk/unittests/Transforms/DebugIR/Makefile<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/DebugIR/Makefile?rev=185212&view=auto">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/DebugIR/Makefile?rev=185212&view=auto</a><br>==============================================================================<br>--- llvm/trunk/unittests/Transforms/DebugIR/Makefile (added)<br>+++ llvm/trunk/unittests/Transforms/DebugIR/Makefile Fri Jun 28 15:37:20 2013<br>@@ -0,0 +1,15 @@<br>+##===- unittests/Transforms/Utils/Makefile -----------------*- Makefile -*-===##<br>+#<br>+# The LLVM Compiler Infrastructure<br>+#<br>+# This file is distributed under the University of Illinois Open Source<br>+# License. See LICENSE.TXT for details.<br>+#<br>+##===----------------------------------------------------------------------===##<br>+<br>+LEVEL = ../../..<br>+TESTNAME = DebugIR<br>+LINK_COMPONENTS := Instrumentation<br>+<br>+include $(LEVEL)/Makefile.config<br>+include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest<br><br>Modified: llvm/trunk/unittests/Transforms/Makefile<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/Makefile?rev=185212&r1=185211&r2=185212&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/Makefile?rev=185212&r1=185211&r2=185212&view=diff</a><br>==============================================================================<br>--- llvm/trunk/unittests/Transforms/Makefile (original)<br>+++ llvm/trunk/unittests/Transforms/Makefile Fri Jun 28 15:37:20 2013<br>@@ -9,7 +9,7 @@<br><br>LEVEL = ../..<br><br>-PARALLEL_DIRS = Utils<br>+PARALLEL_DIRS = DebugIR Utils<br><br>include $(LEVEL)/Makefile.common<br><br><br><br>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a></div></blockquote></div><br></div></body></html>