-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[powerpc-darwin][AsmPrinter] addis instruction expects 0 instead of r0 #18690
Comments
Odd; this should already have been fixed (ADDIS uses the gprc_nor0 input register class, which should use PPC::ZERO to represent r0, and PPC::ZERO should print as "0"). Can you tell from where this addis is coming? (you can probably use bugpoint to create a reduced test case). |
function containing faulty addis instruction % /Volumes/Isolde/sources/LLVM-svn/gcc40-cmake-build/bin/clang++ -DLLVMX86CodeGen_EXPORTS -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/usr/lib/gcc/powerpc-apple-darwin8/4.0.1/include -fno-common -no-integrated-as -fno-dwarf2-cfi-asm -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic -Wno-long-long -Wnon-virtual-dtor -fno-rtti -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fPIC -I/Users/fang/local/src/LLVM-svn/gcc40-stage2-build/lib/Target/X86 -I/Users/fang/local/src/LLVM-svn/llvm/lib/Target/X86 -I/Users/fang/local/src/LLVM-svn/gcc40-stage2-build/include -I/Users/fang/local/src/LLVM-svn/llvm/include -fno-exceptions -fno-exceptions -o CMakeFiles/LLVMX86CodeGen.dir/X86ISelLowering.cpp.o -c /Users/fang/local/src/LLVM-svn/llvm/lib/Target/X86/X86ISelLowering.cpp -save-temps Attached is the asm of the function that contains the lone instance of addis rX, r0, Y My workaround was to manually recompile this unit with -integrated-as (which then allowed stage-2 to finish). |
reduced test case #18690 .ii: struct SDNode; struct SDValue { struct SDLoc { struct ISD { struct SelectionDAG { namespace X86ISD { SDValue LowerMUL(SDValue Op, SelectionDAG &DAG) { invocation: % grep addis #18690 .s | grep r0 I had trouble reducing further because the asm was sensitive to struct sizes and call sites. Hope this suffices. |
llvm-mc seems to do the right thing and print r0 as 0. % cat in.s
The output from the reduced test case might be going through some different code path to print that. |
Please attach the input LLVM IR, so that I can debug this problem. (running Clang with -S -emit-llvm should do it). |
At least as of r200461, I don't see any addis instructions generated from this input (running it through llc or llc -O0). |
The original test case X86ISelLowering.cpp no longer triggers the error, however, the reduced test case from comment 3 still does: % /Volumes/Isolde/sources/LLVM-svn/gcc40-cmake-build/bin/clang++ -no-integrated-as -o #18690 .o -c #18690 .ii -save-temps -v Can you try that test case with the above cc1 command? (instead of the .ll) |
I'm sync'd to r200717. |
I had trouble getting llc to fail on the already attached .ll, but clang was able to use it: "/Volumes/Isolde/builds/LLVM/gcc40-cmake-build/bin/clang-3.5" -cc1 -triple powerpc-apple-macosx10.4.0 -S -disable-free -main-file-name #18690 .ll -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -v -coverage-file /var/tmp/#18316 -8d1aa6.s -resource-dir /Volumes/Isolde/builds/LLVM/gcc40-cmake-build/bin/../lib/clang/3.5 -fno-dwarf2-cfi-asm -fno-dwarf-directory-asm -fno-autolink -fdebug-compilation-dir /Users/fang/temp/clang/#18316 -ferror-limit 19 -fmessage-length 80 -mstackrealign -malign-power -fblocks -fblocks-runtime-optional -fobjc-runtime=macosx-10.4.0 -fencode-extended-block-signature -fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -o /var/tmp/#18316 -8d1aa6.s -x ir #18690 .ll |
even simpler cc1: temp.s should contain around line 467: Also reproducible with -fno-dwarf2-cfi-asm, which is needed on darwin8. |
bugpoint reduced test case |
The ADDIS is coming from the regular add pattern: ISEL: Starting pattern match on root node: 0x70b7480: i32 = add 0x70b4430, 0x70b2c70 [ORD=29] [ID=66] which was:
If we make sure to allocate the global base register from the non-r0 register class, then this problem goes away ;) -- r203054. |
Fix confirmed on powerpc-darwin8! (I now get r30 where there was r0 before.) |
Extended Description
During my stage-2 build of powerpc-darwin8 clang, stage-1 clang was found to emit some assembly that was rejected by the system assembler (including the 'as' from odcctools-2009).
% cat addis.s
addis r30, 0, 1 ; OK
addis r30, r1, 1 ; OK
addis r30, r0, 1 : rejected
% as addis.s -o addis.o
addis.s:3:Parameter error: r0 not allowed for parameter 2 (code as 0 not r0)
Apparently, r0 is special enough to warrant different syntax in certain contexts.
Would it be possible to emit such instructions differently?
The PPC darwin asm parser, accepts all of the above:
% ~/local/src/LLVM-svn/gcc40-cmake-build/bin/llvm-mc -triple powerpc-apple-darwin8 addis.s -filetype=obj -o addis.o
I don't mind keeping that as-is, but if you want tighter conformity, you could mimic the darwin assembler behavior.
I think it's more important to emit darwin-asm-friendly code so that -no-integrated-as continues to work.
The text was updated successfully, but these errors were encountered: