[llvm] r333217 - Add handling for GlobalAliases in ExecutionEngine::getConstantValue.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Thu May 24 12:07:34 PDT 2018
Author: lhames
Date: Thu May 24 12:07:34 2018
New Revision: 333217
URL: http://llvm.org/viewvc/llvm-project?rev=333217&view=rev
Log:
Add handling for GlobalAliases in ExecutionEngine::getConstantValue.
Patch by Brad Moody. Thanks Brad!
https://reviews.llvm.org/D42160
Added:
llvm/trunk/test/ExecutionEngine/Interpreter/alias.ll
Modified:
llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp
Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp?rev=333217&r1=333216&r2=333217&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp Thu May 24 12:07:34 2018
@@ -903,6 +903,9 @@ GenericValue ExecutionEngine::getConstan
Result.IntVal = cast<ConstantInt>(C)->getValue();
break;
case Type::PointerTyID:
+ while (auto *A = dyn_cast<GlobalAlias>(C)) {
+ C = A->getAliasee();
+ }
if (isa<ConstantPointerNull>(C))
Result.PointerVal = nullptr;
else if (const Function *F = dyn_cast<Function>(C))
Added: llvm/trunk/test/ExecutionEngine/Interpreter/alias.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ExecutionEngine/Interpreter/alias.ll?rev=333217&view=auto
==============================================================================
--- llvm/trunk/test/ExecutionEngine/Interpreter/alias.ll (added)
+++ llvm/trunk/test/ExecutionEngine/Interpreter/alias.ll Thu May 24 12:07:34 2018
@@ -0,0 +1,14 @@
+; RUN: %lli -force-interpreter %s
+
+define i32 @func() {
+entry:
+ ret i32 0
+}
+
+ at alias = alias i32 (), i32 ()* @func
+
+define i32 @main() {
+entry:
+ %call = call i32 @alias()
+ ret i32 %call
+}
More information about the llvm-commits
mailing list