Skip to content

Commit 751655a

Browse files
jeanPeriermemfrob
authored andcommitted
[flang] Add Pre-FIR Tree structure to help lowering the parse-tree
The Pre-FIR Tree structure is a transient data structure that is meant to be built from the parse tree just before lowering to FIR and that will be deleted just afterwards. It is not meant to perfrom optimization analysis and transformations. It only provides temporary information, such as label target information or parse tree parent nodes, that is meant to be used to lower the parse tree structure into FIR operations. A PFTBuilder class builds the Pre-Fir Tree from the parse-tree. A pretty printer is available to visualize this data structure. - Lit tests are added to: 1. that the PFT tree structure is as expected 2. that the PFT captures all intented nodes - Cmake changes: Prevent warnings inisde LLVM headers when compiling flang The issue is that some LLVM headers define functions where the usage of the parameters depend on environment ifdef. See for instance Size in: https://github.com/llvm/llvm-project/blob/5f940220bf9438e95ffa4a627ac1591be1e1ba6e/llvm/include/llvm/Support/Compiler.h#L574 Because flang is build with -Werror and -Wunused-parameter is default in clang, this may breaks build in some environments (like with clang9 on macos). A solution would be to add -Wno-unused-parameter to flang CmakLists.txt, but it is wished to keep this warning on flang sources for quality purposes. Fixing LLVM headers is not an easy task and `[[maybe_unused]]` is C++17 and cannot be used yet in LLVM headers. Hence, this fix simply silence warnings coming from LLVM headers by telling CMake they are to be considered as if they were system headers. - drone.io changes: remove llvm 6.0 from clang config in drone.io and link flang with libstdc++ instead of libc++ llvm-dev resolved to llvm-6.0 in clang builds on drone.io. llvm 6.0 too old. LLVM packages are linked with libstdc++ standard library whereas libc++ was used for flang. This caused link time failure when building clang. Change frone.io to build flang with libc++. Note: This commit does not reflect an actual work log, it is a feature based split of the changes done in the FIR experimental branch. The related work log can be found in the commits between: 864898cbe509d032abfe1172ec367dbd3dd92bc1 and 137c23da9c64cf90584cf81fd646053a69e91f63 Other changes come from flang-compiler/f18#959 review. Original-commit: flang-compiler/f18@edb0943 Reviewed-on: flang-compiler/f18#959
1 parent b448ae2 commit 751655a

16 files changed

+1735
-7
lines changed

flang/.drone.star

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ def clang(arch):
77
"name": "test",
88
"image": "ubuntu",
99
"commands": [
10-
"apt-get update && apt-get install -y clang-8 cmake ninja-build lld-8 llvm-dev libc++-8-dev libc++abi-8-dev libz-dev",
10+
"apt-get update && apt-get install -y clang-8 cmake ninja-build lld-8 llvm-8-dev libc++-8-dev libc++abi-8-dev libz-dev",
1111
"mkdir build && cd build",
12-
'env CC=clang-8 CXX=clang++-8 CXXFLAGS="-UNDEBUG -stdlib=libc++" LDFLAGS="-fuse-ld=lld" cmake -GNinja -DCMAKE_BUILD_TYPE=Release ..',
12+
'env CC=clang-8 CXX=clang++-8 CXXFLAGS="-UNDEBUG" LDFLAGS="-fuse-ld=lld" cmake -GNinja -DCMAKE_BUILD_TYPE=Release ..',
1313
"ninja -j8",
1414
"ctest --output-on-failure -j24",
1515
],

flang/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,14 @@ include(AddLLVM)
7070
# https://stackoverflow.com/questions/41924375/llvm-how-to-specify-all-link-libraries-as-input-to-llvm-map-components-to-libna
7171
# https://stackoverflow.com/questions/33948633/how-do-i-link-when-building-with-llvm-libraries
7272

73-
include_directories(${LLVM_INCLUDE_DIRS})
73+
# Add LLVM include files as if they were SYSTEM because there are complex unused
74+
# parameter issues that may or may not appear depending on the environments and
75+
# compilers (ifdefs are involved). This allows warnings from LLVM headers to be
76+
# ignored while keeping -Wunused-parameter a fatal error inside f18 code base.
77+
# This may have to be fine-tuned if flang headers are consider part of this
78+
# LLVM_INCLUDE_DIRS when merging in the monorepo (Warning from flang headers
79+
# should not be suppressed).
80+
include_directories(SYSTEM ${LLVM_INCLUDE_DIRS})
7481
add_definitions(${LLVM_DEFINITIONS})
7582

7683
# LLVM_LIT_EXTERNAL store in cache so it could be used by AddLLVM.cmake

0 commit comments

Comments
 (0)