[llvm] r309657 - [MetaRenamer] Leave `@main` alone.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 31 22:14:46 PDT 2017
Author: davide
Date: Mon Jul 31 22:14:45 2017
New Revision: 309657
URL: http://llvm.org/viewvc/llvm-project?rev=309657&view=rev
Log:
[MetaRenamer] Leave `@main` alone.
To the best of my knowledge -metarenamer is used in two cases:
1) obfuscate names, when e.g. they contain informations that
can't be shared.
2) Improve clarity of the textual IR for testcases.
One of the usecases if getting the output of `opt` and passing it
to the lli interpreter to run the test. If metarenamer renames
@main, lli can't find an entry point.
Added:
llvm/trunk/test/Transforms/MetaRenamer/main.ll
Modified:
llvm/trunk/lib/Transforms/Utils/MetaRenamer.cpp
Modified: llvm/trunk/lib/Transforms/Utils/MetaRenamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/MetaRenamer.cpp?rev=309657&r1=309656&r2=309657&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/MetaRenamer.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/MetaRenamer.cpp Mon Jul 31 22:14:45 2017
@@ -123,7 +123,11 @@ namespace {
TLI.getLibFunc(F, Tmp))
continue;
- F.setName(renamer.newName());
+ // Leave @main alone. The output of -metarenamer might be passed to
+ // lli for execution and the latter needs a main entry point.
+ if (Name != "main")
+ F.setName(renamer.newName());
+
runOnFunction(F);
}
return true;
Added: llvm/trunk/test/Transforms/MetaRenamer/main.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/MetaRenamer/main.ll?rev=309657&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/MetaRenamer/main.ll (added)
+++ llvm/trunk/test/Transforms/MetaRenamer/main.ll Mon Jul 31 22:14:45 2017
@@ -0,0 +1,15 @@
+; Make sure @main is left untouched.
+; RUN: opt -metarenamer -S %s | FileCheck %s
+
+; CHECK: define void @main
+; CHECK: call void @main
+
+define void @main() {
+ call void @patatino()
+ ret void
+}
+
+define void @patatino() {
+ call void @main()
+ ret void
+}
More information about the llvm-commits
mailing list