sebastien deldon (PGI)
2014-Jun-16 09:57 UTC
[LLVMdev] Is it possible to create a variable that aliases a field in a struct ?
Hi all, Given assert code in alias detection I've opted for a simplification in expressing field address : target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64" %struct._dpowk_16 = type < { [32 x [32 x double]], [32 x [32 x double]], [32 x [32 x i64]] } > @_dpowk_16 = common global %struct._dpowk_16 zeroinitializer, align 16 @r_d_field = alias [32 x [32 x double]] * getelementptr (%struct._dpowk_16 * @_dpowk_16, i32 0, i32 1) Now I've got following error from opt : opt -O2 -S gblmod2.ll -o gblmod2.opt.ll opt: /home/sdeldon/tools/llvm/3.2/llvm-3.2.src/include/llvm/Support/Casting.h:208: typename llvm::cast_retty<To, From>::ret_type llvm::cast(const Y&) [with X = llvm::GlobalValue, Y = llvm::Value*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed. 0 opt 0x00000000010e3abf 1 opt 0x00000000010e5a22 2 libpthread.so.0 0x0000003dd0a0f710 3 libc.so.6 0x0000003dd0232925 gsignal + 53 4 libc.so.6 0x0000003dd0234105 abort + 373 5 libc.so.6 0x0000003dd022ba4e 6 libc.so.6 0x0000003dd022bb10 __assert_perror_fail + 0 7 opt 0x0000000000bf238f 8 opt 0x0000000001083af1 llvm::MPPassManager::runOnModule(llvm::Module&) + 497 9 opt 0x0000000001083c6b llvm::PassManagerImpl::run(llvm::Module&) + 171 10 opt 0x000000000053b307 main + 6999 11 libc.so.6 0x0000003dd021ed1d __libc_start_main + 253 12 opt 0x000000000052c5c9 Stack dump: 0. Program arguments: opt -O2 -S gblmod2.ll -o gblmod2.opt.ll 1. Running pass 'Global Variable Optimizer' on module 'gblmod2.ll'. Is it a BUG ? Seb From: sebastien deldon (PGI) Sent: Friday, June 13, 2014 11:05 AM To: llvmdev Subject: Is it possible to create a variable that aliases a field in a struct ? Hi all, I would like to create a variable that aliases a field in a struct like : %struct._dpowk_16 = type < { [32 x [32 x double]], [32 x [32 x double]], [32 x [32 x i64]] } > @_dpowk_16 = common addrspace(1) global %struct._dpowk_16 zeroinitializer, align 16 @r_d_alias = alias [32 x [32 x double]] addrspace(1) * bitcast (i8 addrspace(1) * getelementptr (i8 addrspace(1) * bitcast (%struct._dpowk_16 addrspace(1)* @_dpowk_16 to i8 addrspace(1) *), i64 8192) to [32 x [32 x double]] addrspace(1) * ) When I use opt I got following message : Aliasee should be either GlobalValue or bitcast of GlobalValue [32 x [32 x double]] addrspace(1)* @r_d_alias Broken module found, compilation aborted! 0 opt 0x00000000010e3abf 1 opt 0x00000000010e5a22 2 libpthread.so.0 0x0000003dd0a0f710 3 libc.so.6 0x0000003dd0232925 gsignal + 53 4 libc.so.6 0x0000003dd0234105 abort + 373 5 opt 0x00000000010a3e8a 6 opt 0x000000000107c654 llvm::FPPassManager::doFinalization(llvm::Module&) + 84 7 opt 0x000000000107df79 llvm::FunctionPassManagerImpl::doFinalization(llvm::Module&) + 105 8 opt 0x000000000053b25d main + 6829 9 libc.so.6 0x0000003dd021ed1d __libc_start_main + 253 10 opt 0x000000000052c5c9 Stack dump: 0. Program arguments: opt -O2 -S gblmod.ll -o gblmod.opt.ll Is there a way to have a global value that reflects a field in a struct ? Thanks for your answers Seb ----------------------------------------------------------------------------------- This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. ----------------------------------------------------------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140616/69371cac/attachment.html>
Reid Kleckner
2014-Jun-17 20:41 UTC
[LLVMdev] Is it possible to create a variable that aliases a field in a struct ?
Previously it was impossible to create an alias with an offset into a global. It appears you've found a way to workaround the check in the verifier, and that understandably crashes LLVM. Rafael recently relaxed this restriction in trunk LLVM, so aliases can now be arbitrary constant expressions. It should support your example. It is now possible to represent some aliases in LLVM that cannot be compiled, so be careful. On Mon, Jun 16, 2014 at 2:57 AM, sebastien deldon (PGI) < sebastien.deldon at pgroup.com> wrote:> Hi all, > > > > Given assert code in alias detection I’ve opted for a simplification in > expressing field address : > > > > target datalayout > "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64" > > > > > > %struct._dpowk_16 = type < { [32 x [32 x double]], [32 x [32 x double]], > [32 x [32 x i64]] } > > > > > @_dpowk_16 = common global %struct._dpowk_16 zeroinitializer, align 16 > > @r_d_field = alias [32 x [32 x double]] * getelementptr (%struct._dpowk_16 > * @_dpowk_16, i32 0, i32 1) > > > > Now I’ve got following error from opt : > > > > opt -O2 -S gblmod2.ll -o gblmod2.opt.ll > > opt: > /home/sdeldon/tools/llvm/3.2/llvm-3.2.src/include/llvm/Support/Casting.h:208: > typename llvm::cast_retty<To, From>::ret_type llvm::cast(const Y&) [with X > = llvm::GlobalValue, Y = llvm::Value*]: Assertion `isa<X>(Val) && > "cast<Ty>() argument of incompatible type!"' failed. > > 0 opt 0x00000000010e3abf > > 1 opt 0x00000000010e5a22 > > 2 libpthread.so.0 0x0000003dd0a0f710 > > 3 libc.so.6 0x0000003dd0232925 gsignal + 53 > > 4 libc.so.6 0x0000003dd0234105 abort + 373 > > 5 libc.so.6 0x0000003dd022ba4e > > 6 libc.so.6 0x0000003dd022bb10 __assert_perror_fail + 0 > > 7 opt 0x0000000000bf238f > > 8 opt 0x0000000001083af1 > llvm::MPPassManager::runOnModule(llvm::Module&) + 497 > > 9 opt 0x0000000001083c6b > llvm::PassManagerImpl::run(llvm::Module&) + 171 > > 10 opt 0x000000000053b307 main + 6999 > > 11 libc.so.6 0x0000003dd021ed1d __libc_start_main + 253 > > 12 opt 0x000000000052c5c9 > > Stack dump: > > 0. Program arguments: opt -O2 -S gblmod2.ll -o gblmod2.opt.ll > > 1. Running pass 'Global Variable Optimizer' on module > 'gblmod2.ll'. > > > > Is it a BUG ? > > > > Seb > > > > > > *From:* sebastien deldon (PGI) > *Sent:* Friday, June 13, 2014 11:05 AM > *To:* llvmdev > *Subject:* Is it possible to create a variable that aliases a field in a > struct ? > > > > Hi all, > > > > I would like to create a variable that aliases a field in a struct like : > > > > %struct._dpowk_16 = type < { [32 x [32 x double]], [32 x [32 x double]], > [32 x [32 x i64]] } > > > > > @_dpowk_16 = common addrspace(1) global %struct._dpowk_16 > zeroinitializer, align 16 > > @r_d_alias = alias [32 x [32 x double]] addrspace(1) * bitcast (i8 > addrspace(1) * getelementptr (i8 addrspace(1) * bitcast (%struct._dpowk_16 > addrspace(1)* @_dpowk_16 to i8 addrspace(1) *), i64 8192) to [32 x [32 x > double]] addrspace(1) * ) > > > > When I use opt I got following message : > > > > Aliasee should be either GlobalValue or bitcast of GlobalValue > > [32 x [32 x double]] addrspace(1)* @r_d_alias > > Broken module found, compilation aborted! > > 0 opt 0x00000000010e3abf > > 1 opt 0x00000000010e5a22 > > 2 libpthread.so.0 0x0000003dd0a0f710 > > 3 libc.so.6 0x0000003dd0232925 gsignal + 53 > > 4 libc.so.6 0x0000003dd0234105 abort + 373 > > 5 opt 0x00000000010a3e8a > > 6 opt 0x000000000107c654 > llvm::FPPassManager::doFinalization(llvm::Module&) + 84 > > 7 opt 0x000000000107df79 > llvm::FunctionPassManagerImpl::doFinalization(llvm::Module&) + 105 > > 8 opt 0x000000000053b25d main + 6829 > > 9 libc.so.6 0x0000003dd021ed1d __libc_start_main + 253 > > 10 opt 0x000000000052c5c9 > > Stack dump: > > 0. Program arguments: opt -O2 -S gblmod.ll -o gblmod.opt.ll > > > > Is there a way to have a global value that reflects a field in a struct ? > > > > Thanks for your answers > > Seb > ------------------------------ > This email message is for the sole use of the intended recipient(s) and > may contain confidential information. Any unauthorized review, use, > disclosure or distribution is prohibited. If you are not the intended > recipient, please contact the sender by reply email and destroy all copies > of the original message. > ------------------------------ > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140617/7889fd44/attachment.html>