-
-
Save carlokok/e1c9aef9c8a382afdb280385a422f913 to your computer and use it in GitHub Desktop.
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
; ModuleID = '751b7120e2d883b75150f3fcec6559f0-Program' | |
source_filename = "751b7120e2d883b75150f3fcec6559f0-Program" | |
target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32" | |
target triple = "i686-pc-windows-msvc" | |
%threedoubles = type { double, double, double } | |
define void @TEST(i8*) personality i8* bitcast (void()* @__CxxFrameHandler3 to i8*) { | |
BasicBlock0: | |
%1 = alloca i8*, align 4 | |
store i8* %0, i8** %1 | |
%2 = alloca i32 | |
store i32 0, i32* %2 | |
; << replace the localsescape below with this and it gives the wrong values. | |
;%3 = alloca %threedoubles | |
;store %threedoubles zeroinitializer, %threedoubles* %3 | |
;call void (...) @llvm.localescape(i8** %1, i32* %2, %threedoubles* %3) | |
call void (...) @llvm.localescape(i8** %1, i32* %2) | |
%q4 = load i8*, i8** %1 | |
invoke void @LogI8P(i8* %q4) | |
to label %Resume unwind label %Exception | |
Resume: | |
%loctmp = call i8* @llvm.localaddress() | |
call void @"TEST$Fin0"(i8 0, i8* %loctmp) | |
ret void | |
Exception: | |
%exceptcleanuppad = cleanuppad within none [] | |
%exceptcleanuppadla = call i8* @llvm.localaddress() | |
call void @"TEST$Fin0"(i8 1, i8* %exceptcleanuppadla) [ "funclet"(token %exceptcleanuppad) ] | |
cleanupret from %exceptcleanuppad unwind to caller | |
} | |
declare void @__CxxFrameHandler3() | |
; Function Attrs: nounwind | |
declare void @llvm.localescape(...) | |
declare i8* @llvm.localaddress() | |
declare void @LogI8P(i8*) | |
; Function Attrs: noinline | |
define void @"TEST$Fin0"(i8, i8*) { | |
BasicBlock8: | |
%2 = call i8* @llvm.localrecover(i8* bitcast (void (i8*)* @TEST to i8*), i8* %1, i32 0) | |
%3 = bitcast i8* %2 to i8** | |
%4 = load i8*, i8** %3 | |
call void @LogI8P(i8* %4) | |
ret void | |
} | |
; Function Attrs: nounwind readnone | |
declare i8* @llvm.localrecover(i8*, i8*, i32) | |
; helper.c | |
; compiled with: clang helper.c myfile.ll -o helper.exe | |
#include <stdio.h> | |
void TEST(void* p); | |
void LogI8P(void* p) { printf("Logging pointer %p\r\n", p);} | |
void main() { | |
int a; | |
LogI8P(&a); | |
TEST(&a); | |
} | |
; running as is prints: | |
; - Logging pointer 0093FC54 | |
; - Logging pointer 0093FC54 | |
; - Logging pointer 0093FC54 | |
; replacing the existing llvm.localescape with the commented version: | |
; Logging pointer 00EFFB50 | |
; Logging pointer 00EFFB50 | |
; Logging pointer 00EFFB44 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment