1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
15 #include "llvm/IR/Module.h"
21 class TestLLVMPass : public ModulePass {
26 TestLLVMPass() : ModulePass(ID) { }
28 bool runOnModule(Module &M) override;
30 const char *getPassName() const override {
31 return "Some LLVM pass";
38 bool TestLLVMPass::runOnModule(Module &M) {
39 // A couple examples of operations that previously caused segmentation faults
40 // https://github.com/rust-lang/rust/issues/31067
42 for (auto F = M.begin(); F != M.end(); ++F) {
46 LLVMContext &C = M.getContext();
47 IntegerType *Int8Ty = IntegerType::getInt8Ty(C);
48 PointerType::get(Int8Ty, 0);
52 char TestLLVMPass::ID = 0;
54 static RegisterPass<TestLLVMPass> RegisterAFLPass(
55 "some-llvm-pass", "Some LLVM pass");