-
Notifications
You must be signed in to change notification settings - Fork 31
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
Port release_90 patches to LLVM 10 monorepo #1
Port release_90 patches to LLVM 10 monorepo #1
Conversation
Cherry-picked eddca9f374bd7b4b4038909b609771cb2203f927.
Cherry-picked 9d840227b8e054f05ccc0dea90c28a68c47ea8c7: We don't want to include calls to pthread_[sg]etname_np() as they are glibc 2.12 functions and SLES uses glibc 2.11 by default.
@bryanpkc Is the CI (results above) running from your repository? Is it expected to fail? |
@kiranchandramohan I think those CI jobs came from the GitHub Actions that are configured for your repository: https://github.com/flang-compiler/classic-flang-llvm-project/actions These CI jobs are probably incorrect or irrelevant. For our purpose, a useful CI job should build llvm-project with |
I found a bug in my branch; I will push a fix shortly. |
Classic flang had no pre-commit CI on any repositories before so these were not pre-existing CI configs. Presumably you made a fork of llvm/llvm-project to make flang-compiler/classic-flang-llvm-project? Is it possible that these were somehow inherited from llvm/llvm-project when the fork was made?
From: Bryan Chan <notifications@github.com>
Sent: 21 August, 2020 23:07
To: flang-compiler/classic-flang-llvm-project <classic-flang-llvm-project@noreply.github.com>
Cc: Richard Barton <Richard.Barton@arm.com>; Review requested <review_requested@noreply.github.com>
Subject: Re: [flang-compiler/classic-flang-llvm-project] Port release_90 patches to LLVM 10 monorepo (#1)
I found a bug in my branch; I will push a fix shortly.
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub<#1 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AKKGCW5XZ7K6IAZA5E2CKCTSB3VXRANCNFSM4QEAMWHQ>.
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
|
The master branch in classic-flang-llvm-project does not contain a It's not a bad idea to have some CI jobs to ensure that this repo is functionally correct, and especially can still build Clang normally. |
I have fixed this pull request to allow normal Clang builds and regression tests to succeed, except for the two tests mentioned in issue #2. Ideally we should fix those tests too so that we have a clean branch. This port adds a |
Was able to build flang with this monorepo using the build instructions provided. Copying the build instructions below (has trivial modifications to work with this monorepo). All tests in flang passes on Aarch64, two tests in llvm debug fails as @bryanpkc mentions. I will go through the code next.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two quick questions.
I notice that the build instructions you have do not use the FLANG_LLVM_EXTENSIONS flag while building flang. If you use this flag then there will be DIGlobalVariables without the name field. This happens because there is some code (see link below) in lldebug.cpp which removes names of artificial variables. The simplest testcase to reproduce the issue is,
|
I based my build instructions on the official build instructions which also did not mention |
@kiranchandramohan I believe it is best to combine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As someone who has been involved in monorepo and driver work elsewhere, this looks broadly good to me. I've reviewed this by studying the diff-of-the-diff vs the release_90 branches on flang-compiler/flang-driver
and flang-compiler/llvm
.
I think it's possible to simplify the driver, removing the FlangFrontend and instead using the Compiler phase. I've published my preliminary patch, which I will submit for review after this PR has landed, or you're welcome to incorporate those changes here if you feel that is appropriate. I don't mind rebasing as needed for any changes you want to make or include in this patch.
I've highlighted some small issues. I don't think fixing them all needs to hold this PR back.
- I'd like to see the warning fixed, please.
- I think merging the two
#define
s into one is a good idea and have a personal preference forUSE_CLASSIC_FLANG
, but I'm sure other names would be fine too.
ab8a623
to
9269268
Compare
Cherry-picked commit 2085211cfcca70411dc63f0d08763facc8a02090 by Eric Schweitz, resolved merge conflicts, fixed build failures (e.g. adapted CGDebugInfo.cpp to the new API), and fixed the DIGlobalVariable unit tests, which have been broken since commit edfad65eebdf045b050f37380b6b61d673513982.
Cherry-picked cabccf8f2d00daf1d740b18a1c80e9b5f4593f60.
Cherry-picked c51f89679135f84675f492d560ec5535c2000cfe by Varun Jayathirtha, and resolved merge conflicts. To avoid conflicts with the new Flang, lib/Driver/ToolChains/Flang.{cpp,h} have been renamed to ClassicFlang.{cpp,h}, and the ENABLE_CLASSIC_FLANG macro is introduced to select which incarnation of Flang to build. The macro is set by running CMake with -DLLVM_ENABLE_CLASSIC_FLANG.
Add a new lit feature tag "classic_flang" to select which tests can or cannot be run when the driver is built for classic Flang. Handle LLVM_ENABLE_CLASSIC_FLANG in llvm/cmake/modules/HandleLLVMOptions.cmake instead of clang/CMakeLists.txt so that macro works in both clang and llvm.
9269268
to
71a49a0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Builds and passes make check-all (llvm and flang) with a Release build on a AArch64 machine.
This now needs approval from @gklimowicz and @shivaramaarao. |
I'm working on this today. It may not be done until Wednesday. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. build passed and also the tests passed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes for classic-flang-llvm-project look fine to me. I have run across 2 failures in check-clang
on OpenPOWER, though. The first is in f90_correct/fc30
. The second is in f90_correct/ls07
.
These failures do not occur on LLVM 10 x86_64 or aarch64.
After digging into these failures, they appear to be related to how LLVM 10 on Power is handling negative zeros during the computation of COMPLEX multiplies. The two tests fail when they generate -0.0
for the imaginary part of a COMPLEX number, when the test results are expecting 0.0
.
These need to be investigated further. There's a slight chance these are related to the driver changes in the pull request. It seems more likely to be on the LLVM 10 code-gen side.
I see no reason at this time to hold up approval of this pull request, though.
I have pushed flang-compiler/flang#927 to exclude the test failures in f90_correct and created an issue flang-compiler/flang#928 to track their fix. |
@kiranchandramohan I don't have merge privilege in this repository. Could you merge this PR, or give me the access please? I think the PR is good to go now that we have a workaround (even if it hasn't been merged) for the test failures. |
@bryanpkc I am adding you to the organization, and then will make sure that you have merge privileges. |
@bryanpkc I hope @gklimowicz has given you commit access and u can merge now. If not then please let me know. |
@kiranchandramohan @gklimowicz has added me to the organization but I don't have merge privilege for this repository yet. |
OK @bryanpkc, i can merge. Is merge (no rebase or squash) the best action here? |
Please rebase if necessary, but do not squash. Keeping the historical commits separate make them easier to rebase to future release branches. Thank you. |
Flang works on llvm-10 now. Thanks @bryanpkc for your help. |
Thanks very much @kiranchandramohan. |
@peterwaller-arm Could you submit a pull request for your patch (peterwaller-arm/classic-flang-llvm-project@9078d6c4c8b7)? |
@bryanpkc As discussed in the Flang call yesterday (7/10/20), feel free to cherry-pick that patch and submit it on behalf of Peter. We discussed this with @peterwaller-arm offline and decided that that would be the preferred way. Peter is currently on a different project and I'm actively working on the driver for the LLVM Flang. If you need reviewers, I volunteer :) |
I've published a rebase on https://github.com/peterwaller-arm/classic-flang-llvm-project/tree/simplify-driver, that's peterwaller-arm@10dacac. It would be great if someone can pick it up and run with it. It has an issue: currently the classic_flang.f95 test fails, because the driver thinks that flang is capable of emitting assembly. I think what's going on is that ToolSelector::getTool is combining flang+llvm here: https://github.com/peterwaller-arm/classic-flang-llvm-project/blob/10dacac072ded415449e7350c7ba67c2b500f576/clang/lib/Driver/Driver.cpp#L4110-L4113 As far as I know that is the only issue, but it needs testing with flang and I don't have time to dive in to this for a bit. |
When `Target::GetEntryPointAddress()` calls `exe_module->GetObjectFile()->GetEntryPointAddress()`, and the returned `entry_addr` is valid, it can immediately be returned. However, just before that, an `llvm::Error` value has been setup, but in this case it is not consumed before returning, like is done further below in the function. In https://bugs.freebsd.org/248745 we got a bug report for this, where a very simple test case aborts and dumps core: ``` * thread #1, name = 'testcase', stop reason = breakpoint 1.1 frame #0: 0x00000000002018d4 testcase`main(argc=1, argv=0x00007fffffffea18) at testcase.c:3:5 1 int main(int argc, char *argv[]) 2 { -> 3 return 0; 4 } (lldb) p argc Program aborted due to an unhandled Error: Error value was Success. (Note: Success values must still be checked prior to being destroyed). Thread 1 received signal SIGABRT, Aborted. thr_kill () at thr_kill.S:3 3 thr_kill.S: No such file or directory. (gdb) bt #0 thr_kill () at thr_kill.S:3 #1 0x00000008049a0004 in __raise (s=6) at /usr/src/lib/libc/gen/raise.c:52 #2 0x0000000804916229 in abort () at /usr/src/lib/libc/stdlib/abort.c:67 #3 0x000000000451b5f5 in fatalUncheckedError () at /usr/src/contrib/llvm-project/llvm/lib/Support/Error.cpp:112 #4 0x00000000019cf008 in GetEntryPointAddress () at /usr/src/contrib/llvm-project/llvm/include/llvm/Support/Error.h:267 flang-compiler#5 0x0000000001bccbd8 in ConstructorSetup () at /usr/src/contrib/llvm-project/lldb/source/Target/ThreadPlanCallFunction.cpp:67 flang-compiler#6 0x0000000001bcd2c0 in ThreadPlanCallFunction () at /usr/src/contrib/llvm-project/lldb/source/Target/ThreadPlanCallFunction.cpp:114 flang-compiler#7 0x00000000020076d4 in InferiorCallMmap () at /usr/src/contrib/llvm-project/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp:97 flang-compiler#8 0x0000000001f4be33 in DoAllocateMemory () at /usr/src/contrib/llvm-project/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp:604 flang-compiler#9 0x0000000001fe51b9 in AllocatePage () at /usr/src/contrib/llvm-project/lldb/source/Target/Memory.cpp:347 flang-compiler#10 0x0000000001fe5385 in AllocateMemory () at /usr/src/contrib/llvm-project/lldb/source/Target/Memory.cpp:383 flang-compiler#11 0x0000000001974da2 in AllocateMemory () at /usr/src/contrib/llvm-project/lldb/source/Target/Process.cpp:2301 flang-compiler#12 CanJIT () at /usr/src/contrib/llvm-project/lldb/source/Target/Process.cpp:2331 flang-compiler#13 0x0000000001a1bf3d in Evaluate () at /usr/src/contrib/llvm-project/lldb/source/Expression/UserExpression.cpp:190 flang-compiler#14 0x00000000019ce7a2 in EvaluateExpression () at /usr/src/contrib/llvm-project/lldb/source/Target/Target.cpp:2372 flang-compiler#15 0x0000000001ad784c in EvaluateExpression () at /usr/src/contrib/llvm-project/lldb/source/Commands/CommandObjectExpression.cpp:414 flang-compiler#16 0x0000000001ad86ae in DoExecute () at /usr/src/contrib/llvm-project/lldb/source/Commands/CommandObjectExpression.cpp:646 flang-compiler#17 0x0000000001a5e3ed in Execute () at /usr/src/contrib/llvm-project/lldb/source/Interpreter/CommandObject.cpp:1003 flang-compiler#18 0x0000000001a6c4a3 in HandleCommand () at /usr/src/contrib/llvm-project/lldb/source/Interpreter/CommandInterpreter.cpp:1762 flang-compiler#19 0x0000000001a6f98c in IOHandlerInputComplete () at /usr/src/contrib/llvm-project/lldb/source/Interpreter/CommandInterpreter.cpp:2760 flang-compiler#20 0x0000000001a90b08 in Run () at /usr/src/contrib/llvm-project/lldb/source/Core/IOHandler.cpp:548 flang-compiler#21 0x00000000019a6c6a in ExecuteIOHandlers () at /usr/src/contrib/llvm-project/lldb/source/Core/Debugger.cpp:903 flang-compiler#22 0x0000000001a70337 in RunCommandInterpreter () at /usr/src/contrib/llvm-project/lldb/source/Interpreter/CommandInterpreter.cpp:2946 flang-compiler#23 0x0000000001d9d812 in RunCommandInterpreter () at /usr/src/contrib/llvm-project/lldb/source/API/SBDebugger.cpp:1169 flang-compiler#24 0x0000000001918be8 in MainLoop () at /usr/src/contrib/llvm-project/lldb/tools/driver/Driver.cpp:675 flang-compiler#25 0x000000000191a114 in main () at /usr/src/contrib/llvm-project/lldb/tools/driver/Driver.cpp:890``` Fix the incorrect error catch by only instantiating an `Error` object if it is necessary. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D86355 (cherry picked from commit 1ce07cd)
This patch re-introduces the fix in the commit llvm/llvm-project@66b0cebf7f736 by @yrnkrn > In DwarfEHPrepare, after all passes are run, RewindFunction may be a dangling > > pointer to a dead function. To make sure it's valid, doFinalization nullptrs > RewindFunction just like the constructor and so it will be found on next run. > > llvm-svn: 217737 It seems that the fix was not migrated to `DwarfEHPrepareLegacyPass`. This patch also updates `llvm/test/CodeGen/X86/dwarf-eh-prepare.ll` to include `-run-twice` to exercise the cleanup. Without this patch `llvm-lit -v llvm/test/CodeGen/X86/dwarf-eh-prepare.ll` fails with ``` -- Testing: 1 tests, 1 workers -- FAIL: LLVM :: CodeGen/X86/dwarf-eh-prepare.ll (1 of 1) ******************** TEST 'LLVM :: CodeGen/X86/dwarf-eh-prepare.ll' FAILED ******************** Script: -- : 'RUN: at line 1'; /home/arakaki/build/llvm-project/main/bin/opt -mtriple=x86_64-linux-gnu -dwarfehprepare -simplifycfg-require-and-preserve-domtree=1 -run-twice < /home/arakaki/repos/watch/llvm-project/llvm/test/CodeGen/X86/dwarf-eh-prepare.ll -S | /home/arakaki/build/llvm-project/main/bin/FileCheck /home/arakaki/repos/watch/llvm-project/llvm/test/CodeGen/X86/dwarf-eh-prepare.ll -- Exit Code: 2 Command Output (stderr): -- Referencing function in another module! call void @_Unwind_Resume(i8* %ehptr) #1 ; ModuleID = '<stdin>' void (i8*)* @_Unwind_Resume ; ModuleID = '<stdin>' in function simple_cleanup_catch LLVM ERROR: Broken function found, compilation aborted! PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace. Stack dump: 0. Program arguments: /home/arakaki/build/llvm-project/main/bin/opt -mtriple=x86_64-linux-gnu -dwarfehprepare -simplifycfg-require-and-preserve-domtree=1 -run-twice -S 1. Running pass 'Function Pass Manager' on module '<stdin>'. 2. Running pass 'Module Verifier' on function '@simple_cleanup_catch' #0 0x000056121b570a2c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/arakaki/repos/watch/llvm-project/llvm/lib/Support/Unix/Signals.inc:569:0 #1 0x000056121b56eb64 llvm::sys::RunSignalHandlers() /home/arakaki/repos/watch/llvm-project/llvm/lib/Support/Signals.cpp:97:0 #2 0x000056121b56f28e SignalHandler(int) /home/arakaki/repos/watch/llvm-project/llvm/lib/Support/Unix/Signals.inc:397:0 #3 0x00007fc7e9b22980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980) #4 0x00007fc7e87d3fb7 raise /build/glibc-S7xCS9/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0 #5 0x00007fc7e87d5921 abort /build/glibc-S7xCS9/glibc-2.27/stdlib/abort.c:81:0 #6 0x000056121b4e1386 llvm::raw_svector_ostream::raw_svector_ostream(llvm::SmallVectorImpl<char>&) /home/arakaki/repos/watch/llvm-project/llvm/include/llvm/Support/raw_ostream.h:674:0 #7 0x000056121b4e1386 llvm::report_fatal_error(llvm::Twine const&, bool) /home/arakaki/repos/watch/llvm-project/llvm/lib/Support/ErrorHandling.cpp:114:0 #8 0x000056121b4e1528 (/home/arakaki/build/llvm-project/main/bin/opt+0x29e3528) #9 0x000056121adfd03f llvm::raw_ostream::operator<<(llvm::StringRef) /home/arakaki/repos/watch/llvm-project/llvm/include/llvm/Support/raw_ostream.h:218:0 FileCheck error: '<stdin>' is empty. FileCheck command line: /home/arakaki/build/llvm-project/main/bin/FileCheck /home/arakaki/repos/watch/llvm-project/llvm/test/CodeGen/X86/dwarf-eh-prepare.ll -- ******************** ******************** Failed Tests (1): LLVM :: CodeGen/X86/dwarf-eh-prepare.ll Testing Time: 0.22s Failed: 1 ``` Reviewed By: loladiro Differential Revision: https://reviews.llvm.org/D110979 (cherry picked from commit e8806d7)
In the latest Linux kernels synchronous tag faults include the tag bits in their address. This change adds logical and allocation tags to the description of synchronous tag faults. (asynchronous faults have no address) Process 1626 stopped * thread flang-compiler#1, name = 'a.out', stop reason = signal SIGSEGV: sync tag check fault (fault address: 0x900fffff7ff9010 logical tag: 0x9 allocation tag: 0x0) This extends the existing description and will show as much as it can on the rare occasion something fails. This change supports AArch64 MTE only but other architectures could be added by extending the switch at the start of AnnotateSyncTagCheckFault. The rest of the function is generic code. Tests have been added for synchronous and asynchronous MTE faults. Reviewed By: omjavaid Differential Revision: https://reviews.llvm.org/D105178 (cherry picked from commit d510b5f)
We experienced some deadlocks when we used multiple threads for logging using `scan-builds` intercept-build tool when we used multiple threads by e.g. logging `make -j16` ``` (gdb) bt #0 0x00007f2bb3aff110 in __lll_lock_wait () from /lib/x86_64-linux-gnu/libpthread.so.0 flang-compiler#1 0x00007f2bb3af70a3 in pthread_mutex_lock () from /lib/x86_64-linux-gnu/libpthread.so.0 flang-compiler#2 0x00007f2bb3d152e4 in ?? () flang-compiler#3 0x00007ffcc5f0cc80 in ?? () flang-compiler#4 0x00007f2bb3d2bf5b in ?? () from /lib64/ld-linux-x86-64.so.2 flang-compiler#5 0x00007f2bb3b5da27 in ?? () from /lib/x86_64-linux-gnu/libc.so.6 flang-compiler#6 0x00007f2bb3b5dbe0 in exit () from /lib/x86_64-linux-gnu/libc.so.6 flang-compiler#7 0x00007f2bb3d144ee in ?? () flang-compiler#8 0x746e692f706d742f in ?? () flang-compiler#9 0x692d747065637265 in ?? () flang-compiler#10 0x2f653631326b3034 in ?? () flang-compiler#11 0x646d632e35353532 in ?? () flang-compiler#12 0x0000000000000000 in ?? () ``` I think the gcc's exit call caused the injected `libear.so` to be unloaded by the `ld`, which in turn called the `void on_unload() __attribute__((destructor))`. That tried to acquire an already locked mutex which was left locked in the `bear_report_call()` call, that probably encountered some error and returned early when it forgot to unlock the mutex. All of these are speculation since from the backtrace I could not verify if frames 2 and 3 are in fact corresponding to the `libear.so` module. But I think it's a fairly safe bet. So, hereby I'm releasing the held mutex on *all paths*, even if some failure happens. PS: I would use lock_guards, but it's C. Reviewed-by: NoQ Differential Revision: https://reviews.llvm.org/D118439 (cherry picked from commit d919d02)
This pull request cherry-picks all relevant patches from the
release_90
branches in https://github.com/flang-compiler/flang-driver and https://github.com/flang-compiler/llvm, adapts them to fit the monorepo layout, and adjusts the Classic Flang code to let it coexist with the new Flang. To build the code, run CMake with-DLLVM_ENABLE_CLASSIC_FLANG=on
.See https://github.com/Huawei-PTLab/classic-flang-llvm/wiki for an example build script.