Check-in [504ceb334b]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Dump bitcode to files after module verification, to try to debug optimizer crashes. Commit missing changes to the debug helper for better phi handling.
Timelines: family | ancestors | descendants | both | notworking | kbk-nre
Files: files | file ages | folders
SHA3-256: 504ceb334bd134dbe77d61b508917bfec264bd3728227a9f2b15bf31d33bbdc5
User & Date: kbk 2018-04-16 23:46:34.410
Context
2018-04-17
00:11
Merge trunk: expunge last uses of 'uniqueUndef' in constructing phi's check-in: 1855f5dc7a user: kbk tags: notworking, kbk-nre
2018-04-16
23:46
Dump bitcode to files after module verification, to try to debug optimizer crashes. Commit missing changes to the debug helper for better phi handling. check-in: 504ceb334b user: kbk tags: notworking, kbk-nre
01:09
Merge trunk to get better handling of 'phi' operations. Fix issues that prevented compilability with these changes. check-in: bc9590bbdb user: kbk tags: notworking, kbk-nre
Changes
Unified Diff Ignore Whitespace Patch
Changes to codegen/jit.tcl.
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182








183
184
185
186
187
188
189
		$thunkBuilder finalize
	    }

	    timeit dump-pre {
		# Save the current IR
		variable dumpPre [$module dump]
		variable bitcodePre [$module bitcode]
		set f_ [open test.bc wb]
		puts -nonewline $f_ $bitcodePre
		close $f_
		set f_ [open test.ll w]
		puts $f_ $dumpPre
		close $f_
	    }

	    # Check that what we have is actually correct!
	    $module verify
	    if {$debug} {
		parray ::useCount
	    }









	    timeit optimize {
		# Run the LLVM IR optimizer. The configuration of this is in
		# llvmtcl and is due to Jos Decoster.
		$module optimize $optimiseLevel
	    }








<
<
<
<
<
<







>
>
>
>
>
>
>
>







163
164
165
166
167
168
169






170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
		$thunkBuilder finalize
	    }

	    timeit dump-pre {
		# Save the current IR
		variable dumpPre [$module dump]
		variable bitcodePre [$module bitcode]






	    }

	    # Check that what we have is actually correct!
	    $module verify
	    if {$debug} {
		parray ::useCount
	    }
	    set bitcodeFinal [$module bitcode]
	    set f_ [open test.bc wb]
	    puts -nonewline $f_ $bitcodeFinal
	    close $f_
	    set dumpFinal [$module dump]
	    set f_ [open test.ll w]
	    puts $f_ $dumpFinal
	    close $f_

	    timeit optimize {
		# Run the LLVM IR optimizer. The configuration of this is in
		# llvmtcl and is due to Jos Decoster.
		$module optimize $optimiseLevel
	    }

