[PATCH] D61524: [BPF] Support for compile once and run everywhere
Yonghong Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 10 16:12:20 PDT 2019
yonghong-song added a comment.
My current implementation has an issue like below:
For the intrinsic call,
@0 = private unnamed_addr constant [8 x i8] c"sk_buff\00", align 1
...
%4 = tail call %struct.anon* @llvm.preserve.di.access.index.p0s_struct.anons.p0s_struct.anons.p0s_struct.sk_buffs(%struct.anon* nonnull %3, %struct.sk_buff* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @0, i64 0, i64 0), i32 1), !dbg !43
The third argument `i8* getelementptr inbounds ([8 x i8], [8 x i8]* @0, i64 0, i64 0)` is constructed with `CreateGlobalStringPtr` which uses GEP internally.
For a test example, if I am using the clang directly to generate .s, everything is okay. But if I am using llc on IR instead, I hit a verification error.
-bash-4.4$ clang -target bpf -O2 -g -Xclang -target-feature -Xclang +offsetreloc -S struct.c
-bash-4.4$ clang -target bpf -O2 -g -Xclang -target-feature -Xclang +offsetreloc -S -emit-llvm struct.c
-bash-4.4$ llc -march=bpfel -filetype=asm -mattr=offsetreloc struct.ll
Global is referenced by parentless instruction!
[8 x i8]* @0
; ModuleID = 'struct.ll'
<badref> = getelementptr inbounds [8 x i8], [8 x i8]* @0, i64 0, i64 0
Global is referenced by parentless instruction!
[1 x i8]* @1
; ModuleID = 'struct.ll'
<badref> = getelementptr inbounds [1 x i8], [1 x i8]* @1, i64 0, i64 0
Global is referenced by parentless instruction!
[1 x i8]* @1
; ModuleID = 'struct.ll'
<badref> = getelementptr inbounds [1 x i8], [1 x i8]* @1, i64 0, i64 0
LLVM ERROR: Broken module found, compilation aborted!
-bash-4.4$
This could be related to my code below
Call->replaceAllUsesWith(Call->getArgOperand(0));
Call->eraseFromParent();
But I do not understand why it works with clang alone and fails with clang/llc.
Have anybody seen similar issues?
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D61524/new/
https://reviews.llvm.org/D61524
More information about the llvm-commits
mailing list