Fix __Slow files getting compiled with OPT_FAST, bug1370.

This commit is contained in:
Wilson Snyder 2018-11-29 20:35:21 -05:00
parent 2e5919549c
commit 49353784fd
5 changed files with 68 additions and 24 deletions

View File

@ -20,6 +20,8 @@ The contributors that suggested a given feature are shown in []. Thanks!
**** Fix crash due to cygwin bug in getline, bug1349. [Affe Mao]
**** Fix __Slow files getting compiled with OPT_FAST, bug1370. [Thomas Watts]
* Verilator 4.006 2018-10-27

View File

@ -167,17 +167,19 @@ $(VM_PREFIX)__ALL.a: $(VK_OBJS)
### Compile rules
ifneq ($(VM_DEFAULT_RULES),0)
$(VM_PREFIX)__ALLsup.o: $(VM_PREFIX)__ALLsup.cpp
$(OBJCACHE) $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OPT_SLOW) -c -o $@ $<
$(VM_PREFIX)__ALLcls.o: $(VM_PREFIX)__ALLcls.cpp
$(OBJCACHE) $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OPT_FAST) -c -o $@ $<
$(VM_PREFIX)%__Slow.o: $(VM_PREFIX)%__Slow.cpp
$(VM_PREFIX)__ALLsup.o: $(VM_PREFIX)__ALLsup.cpp
$(OBJCACHE) $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OPT_SLOW) -c -o $@ $<
$(VM_PREFIX)%.o: $(VM_PREFIX)%.cpp
# VM_GLOBAL_FAST files including verilated.o use this rule
%.o: %.cpp
$(OBJCACHE) $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OPT_FAST) -c -o $@ $<
%__Slow.o: %__Slow.cpp
$(OBJCACHE) $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OPT_SLOW) -c -o $@ $<
endif
#Default rule embedded in make:
@ -189,7 +191,10 @@ endif
debug-make::
@echo
@echo CXXFLAGS: $(CXXFLAGS)
@echo CPPFLAGS: $(CPPFLAGS)
@echo OPT_FAST: $(OPT_FAST)
@echo OPT_SLOW: $(OPT_SLOW)
@echo VM_PREFIX: $(VM_PREFIX)
@echo VM_PARALLEL_BUILDS: $(VM_PARALLEL_BUILDS)
@echo VM_CLASSES_FAST: $(VM_CLASSES_FAST)

View File

@ -2730,10 +2730,11 @@ class EmitCTrace : EmitCStmts {
// METHODS
void newOutCFile(int filenum) {
string filename = (v3Global.opt.makeDir()+"/"+ topClassName()
+ (m_slow?"__Trace__Slow":"__Trace"));
if (filenum) filename += "__"+cvtToStr(filenum);
filename += ".cpp";
string filename = (v3Global.opt.makeDir()+"/"+ topClassName()
+"__Trace");
if (filenum) filename += "__"+cvtToStr(filenum);
filename += (m_slow ? "__Slow":"");
filename += ".cpp";
AstCFile* cfilep = newCFile(filename, m_slow, true/*source*/);
cfilep->support(true);

View File

@ -10,25 +10,45 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(vlt_all => 1);
compile(
v_flags2 => ["--trace --output-split 1 --output-split-cfuncs 1"],
v_flags2 => ["--trace --output-split 1 --output-split-cfuncs 1 --exe ../$Self->{main_filename}"],
verilator_make_gcc => 0,
);
# We don't use the standard test_regress rules, as want to test the rules
# properly build
run(logfile=>"$Self->{obj_dir}/vlt_gcc.log",
cmd=>["make",
"-C ".$Self->{obj_dir},
"-f $Self->{VM_PREFIX}.mk",
"-j 4",
"VM_PARALLEL_BUILDS=1", # Important to this test
"VM_PREFIX=$Self->{VM_PREFIX}",
"TEST_OBJ_DIR=$Self->{obj_dir}",
"CPPFLAGS_DRIVER=-D".uc($Self->{name}),
($opt_verbose ? "CPPFLAGS_DRIVER2=-DTEST_VERBOSE=1":""),
"OPT_FAST=-O2",
"OPT_SLOW=-O0",
($param{make_flags}||""),
]);
execute(
check_finished => 1,
);
my $got1;
foreach my $file (glob("$Self->{obj_dir}/*.cpp")) {
$got1 = 1 if $file =~ /__1/;
check($file);
{
my $got1;
foreach my $file (glob("$Self->{obj_dir}/*.cpp")) {
$got1 = 1 if $file =~ /__1/;
check_cpp($file);
}
$got1 or error("No __1 split file found");
}
$got1 or error("No __1 split file found");
check_gcc_flags("$Self->{obj_dir}/vlt_gcc.log");
ok(1);
1;
sub check {
sub check_cpp {
my $filename = shift;
my $size = -s $filename;
printf " File %6d %s\n", $size, $filename if $Self->{verbose};
@ -53,3 +73,19 @@ sub check {
error("Split had multiple functions in $filename\n\t".join("\n\t",@funcs));
}
}
sub check_gcc_flags {
my $filename = shift;
my $fh = IO::File->new("<$filename") or error("$! $filenme");
while (defined (my $line = $fh->getline)) {
chomp $line;
if ($line =~ /\.cpp/) {
my $filetype = ($line =~ /Slow/) ? "slow":"fast";
my $opt = ($line !~ /-O2/) ? "slow":"fast";
print "$filetype, $opt, $line\n";
if ($filetype ne $opt) {
error("${filetype} file compiled as if was ${opt}: $line");
}
}
}
}

View File

@ -9,9 +9,9 @@ module t (/*AUTOARG*/
);
input clk;
integer cyc=0;
integer cyc=0;
parameter CNT = 10;
parameter CNT = 5;
wire [31:0] w [CNT:0];
@ -33,13 +33,13 @@ module t (/*AUTOARG*/
else if (cyc<90) begin
end
else if (cyc==99) begin
`define EXPECTED_SUM 32'h123e
`define EXPECTED_SUM 32'h1239
`ifdef TEST_VERBOSE
$write("[%0t] cyc==%0d sum=%x\n",$time, cyc, w[CNT]);
$write("[%0t] cyc==%0d sum=%x\n",$time, cyc, w[CNT]);
`endif
if (w[CNT] !== `EXPECTED_SUM) $stop;
$write("*-* All Finished *-*\n");
$finish;
if (w[CNT] !== `EXPECTED_SUM) $stop;
$write("*-* All Finished *-*\n");
$finish;
end
end