[Lldb-commits] [lldb] [lldb] Fix evaluation of expressions with static initializers (PR #89063)

2024-04-17 Thread Pavel Labath via lldb-commits

https://github.com/labath closed https://github.com/llvm/llvm-project/pull/89063
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix evaluation of expressions with static initializers (PR #89063)

2024-04-17 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

After 281d71604f418eb952e967d9dc4b26241b7f96a, llvm generates 32-bit 
relocations, which overflow when we load these objects into high memory. 
Interestingly, setting the code model to "large" does not help here (perhaps it 
is the default?). I'm not completely sure that this is the right thing to do, 
but it doesn't seem to cause any ill effects. I'll follow up with the author of 
that patch about the expected behavior here.

---
Full diff: https://github.com/llvm/llvm-project/pull/89063.diff


1 Files Affected:

- (modified) lldb/source/Expression/IRExecutionUnit.cpp (+6-2) 


``diff
diff --git a/lldb/source/Expression/IRExecutionUnit.cpp 
b/lldb/source/Expression/IRExecutionUnit.cpp
index cb9bee8733e15d..7ad0e5ff22b2f6 100644
--- a/lldb/source/Expression/IRExecutionUnit.cpp
+++ b/lldb/source/Expression/IRExecutionUnit.cpp
@@ -13,6 +13,7 @@
 #include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
+#include "llvm/Support/CodeGen.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -279,10 +280,13 @@ void IRExecutionUnit::GetRunnableInfo(Status , 
lldb::addr_t _addr,
   llvm::EngineBuilder builder(std::move(m_module_up));
   llvm::Triple triple(m_module->getTargetTriple());
 
+  // PIC needed for ELF to avoid generating 32-bit relocations (which overflow
+  // if the object is loaded into high memory).
+  bool want_pic = triple.isOSBinFormatMachO() || triple.isOSBinFormatELF();
+
   builder.setEngineKind(llvm::EngineKind::JIT)
   .setErrorStr(_string)
-  .setRelocationModel(triple.isOSBinFormatMachO() ? llvm::Reloc::PIC_
-  : llvm::Reloc::Static)
+  .setRelocationModel(want_pic ? llvm::Reloc::PIC_ : llvm::Reloc::Static)
   .setMCJITMemoryManager(std::make_unique(*this))
   .setOptLevel(llvm::CodeGenOptLevel::Less);
 

``




https://github.com/llvm/llvm-project/pull/89063
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix evaluation of expressions with static initializers (PR #89063)

2024-04-17 Thread Pavel Labath via lldb-commits

https://github.com/labath created 
https://github.com/llvm/llvm-project/pull/89063

After 281d71604f418eb952e967d9dc4b26241b7f96a, llvm generates 32-bit 
relocations, which overflow when we load these objects into high memory. 
Interestingly, setting the code model to "large" does not help here (perhaps it 
is the default?). I'm not completely sure that this is the right thing to do, 
but it doesn't seem to cause any ill effects. I'll follow up with the author of 
that patch about the expected behavior here.

>From e9b74aae92b8d8583d3549c6ef7257fd026678f5 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Wed, 17 Apr 2024 11:58:44 +
Subject: [PATCH] [lldb] Fix evaluation of expressions with static initializers

After 281d71604f418eb952e967d9dc4b26241b7f96a, llvm generates 32-bit
relocations, which overflow when we load these objects into high memory.
Interestingly, setting the code model to "large" does not help here
(perhaps it is the default?). I'm not completely sure that this is the
right thing to do, but it doesn't seem to cause any ill effects.
I'll follow up with the author of that patch about the expected behavior
here.
---
 lldb/source/Expression/IRExecutionUnit.cpp | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Expression/IRExecutionUnit.cpp 
b/lldb/source/Expression/IRExecutionUnit.cpp
index cb9bee8733e15d..7ad0e5ff22b2f6 100644
--- a/lldb/source/Expression/IRExecutionUnit.cpp
+++ b/lldb/source/Expression/IRExecutionUnit.cpp
@@ -13,6 +13,7 @@
 #include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
+#include "llvm/Support/CodeGen.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -279,10 +280,13 @@ void IRExecutionUnit::GetRunnableInfo(Status , 
lldb::addr_t _addr,
   llvm::EngineBuilder builder(std::move(m_module_up));
   llvm::Triple triple(m_module->getTargetTriple());
 
+  // PIC needed for ELF to avoid generating 32-bit relocations (which overflow
+  // if the object is loaded into high memory).
+  bool want_pic = triple.isOSBinFormatMachO() || triple.isOSBinFormatELF();
+
   builder.setEngineKind(llvm::EngineKind::JIT)
   .setErrorStr(_string)
-  .setRelocationModel(triple.isOSBinFormatMachO() ? llvm::Reloc::PIC_
-  : llvm::Reloc::Static)
+  .setRelocationModel(want_pic ? llvm::Reloc::PIC_ : llvm::Reloc::Static)
   .setMCJITMemoryManager(std::make_unique(*this))
   .setOptLevel(llvm::CodeGenOptLevel::Less);
 

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits