forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#31391 - frewsxcv:test, r=alexcrichton
Part of rust-lang#31185
- Loading branch information
Showing
6 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1048,7 +1048,8 @@ $(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \ | |
$$(S) \ | ||
$(3) \ | ||
"$$(LLVM_LIBDIR_RUSTFLAGS_$(3))" \ | ||
"$$(LLVM_ALL_COMPONENTS_$(3))" | ||
"$$(LLVM_ALL_COMPONENTS_$(3))" \ | ||
"$$(LLVM_CXXFLAGS_$(3))" | ||
@touch -r [email protected]_time $$@ && rm [email protected]_time | ||
else | ||
# FIXME #11094 - The above rule doesn't work right for multiple targets | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-include ../tools.mk | ||
|
||
all: $(call NATIVE_STATICLIB,llvm-pass) | ||
$(RUSTC) plugin.rs -C prefer-dynamic | ||
$(RUSTC) main.rs | ||
|
||
$(TMPDIR)/libllvm-pass.o: | ||
$(CXX) $(LLVM_CXXFLAGS) -c llvm-pass.so.cc -o $(TMPDIR)/libllvm-pass.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
|
||
#include "llvm/IR/Module.h" | ||
|
||
using namespace llvm; | ||
|
||
namespace { | ||
|
||
class TestLLVMPass : public ModulePass { | ||
|
||
public: | ||
|
||
static char ID; | ||
TestLLVMPass() : ModulePass(ID) { } | ||
|
||
bool runOnModule(Module &M) override; | ||
|
||
const char *getPassName() const override { | ||
return "Some LLVM pass"; | ||
} | ||
|
||
}; | ||
|
||
} | ||
|
||
bool TestLLVMPass::runOnModule(Module &M) { | ||
// A couple examples of operations that previously caused segmentation faults | ||
// https://github.com/rust-lang/rust/issues/31067 | ||
|
||
for (auto F = M.begin(); F != M.end(); ++F) { | ||
/* code */ | ||
} | ||
|
||
LLVMContext &C = M.getContext(); | ||
IntegerType *Int8Ty = IntegerType::getInt8Ty(C); | ||
llvm::Type *i = PointerType::get(Int8Ty, 0); | ||
return true; | ||
} | ||
|
||
char TestLLVMPass::ID = 0; | ||
|
||
static RegisterPass<TestLLVMPass> RegisterAFLPass( | ||
"some-llvm-pass", "Some LLVM pass"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
#![feature(plugin)] | ||
#![plugin(some_plugin)] | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
#![feature(plugin_registrar, rustc_private)] | ||
#![crate_type = "dylib"] | ||
#![crate_name = "some_plugin"] | ||
|
||
extern crate rustc; | ||
extern crate rustc_plugin; | ||
|
||
#[link(name = "llvm-pass", kind = "static")] | ||
extern {} | ||
|
||
use rustc_plugin::registry::Registry; | ||
|
||
#[plugin_registrar] | ||
pub fn plugin_registrar(reg: &mut Registry) { | ||
reg.register_llvm_pass("some-llvm-pass"); | ||
} |