File: plugins_newpm.txt

package info (click to toggle)
llvm-toolchain-15 1%3A15.0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,554,644 kB
  • sloc: cpp: 5,922,452; ansic: 1,012,136; asm: 674,362; python: 191,568; objc: 73,855; f90: 42,327; lisp: 31,913; pascal: 11,973; javascript: 10,144; sh: 9,421; perl: 7,447; ml: 5,527; awk: 3,523; makefile: 2,520; xml: 885; cs: 573; fortran: 567
file content (38 lines) | stat: -rw-r--r-- 1,250 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Tests LLVM pass using new pass manager. Based on https://llvm.org/docs/WritingAnLLVMNewPMPass.html
# RUN: rm -rf %t
# RUN: mkdir -p %t/_build
# RUN: cat %s > %t/CMakeLists.txt
# RUN: cp %S/Inputs/llvm_newpm_pass.cpp %t
# RUN: cd %t/_build
# RUN: %cmake .. -DCMAKE_C_COMPILER=%cc -DCMAKE_CXX_COMPILER=%cxx -DLLVM_DIR=`%llvm-config --cmakedir`
# RUN: %cmake --build .
# RUN: %clang -emit-llvm -O3 -c %S/Inputs/foo.c -o llvm-ir.bc
# RUN: %opt -load-pass-plugin=./HelloPass.so -disable-output ./llvm-ir.bc  -passes=hellonewpm 2> %t.output
# RUN: grep "Function name: foo" %t.output
# REQUIRES: opt, clang

cmake_minimum_required(VERSION 3.4.3)

project(TestLLVMPass)
find_package(LLVM REQUIRED CONFIG)
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
include(AddLLVM)

# Starting LLVM 16, std=c++17 is required
if(LLVM_PACKAGE_VERSION VERSION_GREATER_EQUAL "16.0.0")
    set(CMAKE_CXX_STANDARD 17 CACHE STRING "")
else()
    set(CMAKE_CXX_STANDARD 14 CACHE STRING "")
endif()

add_llvm_library(HelloPass MODULE llvm_newpm_pass.cpp)

# Add LLVM headers filled from find_package
target_include_directories(HelloPass
    PRIVATE ${LLVM_INCLUDE_DIRS}
)

# LLVM's compile definitions
target_compile_definitions(HelloPass
    PRIVATE ${LLVM_DEFINITIONS}
)