Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

LoopAligner pass fallout on Sparc/Solaris #2260

Closed Quuxplusone closed 16 years ago

Quuxplusone commented 16 years ago
Bugzilla Link PR2112
Status RESOLVED FIXED
Importance P normal
Reported by Gabor Greif (ggreif@gmail.com)
Reported on 2008-02-29 05:59:12 -0800
Last modified on 2008-02-29 11:53:36 -0800
Version unspecified
Hardware Sun Solaris
CC evan.cheng@apple.com, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments LoopAligner.patch (582 bytes, text/plain)
Blocks
Blocked by
See also
I get this crash on SPARCv8:

(gdb) run ggg.bc -f
Starting program: .../llvm/Debug/bin/llc ggg.bc -f
warning: Temporarily disabling breakpoints for unloaded shared library
"/usr/lib/ld.so.1"
warning: Lowest section in /lib/libpthread.so.1 is .dynamic at 00000074

Program received signal SIGSEGV, Segmentation fault.
0x0095fd68 in llvm::TargetLowering::getPrefLoopAlignment (this=0x0)
    at .../llvm/include/llvm/Target/TargetLowering.h:566
566       return PrefLoopAlignment;
(gdb) bt
#0  0x0095fd68 in llvm::TargetLowering::getPrefLoopAlignment (this=0x0)
    at .../llvm/include/llvm/Target/TargetLowering.h:566
#1  0x0095f67c in (anonymous namespace)::LoopAligner::runOnMachineFunction
(this=0xd387f0, MF=@0xd42e90)
    at LoopAligner.cpp:54
#2  0x00481e28 in llvm::MachineFunctionPass::runOnFunction (this=0xd387f0,
F=@0xd3b150)
    at .../llvm/include/llvm/CodeGen/MachineFunctionPass.h:41
#3  0x00ba4a70 in llvm::FPPassManager::runOnFunction (this=0xd3a8c8,
F=@0xd3b150) at PassManager.cpp:1170
#4  0x00ba4704 in llvm::FunctionPassManagerImpl::run (this=0xd3a5e0,
F=@0xd3b150) at PassManager.cpp:1128
#5  0x00ba4590 in llvm::FunctionPassManager::run (this=0xffbff400, F=@0xd3b150)
at PassManager.cpp:1073
#6  0x00413e9c in main (argc=3, argv=0xffbff4bc) at llc.cpp:296
(gdb) up
#1  0x0095f67c in (anonymous namespace)::LoopAligner::runOnMachineFunction
(this=0xd387f0, MF=@0xd42e90)
    at LoopAligner.cpp:54
54      unsigned Align = MF.getTarget().getTargetLowering()-
>getPrefLoopAlignment();

It appears that on Sparc no TargetLowering object is allocated and LoopAligner
does not guard against this condition.

Three solution attempts come to my mind:

1) Install a TargetLowering for Sparc too.
2) Guard against TargetLowering == NULL in LoopAligner
3) Do not register with LoopAligner when there is no TargetLowering installed.

1) looks best to me, but other people may prefer 3). 2) probably makes little
sense.

Ah, the test in question is CodeGen/Generic/GC/alloc_loop.ll
but many others fail too.
Quuxplusone commented 16 years ago

Attached LoopAligner.patch (582 bytes, text/plain): this implements the second suggestion

Quuxplusone commented 16 years ago
Fixed. Thanks!
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20080225/058986.html