Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Change D98884 broke bootstrap build on x32 (x86_64 with 32-bit pointers) #48830

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR49861
Status NEW
Importance P enhancement
Reported by John Paul Adrian Glaubitz (glaubitz@physik.fu-berlin.de)
Reported on 2021-04-06 07:16:54 -0700
Last modified on 2021-06-05 11:17:48 -0700
Version trunk
Hardware PC Linux
CC craig.topper@gmail.com, harald@gigawatt.nl, jrtc27@jrtc27.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, madhur13490@gmail.com, pengfei.wang@intel.com, spatel+llvm@rotateright.com, stanislav.mekhanoshin@amd.com
Fixed by commit(s)
Attachments cpu_model-3ac5e8.c (97717 bytes, text/x-csrc)
cpu_model-3ac5e8.sh (4847 bytes, application/x-shellscript)
Blocks
Blocked by
See also
Since D98884, the bootstrap build on x32 (x86_64 with 32-bit pointers) fails
with:

[46/3990] Building C object projects/compiler-
rt/lib/builtins/CMakeFiles/clang_rt.builtins-x86_64.dir/cpu_model.c.o
FAILED: projects/compiler-rt/lib/builtins/CMakeFiles/clang_rt.builtins-
x86_64.dir/cpu_model.c.o
/glaubitz/llvm-project/stage1.install/bin/clang -DVISIBILITY_HIDDEN -D_DEBUG -
D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D_LARGEFILE_SOURCE -
D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -
Iprojects/compiler-rt/lib/builtins -I/glaubitz/llvm-project/compiler-
rt/lib/builtins -Iinclude -I/glaubitz/llvm-project/llvm/include -fPIC -
Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-
parameter -Wwrite-strings -Wmissing-field-initializers -pedantic -Wno-long-long
-Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -
Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -ffunction-
sections -fdata-sections -Wall -Wno-unused-parameter -O3   -m64 -fno-lto -
std=c11 -UNDEBUG -MD -MT projects/compiler-
rt/lib/builtins/CMakeFiles/clang_rt.builtins-x86_64.dir/cpu_model.c.o -MF
projects/compiler-rt/lib/builtins/CMakeFiles/clang_rt.builtins-
x86_64.dir/cpu_model.c.o.d -o projects/compiler-
rt/lib/builtins/CMakeFiles/clang_rt.builtins-x86_64.dir/cpu_model.c.o -c
/glaubitz/llvm-project/compiler-rt/lib/builtins/cpu_model.c
clang: /glaubitz/llvm-project/llvm/include/llvm/Support/Casting.h:269: typename
llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X = llvm::CallBase; Y =
llvm::User; typename llvm::cast_retty<X, Y*>::ret_type = llvm::CallBase*]:
Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /glaubitz/llvm-project/stage1.install/bin/clang -
DVISIBILITY_HIDDEN -D_DEBUG -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -
D_LARGEFILE_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -
D__STDC_LIMIT_MACROS -Iprojects/compiler-rt/lib/builtins -I/glaubitz/llvm-
project/compiler-rt/lib/builtins -Iinclude -I/glaubitz/llvm-
project/llvm/include -fPIC -Werror=date-time -Werror=unguarded-availability-new
-Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wmissing-field-
initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-
fallthrough -Wcovered-switch-default -Wdelete-non-virtual-dtor -Wstring-
conversion -fdiagnostics-color -ffunction-sections -fdata-sections -Wall -Wno-
unused-parameter -O3 -m64 -fno-lto -std=c11 -UNDEBUG -MD -MT projects/compiler-
rt/lib/builtins/CMakeFiles/clang_rt.builtins-x86_64.dir/cpu_model.c.o -MF
projects/compiler-rt/lib/builtins/CMakeFiles/clang_rt.builtins-
x86_64.dir/cpu_model.c.o.d -o projects/compiler-
rt/lib/builtins/CMakeFiles/clang_rt.builtins-x86_64.dir/cpu_model.c.o -c
/glaubitz/llvm-project/compiler-rt/lib/builtins/cpu_model.c
1.      <eof> parser at end of file
2.      Optimizer
 #0 0x01b23df2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/glaubitz/llvm-project/stage1.install/bin/clang+0x1b23df2)
 #1 0x01b21e10 llvm::sys::RunSignalHandlers() (/glaubitz/llvm-project/stage1.install/bin/clang+0x1b21e10)
 #2 0x01a8ea17 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0xfffffffff7f021e0 __restore_rt (/lib/x86_64-linux-gnux32/libpthread.so.0+0x131e0)
 #4 0xfffffffff7a2886d raise (/lib/x86_64-linux-gnux32/libc.so.6+0x3286d)
 #5 0xfffffffff7a12515 abort (/lib/x86_64-linux-gnux32/libc.so.6+0x1c515)
 #6 0xfffffffff7a123fe (/lib/x86_64-linux-gnux32/libc.so.6+0x1c3fe)
 #7 0xfffffffff7a211ff (/lib/x86_64-linux-gnux32/libc.so.6+0x2b1ff)
 #8 0x019f65c0 llvm::runIPSCCP(llvm::Module&, llvm::DataLayout const&, std::function<llvm::TargetLibraryInfo const& (llvm::Function&)>, llvm::function_ref<llvm::AnalysisResultsForFn (llvm::Function&)>) (/glaubitz/llvm-project/stage1.install/bin/clang+0x19f65c0)
 #9 0x015d3b7d llvm::IPSCCPPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/glaubitz/llvm-project/stage1.install/bin/clang+0x15d3b7d)