Changes to codegen/struct.tcl.
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
    #	None.
    #
    # Results:
    #	None.

    method FinalizeDebuggingMetadata {} {
	if {[info exist dbbuild]} {
	    puts "Finalizing the debug metadata..."
	    try {
		my debug destroy
	    } on error msg {
		puts ERROR:$msg
	    }
	    oo::objdefine [self] deletemethod debug
	    unset -nocomplain dbbuild







<







84
85
86
87
88
89
90

91
92
93
94
95
96
97
    #	None.
    #
    # Results:
    #	None.

    method FinalizeDebuggingMetadata {} {
	if {[info exist dbbuild]} {

	    try {
		my debug destroy
	    } on error msg {
		puts ERROR:$msg
	    }
	    oo::objdefine [self] deletemethod debug
	    unset -nocomplain dbbuild
2325
2326
2327
2328
2329
2330
2331


2332
2333
2334
2335
2336
2337
2338
2339
2340

2341
2342
2343
2344
2345
2346
2347
2348
	    # entry point.
	    set cur [$BuildSupportBuilder @cur]
	    $BuildSupportBuilder @end $entry

	    # Insert the line number tracking
	    set script [$BuildSupportBuilder AddLineDirectives $linenumber $filename $script]



	    # Construct the wrapping lambda term.
	    set initvars {upvar 1}
	    foreach v [uplevel 1 {info vars}] {
		lappend initvars $v $v
	    }
	    append initvars ";"
	    foreach name $blockNames block $blocks {
		append initvars [list set $name $block] ";"
	    }

	    set lambda [list {} $initvars$script [uplevel 1 namespace current]]

	    # Run the script. This will pick up the caller's current variables
	    # yet limit the variables inside the script to just the script.
	    try {
		uplevel 1 [list apply $lambda]
	    } on error {a opt} {
		# Strip the parts of the stack trace that are confusing bits







>
>









>
|







2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
	    # entry point.
	    set cur [$BuildSupportBuilder @cur]
	    $BuildSupportBuilder @end $entry

	    # Insert the line number tracking
	    set script [$BuildSupportBuilder AddLineDirectives $linenumber $filename $script]

            set startBlock {set @phis@ {};}
	    set endBlock {;FixupPhis}     
	    # Construct the wrapping lambda term.
	    set initvars {upvar 1}
	    foreach v [uplevel 1 {info vars}] {
		lappend initvars $v $v
	    }
	    append initvars ";"
	    foreach name $blockNames block $blocks {
		append initvars [list set $name $block] ";"
	    }
	    set lambda [list {} $startBlock$initvars$script$endBlock \
			    [uplevel 1 namespace current]]

	    # Run the script. This will pick up the caller's current variables
	    # yet limit the variables inside the script to just the script.
	    try {
		uplevel 1 [list apply $lambda]
	    } on error {a opt} {
		# Strip the parts of the stack trace that are confusing bits
2361
2362
2363
2364
2365
2366
2367


































































2368
2369
2370
2371
2372
2373
2374
	    $func verify
	    $BuildSupportBuilder @end $cur
	    uplevel 1 [list unset {*}$params]
	    unset params
	    }
	    return
	}


































































    }
}

# Class LLVMBuilder --
#
#	This class handles actual LLVM instruction issuing. It consists of
#	wrappers for the calls into the llvmtcl code. The wrappers try to







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
	    $func verify
	    $BuildSupportBuilder @end $cur
	    uplevel 1 [list unset {*}$params]
	    unset params
	    }
	    return
	}

	# PHI --
	#
	#	Generate a phi node with automatic fixup at the end of a
	#	'build' sequence
	#
	# Parameters:
	#	type    - Data type of the result. All the inputs must have
	#		  exactly this type.
	#	sources - Basic blocks from which the data sources to the
	#	          phi operation come
	#	values  - Values to feed into the phi from the corresponding
	#	          data sources
	#	name (Optional) - A name to give to the result
	#
	# Results:
	#	Returns a reference to the phi node
	#
	# Side effects:
	#	Stores data regarding the fixup in the variable '@phis@'
	#	in the caller

	proc PHI {type sources values {name {}}} {
	    upvar 1 @phis@ phis
	    set phi [uplevel 1 [list my phiStub $type $name]]
	    lappend phis $phi $sources $values
	    return $phi
	}

	# FixupPhis --
	#
	#	Backpatch the phi operations generated by PHI to have their
	#	correct sources and values.
	#
	# Results:
	#	None.
	#
	# Side effects:
	#	Performs the backpatching using the information in the
	#	variable '@phis@' in the caller's frame

	proc FixupPhis {} {
	    upvar 1 @phis@ phis
	    foreach {phi sources values} $phis {
		set sources \
		    [uplevel 1 [list subst -nobackslashes -nocommands $sources]]
		set values \
		    [uplevel 1 [list subst -nobackslashes -nocommands $values]]
		if {[llength $sources] != [llength $values]} {
		    return -code error "Expected [llength $sources] values,\
                                        but found [llength $values] in\
                                        [PrintValueToString $phi]"
		}
		foreach s $sources v $values {
		    if {[TypeOf $v] ne [TypeOf $phi]} {
			return -code error \
			    "Expected a value of type\
                             [PrintTypeToString [TypeOf $phi]]\
                             for [PrintValueTosString $phi] but found\
                             [PrintTypeToString [TypeOf $v]]"
		    }
		    set label [uplevel 1 [list my LABEL $source]]
		    AddIncoming $phi $value $label
		}
	    }
	}
    }
}

# Class LLVMBuilder --
#
#	This class handles actual LLVM instruction issuing. It consists of
#	wrappers for the calls into the llvmtcl code. The wrappers try to
Changes to demos/perftest/tester.tcl.
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
    calltest3
    # Callframe tests
    callframe::test1
    callframe::test2
    callframe::test3
    callframe::test4
    # The interprocedural tests
    # mrtest::*				NO NRE
    coscaller1
    coscaller2
    xsum xsum2
    # Namespace tests
    nstestaux::pts
    nstest::nstest0
    nstest::nstest1







|







2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
    calltest3
    # Callframe tests
    callframe::test1
    callframe::test2
    callframe::test3
    callframe::test4
    # The interprocedural tests
    mrtest::*
    coscaller1
    coscaller2
    xsum xsum2
    # Namespace tests
    nstestaux::pts
    nstest::nstest0
    nstest::nstest1
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
    expandtest::test10
    expandtest::test11
    expandtest::test12

    # Combined feature tests
    lcmRange
    bug-0616bcf08e::*
    # rectest1				NO NRE
    # qsort				NO NRE
    impure
    impure-caller
    impure-typecheck-int
    impure2
    comps
    bug-7c599d4029::*
    singleton::*







|
|







2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
    expandtest::test10
    expandtest::test11
    expandtest::test12

    # Combined feature tests
    lcmRange
    bug-0616bcf08e::*
    rectest1
    qsort
    impure
    impure-caller
    impure-typecheck-int
    impure2
    comps
    bug-7c599d4029::*
    singleton::*