comparison tools/bugpoint-passes/TestPasses.cpp @ 147:c2174574ed3a

LLVM 10
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 14 Aug 2019 16:55:33 +0900
parents 3a76565eade5
children
comparison
equal deleted inserted replaced
134:3a76565eade5 147:c2174574ed3a
1 //===- TestPasses.cpp - "buggy" passes used to test bugpoint --------------===// 1 //===- TestPasses.cpp - "buggy" passes used to test bugpoint --------------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // 4 // See https://llvm.org/LICENSE.txt for license information.
5 // This file is distributed under the University of Illinois Open Source 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 // License. See LICENSE.TXT for details.
7 // 6 //
8 //===----------------------------------------------------------------------===// 7 //===----------------------------------------------------------------------===//
9 // 8 //
10 // This file contains "buggy" passes that are used to test bugpoint, to check 9 // This file contains "buggy" passes that are used to test bugpoint, to check
11 // that it is narrowing down testcases correctly. 10 // that it is narrowing down testcases correctly.
121 120
122 char CrashOnTooManyCUs::ID = 0; 121 char CrashOnTooManyCUs::ID = 0;
123 static RegisterPass<CrashOnTooManyCUs> 122 static RegisterPass<CrashOnTooManyCUs>
124 A("bugpoint-crash-too-many-cus", 123 A("bugpoint-crash-too-many-cus",
125 "BugPoint Test Pass - Intentionally crash on too many CUs"); 124 "BugPoint Test Pass - Intentionally crash on too many CUs");
125
126 namespace {
127 class CrashOnFunctionAttribute : public FunctionPass {
128 public:
129 static char ID; // Pass ID, replacement for typeid
130 CrashOnFunctionAttribute() : FunctionPass(ID) {}
131
132 private:
133 void getAnalysisUsage(AnalysisUsage &AU) const override {
134 AU.setPreservesAll();
135 }
136
137 bool runOnFunction(Function &F) override {
138 AttributeSet A = F.getAttributes().getFnAttributes();
139 if (A.hasAttribute("bugpoint-crash"))
140 abort();
141 return false;
142 }
143 };
144 } // namespace
145
146 char CrashOnFunctionAttribute::ID = 0;
147 static RegisterPass<CrashOnFunctionAttribute>
148 B("bugpoint-crashfuncattr", "BugPoint Test Pass - Intentionally crash on "
149 "function attribute 'bugpoint-crash'");