[LLVMdev] strange dbgs() behavior: unable to print floats in machine backend
Bjorn De Sutter
bjorn.desutter at elis.ugent.be
Mon Nov 26 06:00:01 PST 2012
Hi,
I am trying to debug my backend, and observe very strange behavior with dbgs():
In the IfConverter, I have added two debugging lines that print floating-point numbers for the sake of demonstration that such printing works fine.
bool MeetIfcvtSizeLimit(MachineBasicBlock &BB,
unsigned Cycle, unsigned Extra,
const BranchProbability &Prediction) const {
dbgs() << "OOPS " << 1.14 << "\n";
bool flag = Cycle > 0 && TII->isProfitableToIfCvt(BB, Cycle, Extra,
Prediction);
dbgs() << "OOPS " << 1.15 << "\n";
return flag;
}
This method invokes the backend method
bool ADRESInstrInfo::isProfitableToIfCvt(MachineBasicBlock &MBB, unsigned NumCycles, unsigned ExtraPredCycles,
const BranchProbability &Probability) const {
dbgs() << "OOPS " << 1.16 << "\n";
}
This invocation works as it should (verified with gdb). But when I execute this code fragment, I get
OOPS 1.140000e+00
OOPS %physreg1
OOPS 1.150000e+00
So suddenly in the machine backend, the dbgs() ostream (which is still the very same ostream as in the IfConverter, I checked the address with gdb) prints floating point numbers as if they are physical registers. Any idea what is going on or how I can force floating-point numbers to be printed in the backend code? I want to do that to tune my if-predication heuristics ...
By the way, when I step through the isProfitableToIfCvt method, rather than invoking a <<-operator in an ostream class, the constructor of the Twine class is invoked ...
Thanks,
Bjorn De Sutter
Computer Systems Lab
Ghent University
More information about the llvm-dev
mailing list