#10 0x02ae78dd llvm::detail::PassModel<llvm::Module, llvm::IPSCCPPass,
llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>
>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/glaubitz/llvm-
project/stage1.install/bin/clang+0x2ae78dd)
#11 0x0146f513 llvm::PassManager<llvm::Module,
llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&,
llvm::AnalysisManager<llvm::Module>&) (/glaubitz/llvm-
project/stage1.install/bin/clang+0x146f513)
#12 0x01de06a1 (anonymous
namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >) (.constprop.0)
BackendUtil.cpp:0:0
#13 0x01de3ae2 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout
const&, llvm::Module*, clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >) (/glaubitz/llvm-
project/stage1.install/bin/clang+0x1de3ae2)
#14 0x02a844dd
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/glaubitz/llvm-project/stage1.install/bin/clang+0x2a844dd)
#15 0x0368be90 clang::ParseAST(clang::Sema&, bool, bool) (/glaubitz/llvm-
project/stage1.install/bin/clang+0x368be90)
#16 0x02424b3c clang::FrontendAction::Execute() (/glaubitz/llvm-
project/stage1.install/bin/clang+0x2424b3c)
#17 0x023bb424 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/glaubitz/llvm-project/stage1.install/bin/clang+0x23bb424)
#18 0x024e0fd3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/glaubitz/llvm-project/stage1.install/bin/clang+0x24e0fd3)
#19 0x008dd673 cc1_main(llvm::ArrayRef<char const*>, char const*, void*)
(/glaubitz/llvm-project/stage1.install/bin/clang+0x8dd673)
#20 0x008d921d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
driver.cpp:0:0
#21 0x02262c99 void llvm::function_ref<void
()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const::'lambda'()>(int) Job.cpp:0:0
#22 0x01a8eb8d llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void
()>) (/glaubitz/llvm-project/stage1.install/bin/clang+0x1a8eb8d)
#23 0x02263ecb
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const (.part.0) Job.cpp:0:0
#24 0x0223911c
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const (/glaubitz/llvm-
project/stage1.install/bin/clang+0x223911c)
#25 0x02239b37 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList
const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
const (/glaubitz/llvm-project/stage1.install/bin/clang+0x2239b37)
#26 0x022452f4
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/glaubitz/llvm-project/stage1.install/bin/clang+0x22452f4)
#27 0x0085ecea main (/glaubitz/llvm-project/stage1.install/bin/clang+0x85ecea)
#28 0xfffffffff7a13da2 __libc_start_main (/lib/x86_64-linux-
gnux32/libc.so.6+0x1dda2)
#29 0x008d8bbb _start (/glaubitz/llvm-project/stage1.install/bin/clang+0x8d8bbb)
clang-13: error: clang frontend command failed with exit code 134 (use -v to
see invocation)
clang version 13.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /glaubitz/llvm-project/stage1.install/bin
clang-13: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-13: note: diagnostic msg: /tmp/cpu_model-3ac5e8.c
clang-13: note: diagnostic msg: /tmp/cpu_model-3ac5e8.sh
clang-13: note: diagnostic msg:

