Skip to content

Commit ef97444

Browse files
[EVM] Remove EVMModuleLayout pass
After FE changes, entry function has to be the first in the module, so this pass is not needed anymore. Instead, add assert in EVMAsmPrinter that function with "evm-entry-function" attribute has to be the first function in the module. Signed-off-by: Vladimir Radosavljevic <[email protected]>
1 parent 9b4f1fa commit ef97444

File tree

7 files changed

+8
-84
lines changed

7 files changed

+8
-84
lines changed

llvm/lib/Target/EVM/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ add_llvm_target(EVMCodeGen
3737
EVMMarkRecursiveFunctions.cpp
3838
EVMMCInstLower.cpp
3939
EVMMachineFunctionInfo.cpp
40-
EVMModuleLayout.cpp
4140
EVMOptimizeLiveIntervals.cpp
4241
EVMRegColoring.cpp
4342
EVMRegisterInfo.cpp

llvm/lib/Target/EVM/EVM.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ FunctionPass *createEVMCodegenPreparePass();
5757
ImmutablePass *createEVMAAWrapperPass();
5858
ImmutablePass *createEVMExternalAAWrapperPass();
5959
ModulePass *createEVMAlwaysInlinePass();
60-
ModulePass *createEVMModuleLayoutPass();
6160

6261
// ISel and immediate followup passes.
6362
FunctionPass *createEVMISelDag(EVMTargetMachine &TM,
@@ -93,7 +92,6 @@ void initializeEVMBPStackificationPass(PassRegistry &);
9392
void initializeEVMAAWrapperPassPass(PassRegistry &);
9493
void initializeEVMExternalAAWrapperPass(PassRegistry &);
9594
void initializeEVMAlwaysInlinePass(PassRegistry &);
96-
void initializeEVMModuleLayoutPass(PassRegistry &);
9795
void initializeEVMLowerJumpUnlessPass(PassRegistry &);
9896
void initializeEVMFinalizeStackFramesPass(PassRegistry &);
9997
void initializeEVMMarkRecursiveFunctionsPass(PassRegistry &);

llvm/lib/Target/EVM/EVMAsmPrinter.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ void EVMAsmPrinter::emitFunctionEntryLabel() {
102102
}
103103

104104
void EVMAsmPrinter::emitFunctionBodyStart() {
105+
if (MF->getFunction().hasFnAttribute("evm-entry-function") &&
106+
FirstFunctIsHandled)
107+
report_fatal_error("Entry function '" + MF->getName() +
108+
"' isn't the first function in the module.");
109+
105110
if (const auto *MFI = MF->getInfo<EVMMachineFunctionInfo>();
106111
MFI->getHasPushDeployAddress()) {
107112
// TODO: #778. Move the function with PUSHDEPLOYADDRESS to the

llvm/lib/Target/EVM/EVMModuleLayout.cpp

Lines changed: 0 additions & 73 deletions
This file was deleted.

llvm/lib/Target/EVM/EVMTargetMachine.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeEVMTarget() {
6565
initializeEVMAAWrapperPassPass(PR);
6666
initializeEVMExternalAAWrapperPass(PR);
6767
initializeEVMAlwaysInlinePass(PR);
68-
initializeEVMModuleLayoutPass(PR);
6968
initializeEVMLowerJumpUnlessPass(PR);
7069
initializeEVMFinalizeStackFramesPass(PR);
7170
initializeEVMMarkRecursiveFunctionsPass(PR);
@@ -238,7 +237,6 @@ bool EVMPassConfig::addPreISel() {
238237
}
239238

240239
void EVMPassConfig::addCodeGenPrepare() {
241-
addPass(createEVMModuleLayoutPass());
242240
addPass(createEVMCodegenPreparePass());
243241
TargetPassConfig::addCodeGenPrepare();
244242
}

llvm/test/CodeGen/EVM/O3-pipeline.ll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ target triple = "evm"
5555
; CHECK-NEXT: Expand reduction intrinsics
5656
; CHECK-NEXT: Natural Loop Information
5757
; CHECK-NEXT: TLS Variable Hoist
58-
; CHECK-NEXT: EVM module layout
59-
; CHECK-NEXT: FunctionPass Manager
6058
; CHECK-NEXT: Final transformations before code generation
6159
; CHECK-NEXT: Dominator Tree Construction
6260
; CHECK-NEXT: Natural Loop Information

llvm/test/CodeGen/EVM/module-layout.ll

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
; RUN: llc -O3 < %s | FileCheck %s
1+
; RUN: not --crash llc -O3 < %s 2>&1 | FileCheck %s
22
target datalayout = "E-p:256:256-i256:256:256-S256-a:256:256"
33
target triple = "evm"
44

55
declare void @llvm.evm.return(ptr addrspace(1), i256)
66

7-
; CHECK-LABEL: __entry:
8-
; CHECK-LABEL: fun_fib:
7+
; CHECK: LLVM ERROR: Entry function '__entry' isn't the first function in the module.
98

109
define private fastcc i256 @fun_fib(i256 %0) noinline {
1110
entry:
1211
%res = add i256 %0, 1
1312
ret i256 %res
1413
}
1514

16-
define void @__entry() noreturn {
15+
define void @__entry() noreturn "evm-entry-function" {
1716
entry:
1817
%fun_res = tail call fastcc i256 @fun_fib(i256 7)
1918
tail call void @llvm.evm.return(ptr addrspace(1) null, i256 %fun_res)

0 commit comments

Comments
 (0)