-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework
StringEncOptStack
option to use globals
We should never desire to have the decoded string variable live in a stack-allocated variable; as literals must remain valid throughout the lifetime of the application. This poses the question of why not using `StringEncOptGlobal` option in the first place. Leveraging `StringEncOptStack` option allows the strings to be decoded lazily; whereas, using `StringEncOptGlobal` as a default option would come to the detriment of performance, since all the strings are decoded at load-time. Hence, decode the string in a global variable locally within the function, and do not decode it twice, if it has already been decoded.
- Loading branch information
1 parent
9bada20
commit 2ec6f40
Showing
3 changed files
with
108 additions
and
33 deletions.
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
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,33 @@ | ||
; | ||
; This file is distributed under the Apache License v2.0. See LICENSE for details. | ||
; | ||
|
||
; REQUIRES: aarch64-registered-target | ||
|
||
; RUN: env OMVLL_CONFIG=%S/config_replace.py clang++ -fpass-plugin=%libOMVLL \ | ||
; RUN: -target arm64-apple-ios17.5.0 -S -emit-llvm -O0 -c %s -o - | FileCheck %s | ||
; | ||
; RUN: env OMVLL_CONFIG=%S/config_replace.py clang++ -fpass-plugin=%libOMVLL \ | ||
; RUN: -target aarch64-linux-android -S -emit-llvm -O0 -c %s -o - | FileCheck %s | ||
; | ||
; CHECK-NOT: {{.*Hello, Stack.*}} | ||
|
||
@__const.main.Hello = private constant [13 x i8] c"Hello, Stack\00", align 1 | ||
|
||
define void @test() { | ||
; CHECK-LABEL: @test( | ||
; CHECK: %5 = getelementptr inbounds [13 x i8], ptr @0, i64 0, i64 0 | ||
; CHECK-NEXT: %6 = load i1, ptr @1, align 1 | ||
; CHECK-NEXT: %7 = icmp eq i1 %6, false | ||
; CHECK-NEXT: br i1 %7, label %8, label %__omvll_decode_wrap.exit | ||
; CHECK: 8: | ||
; CHECK-NEXT: call void @__omvll_decode(ptr %5, ptr @__const.main.Hello, i64 %3, i32 %4) | ||
; CHECK-NEXT: store i1 true, ptr @1, align 1 | ||
; CHECK-NEXT: br label %__omvll_decode_wrap.exit | ||
; CHECK: __omvll_decode_wrap.exit: | ||
; CHECK-NEXT: %puts = call i32 @puts(ptr %5) | ||
%puts = call i32 @puts(ptr @__const.main.Hello) | ||
ret void | ||
} | ||
|
||
declare i32 @puts(ptr) |
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