********************

I assume this assertion needs to be fine-tuned/adopted for x32:

Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
Quuxplusone commented 3 years ago

Attached cpu_model-3ac5e8.c (97717 bytes, text/x-csrc): Preprocessed source.

Quuxplusone commented 3 years ago

Attached cpu_model-3ac5e8.sh (4847 bytes, application/x-shellscript): Run script for preprocessed source.

Quuxplusone commented 3 years ago

@John, Can you please attach bitcode/IR? I am not able to compile the test with the provided configuration.

Quuxplusone commented 3 years ago
Reduced test:

$ cat bug.c
static int a() { return 1; }
void b() { a(); }
$ bin/clang --target=x86_64-linux-gnu -c -O3 bug.c
clang: /home/harald/llvm-project/llvm/include/llvm/Support/Casting.h:269:
typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X =
llvm::CallBase; Y = llvm::User; typename llvm::cast_retty<X, Y*>::ret_type =
llvm::CallBase*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of
incompatible type!"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
[...]
$ bin/clang -v
clang version 13.0.0 (https://github.com/llvm/llvm-project/
167ea67d76c297eb5dd3fa5f4ffc3c85e1842faa)
Target: x86_64-pc-linux-gnux32
Thread model: posix
InstalledDir: /home/harald/llvm-project/stage1/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnux32/10
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnux32/10
Candidate multilib: .;@mx32
Candidate multilib: 64;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@mx32

I cannot provide an IR test case as with -save-temps the error disappears.
Quuxplusone commented 3 years ago

D98884 was reverted at rGfb6a5237aa73e42d476f3736afcd531a593d3c33 - would it be possible to get a regression test committed before D98884 is committed again?

Quuxplusone commented 3 years ago
(In reply to Simon Pilgrim from comment #5)
> D98884 was reverted at rGfb6a5237aa73e42d476f3736afcd531a593d3c33 - would it
> be possible to get a regression test committed before D98884 is committed
> again?

You mean, test with the latest revision of the patch (haven't checked the
current status of D98884 yet, but I also didn't get any update notification)?
Quuxplusone commented 3 years ago
(In reply to John Paul Adrian Glaubitz from comment #6)
> (In reply to Simon Pilgrim from comment #5)
> > D98884 was reverted at rGfb6a5237aa73e42d476f3736afcd531a593d3c33 - would it
> > be possible to get a regression test committed before D98884 is committed
> > again?
>
> You mean, test with the latest revision of the patch (haven't checked the
> current status of D98884 yet, but I also didn't get any update notification)?

Not necessarily, I was thinking you could add a suitably reduced test case that
failed with the previous implementation to help Madhur so that any future
version of D98884 is known to correctly handle it before its committed.
Quuxplusone commented 3 years ago

Once I root caused the issue I will do bootstrap builds and that should confirm if it is fixed or not.

Quuxplusone commented 3 years ago
(In reply to Simon Pilgrim from comment #7)
> > You mean, test with the latest revision of the patch (haven't checked the
> > current status of D98884 yet, but I also didn't get any update
notification)?
>
> Not necessarily, I was thinking you could add a suitably reduced test case
> that failed with the previous implementation to help Madhur so that any
> future version of D98884 is known to correctly handle it before its
> committed.

If I remember correctly, the change broke the build for multiple architectures,
not just x86_64-32. I think ppc64el was affected as well.