llvm-6502/test/SymbolRewriter/rewrite.ll
Saleem Abdulrasool 35c163020a Transform: add SymbolRewriter pass
This introduces the symbol rewriter. This is an IR->IR transformation that is
implemented as a CodeGenPrepare pass. This allows for the transparent
adjustment of the symbols during compilation.

It provides a clean, simple, elegant solution for symbol inter-positioning. This
technique is often used, such as in the various sanitizers and performance
analysis.

The control of this is via a custom YAML syntax map file that indicates source
to destination mapping, so as to avoid having the compiler to know the exact
details of the source to destination transformations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221548 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-07 21:32:08 +00:00

60 lines
2.3 KiB
LLVM

; RUN: opt -mtriple i686-win32 -rewrite-symbols -rewrite-map-file %p/rewrite.map \
; RUN: %s -o - | llvm-dis | FileCheck %s
declare void @source_function()
@source_variable = external global i32
declare void @source_function_pattern_function()
declare void @source_function_pattern_multiple_function_matches()
@source_variable_pattern_variable = external global i32
@source_variable_pattern_multiple_variable_matches = external global i32
declare void @"\01naked_source_function"()
declare void @"\01__imp_missing_global_leader_prefix"()
declare i32 @first_callee()
declare i32 @second_callee()
define i32 @caller() {
%rhs = call i32 @first_callee()
%lhs = call i32 @second_callee()
%res = add i32 %rhs, %lhs
ret i32 %res
}
%struct.S = type { i8 }
@_ZN1SC1Ev = alias void (%struct.S*)* @_ZN1SC2Ev
define void @_ZN1SC2Ev(%struct.S* %this) unnamed_addr align 2 {
entry:
%this.addr = alloca %struct.S*, align 4
store %struct.S* %this, %struct.S** %this.addr, align 4
ret void
}
; CHECK: @target_variable = external global i32
; CHECK-NOT: @source_variable = external global i32
; CHECK: @target_pattern_variable = external global i32
; CHECK-NOT: @source_pattern_variable = external global i32
; CHECK: @target_pattern_multiple_variable_matches = external global i32
; CHECK-NOT: @source_pattern_multiple_variable_matches = external global i32
; CHECK: declare void @target_function()
; CHECK-NOT: declare void @source_function()
; CHECK: declare void @target_pattern_function()
; CHECK-NOT: declare void @source_function_pattern_function()
; CHECK: declare void @target_pattern_multiple_function_matches()
; CHECK-NOT: declare void @source_function_pattern_multiple_function_matches()
; CHECK: declare void @naked_target_function()
; CHECK-NOT: declare void @"\01naked_source_function"()
; CHECK-NOT: declare void @"\01__imp__imported_function"()
; CHECK: declare void @"\01__imp_missing_global_leader_prefix"()
; CHECK-NOT: declare void @"\01__imp_DO_NOT_REWRITE"()
; CHECK: declare i32 @renamed_callee()
; CHECK-NOT: declare i32 @first_callee()
; CHECK: declare i32 @second_callee()
; CHECK: define i32 @caller() {
; CHECK: %rhs = call i32 @renamed_callee()
; CHECK-NOT: %rhs = call i32 @first_callee()
; CHECK: %lhs = call i32 @second_callee()
; CHECK: %res = add i32 %rhs, %lhs
; CHECK: ret i32 %res
; CHECK: }